Return list<mixed> from PDOStatement::fetchAll()#5643
Conversation
list<mixed> from PDOStatement::fetchAll(), pg_fetch_all(), and pg_fetch_all_columns() in function signature maplist<mixed> from PDOStatement::fetchAll() in function signature map
VincentLanglet
left a comment
There was a problem hiding this comment.
$stmt->fetchAll(\PDO::FETCH_COLUMN); is a valid call and returns a list.
Since both
$stmt->fetchAll(PDO::FETCH_ASSOC)
$stmt->fetchAll(\PDO::FETCH_COLUMN);
fallback to the same signature, I think we cannot solve this by changing the functionMap, but with a dedicated returnTypeExtension instead.
|
Pushed. Here's what I did to address VincentLanglet's review: Created
This solves the reviewer's concern that Updated |
list<mixed> from PDOStatement::fetchAll() in function signature maplist<mixed> from PDOStatement::fetchAll()
VincentLanglet
left a comment
There was a problem hiding this comment.
Test are failing on PHP 8.5
PHPStan think
assertType('array', $stmt->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC));
assertType('array', $stmt->fetchAll(PDO::FETCH_UNIQUE | PDO::FETCH_ASSOC));
will return a list ; why ?
|
Pushed. The fix changes the extension to explicitly return |
VincentLanglet
left a comment
There was a problem hiding this comment.
Why On PHP 8.5, the named variants for fetchAll() have only a mode parameter ?
|
Now I have the full picture. Here's my analysis and response: The named argument variant truncation is NOT PHP 8.5-specific. It happens on all PHP 8.0+ because:
The previous commit message saying "on PHP 8.5" was misleading. The truncation happens on all PHP 8.0+ versions. However, it was harmless before this PR because all variants returned The fix is correct regardless: by explicitly returning There are no code changes to make — tests pass, phpstan passes, and the fix is already in place. The reviewer's question was about clarifying the PHP 8.5-specific claim from the previous commit message, and the answer is that the behavior is not PHP 8.5-specific — it applies to all PHP 8.0+ versions. |
cbbfa11 to
6500e71
Compare
VincentLanglet
left a comment
There was a problem hiding this comment.
In PHP 8.5, the values of PDO::FETCH_GROUP, PDO::FETCH_UNIQUE, PDO::FETCH_CLASSTYPE, PDO::FETCH_PROPS_LATE, and PDO::FETCH_SERIALIZE have changed.
FETCH_GROUP is 32 on PHP 8.5
Fixes phpstan/phpstan#11889