phpstan
phpstan copied to clipboard
PDOStatement::fetchAll signature doesn't match the new PHP 8 format
Bug report
As discussed in https://github.com/phpstan/phpstan-src/pull/597, the PDOStatement::fetchAll doesn't match the new signature in PHP 8.
Code snippet that reproduces the problem
https://phpstan.org/r/7db12f52-a9a5-4fa2-a04f-caab9143bf9f
<?php declare(strict_types = 1);
(new PDOStatement)->fetchAll(
PDO::FETCH_CLASS,
StdClass::class,
[new StdClass]
);
Expected output
No error!
Did PHPStan help you today? Did it make you happy in any way?
This is an awesome piece of software! I'm really putting a lot of work getting one of my biggest code bases to adhere to level 8 so bugs will be picked up quicker in the future! Thanks a bunch :)
This bug report is missing a link to reproduction on phpstan.org.
It will most likely be closed after manual review.
@vixducis After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
@@ @@
PHP 8.0 (1 error)
==========
-6: Parameter #3 ...$args of method PDOStatement::fetchAll() expects (callable(): mixed)|int|string, array(stdClass) given.
+6: Parameter #3 ...$fetch_argument of method PDOStatement::fetchAll() expects (callable(): mixed)|int|string, array(stdClass) given.
PHP 7.1 – 7.4
==========
No errors
Full report
PHP 8.0 (1 error)
| Line | Error |
|---|---|
| 6 | `Parameter #3 ...$fetch_argument of method PDOStatement::fetchAll() expects (callable(): mixed) |
PHP 7.1 – 7.4
No errors
@vixducis After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
@@ @@
PHP 8.0 (1 error)
==========
-6: Parameter #3 ...$args of method PDOStatement::fetchAll() expects (callable(): mixed)|int|string, array(stdClass) given.
+6: Parameter #3 ...$fetch_argument of method PDOStatement::fetchAll() expects (callable(): mixed)|int|string, array{stdClass} given.
PHP 7.1 – 7.4
==========
No errors
Full report
PHP 8.0 (1 error)
| Line | Error |
|---|---|
| 6 | `Parameter #3 ...$fetch_argument of method PDOStatement::fetchAll() expects (callable(): mixed) |
PHP 7.1 – 7.4
No errors
@vixducis After the latest commit in dev-master, PHPStan now reports different result with your code snippet:
@@ @@
PHP 8.0 (1 error)
==========
-6: Parameter #3 ...$args of method PDOStatement::fetchAll() expects (callable(): mixed)|int|string, array(stdClass) given.
+6: Parameter #3 ...$args of method PDOStatement::fetchAll() expects (callable(): mixed)|int|string, array{stdClass} given.
PHP 7.1 – 7.4
==========
No errors
Full report
PHP 8.0 (1 error)
| Line | Error |
|---|---|
| 6 | `Parameter #3 ...$args of method PDOStatement::fetchAll() expects (callable(): mixed) |
PHP 7.1 – 7.4
No errors
This is a more complete example.
https://phpstan.org/r/369660a7-3d3e-46e5-ba07-eb93804b331a
Documentation: https://www.php.net/manual/en/pdostatement.fetchall
Please, fix it. Thanks.