From 210b7df961aa40b4790d77f00b031f38e803f106 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Mon, 6 Feb 2023 03:08:56 -0300 Subject: [PATCH] Set "numeric-string" type for the `@return` annotation in `Result::rowCount()` --- src/Connection.php | 14 ++++++++++---- src/Driver/Connection.php | 4 +++- src/Driver/IBMDB2/Connection.php | 2 +- src/Driver/Result.php | 2 ++ src/Query/QueryBuilder.php | 2 +- src/Result.php | 2 ++ src/Statement.php | 2 ++ 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 2549f04132f..fce431773a6 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -378,7 +378,7 @@ private function addCriteriaCondition( * @param array $criteria * @param array|array $types * - * @return int|string The number of affected rows. + * @return non-negative-int|numeric-string The number of affected rows. * * @throws Exception */ @@ -445,7 +445,7 @@ public function getTransactionIsolation(): TransactionIsolationLevel * @param array $criteria * @param array|array $types * - * @return int|string The number of affected rows. + * @return non-negative-int|numeric-string The number of affected rows. * * @throws Exception */ @@ -482,7 +482,7 @@ public function update(string $table, array $data, array $criteria = [], array $ * @param array $data * @param array|array $types * - * @return int|string The number of affected rows. + * @return non-negative-int|numeric-string The number of affected rows. * * @throws Exception */ @@ -839,6 +839,8 @@ public function executeCacheQuery(string $sql, array $params, array $types, Quer * @param list|array $params * @psalm-param WrapperParameterTypeArray $types * + * @return non-negative-int|numeric-string + * * @throws Exception */ public function executeStatement(string $sql, array $params = [], array $types = []): int|string @@ -878,7 +880,7 @@ public function getTransactionNestingLevel(): int * * If the underlying driver does not support identity columns, an exception is thrown. * - * @return int|string The last insert ID, as an integer or a numeric string. + * @return non-negative-int|numeric-string The last insert ID, as an integer or a numeric string. * * @throws Exception */ @@ -1371,6 +1373,8 @@ private function handleDriverException( * @param array|array $params * @psalm-param WrapperParameterTypeArray $types * + * @return non-negative-int|numeric-string + * * @throws Exception */ public function executeUpdate(string $sql, array $params = [], array $types = []): int|string @@ -1392,6 +1396,8 @@ public function query(string $sql): Result * BC layer for a wide-spread use-case of old DBAL APIs * * @deprecated This API is deprecated and will be removed after 2022 + * + * @return non-negative-int|numeric-string */ public function exec(string $sql): int|string { diff --git a/src/Driver/Connection.php b/src/Driver/Connection.php index f5229a2d298..ea56d2a6351 100644 --- a/src/Driver/Connection.php +++ b/src/Driver/Connection.php @@ -39,6 +39,8 @@ public function quote(string $value): string; * If the number of affected rows is greater than the maximum int value (PHP_INT_MAX), * the number of affected rows may be returned as a string. * + * @return non-negative-int|numeric-string + * * @throws Exception */ public function exec(string $sql): int|string; @@ -57,7 +59,7 @@ public function exec(string $sql): int|string; * previous statement. DO NOT RELY ON THIS BEHAVIOR which is driver-dependent: always use getLastInsertId() right * after executing an INSERT statement. * - * @return int|string The last insert ID, as an integer or a numeric string. + * @return non-negative-int|numeric-string The last insert ID, as an integer or a numeric string. * * @throws Exception */ diff --git a/src/Driver/IBMDB2/Connection.php b/src/Driver/IBMDB2/Connection.php index ae437ce3de9..4d179683a2c 100644 --- a/src/Driver/IBMDB2/Connection.php +++ b/src/Driver/IBMDB2/Connection.php @@ -66,7 +66,7 @@ public function quote(string $value): string return "'" . db2_escape_string($value) . "'"; } - public function exec(string $sql): int|string + public function exec(string $sql): int { $stmt = @db2_exec($this->connection, $sql); diff --git a/src/Driver/Result.php b/src/Driver/Result.php index 64fe253e4b3..66cee2f691b 100644 --- a/src/Driver/Result.php +++ b/src/Driver/Result.php @@ -70,6 +70,8 @@ public function fetchFirstColumn(): array; * * If the number of rows exceeds {@see PHP_INT_MAX}, it might be returned as string if the driver supports it. * + * @return non-negative-int|numeric-string + * * @throws Exception */ public function rowCount(): int|string; diff --git a/src/Query/QueryBuilder.php b/src/Query/QueryBuilder.php index 8b15ad7f1c1..4b9f49eece5 100644 --- a/src/Query/QueryBuilder.php +++ b/src/Query/QueryBuilder.php @@ -303,7 +303,7 @@ public function executeQuery(): Result * * Should be used for INSERT, UPDATE and DELETE * - * @return int|string The number of affected rows. + * @return non-negative-int|numeric-string The number of affected rows. * * @throws Exception */ diff --git a/src/Result.php b/src/Result.php index b15babfade7..73d6a0fab92 100644 --- a/src/Result.php +++ b/src/Result.php @@ -225,6 +225,8 @@ public function iterateColumn(): Traversable * * If the number of rows exceeds {@see PHP_INT_MAX}, it might be returned as string if the driver supports it. * + * @return non-negative-int|numeric-string + * * @throws Exception */ public function rowCount(): int|string diff --git a/src/Statement.php b/src/Statement.php index 78997097d50..0c8441f778a 100644 --- a/src/Statement.php +++ b/src/Statement.php @@ -124,6 +124,8 @@ public function executeQuery(): Result * * If the number of rows exceeds {@see PHP_INT_MAX}, it might be returned as string if the driver supports it. * + * @return non-negative-int|numeric-string + * * @throws Exception */ public function executeStatement(): int|string