phpstan icon indicating copy to clipboard operation
phpstan copied to clipboard

PDOStatement::fetchAll signature doesn't match the new PHP 8 format

Open vixducis opened this issue 4 years ago • 5 comments
trafficstars

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 :)

vixducis avatar Aug 22 '21 18:08 vixducis

This bug report is missing a link to reproduction on phpstan.org.

It will most likely be closed after manual review.

mergeable[bot] avatar Aug 22 '21 18:08 mergeable[bot]

@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

phpstan-bot avatar Sep 12 '21 09:09 phpstan-bot

@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

phpstan-bot avatar Oct 13 '21 17:10 phpstan-bot

@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

phpstan-bot avatar Dec 11 '21 13:12 phpstan-bot

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.

Digitalone1 avatar Jan 18 '24 18:01 Digitalone1