diff --git a/phpstan.neon.dist b/phpstan.neon.dist index dcdddbb61a5..ff5afbbea9e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -95,6 +95,22 @@ parameters: - '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapAssociativeRow\(\) expects array, array given\.$~' - '~^Parameter #1 \$row of method Doctrine\\DBAL\\Driver\\PgSQL\\Result\:\:mapNumericRow\(\) expects array, array given\.$~' + # https://github.com/phpstan/phpstan-src/pull/2224 + - + message: '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\Connection\:\:exec\(\) should return int\|numeric\-string but returns int\|string\.$~' + count: 1 + path: src/Driver/Mysqli/Connection.php + + - + message: '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\Result\:\:rowCount\(\) should return int\|numeric\-string but returns int\<0, max\>\|string\.$~' + count: 1 + path: src/Driver/Mysqli/Result.php + + - + message: '~^Method Doctrine\\DBAL\\Driver\\Mysqli\\Result\:\:rowCount\(\) should return int\|numeric\-string but returns int\|string\.$~' + count: 1 + path: src/Driver/Mysqli/Result.php + includes: - vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/rules.neon diff --git a/src/Connection.php b/src/Connection.php index 1e39b6d214e..338b4665400 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 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 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 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 int|numeric-string + * * @throws Exception */ public function executeStatement(string $sql, array $params = [], array $types = []): int|string @@ -1369,6 +1371,8 @@ private function handleDriverException( * @param array|array $params * @psalm-param WrapperParameterTypeArray $types * + * @return int|numeric-string + * * @throws Exception */ public function executeUpdate(string $sql, array $params = [], array $types = []): int|string @@ -1390,6 +1394,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 int|numeric-string */ public function exec(string $sql): int|string { diff --git a/src/Driver/Connection.php b/src/Driver/Connection.php index eaafb01ead7..68852e9370b 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 int|numeric-string + * * @throws Exception */ public function exec(string $sql): int|string; diff --git a/src/Driver/Result.php b/src/Driver/Result.php index 64fe253e4b3..500cb88701b 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 int|numeric-string + * * @throws Exception */ public function rowCount(): int|string; diff --git a/src/Query/QueryBuilder.php b/src/Query/QueryBuilder.php index 8b15ad7f1c1..2e7fac483b5 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 int|numeric-string The number of affected rows. * * @throws Exception */ diff --git a/src/Result.php b/src/Result.php index b15babfade7..d532531f586 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 int|numeric-string + * * @throws Exception */ public function rowCount(): int|string diff --git a/src/Statement.php b/src/Statement.php index 78997097d50..9b4a3b43bca 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 int|numeric-string + * * @throws Exception */ public function executeStatement(): int|string