You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHPStan (1.6.2) incorrectly reports errors for pg_query() for PHP 8.1:
It does not seam to be aware that pg_query() expects a PgSql\Connection object as the first parameter and returns a PgSql\Result object as of PHP 8.1. I have checked the PHP 8 stubs at https://github.com/phpstan/php-8-stubs/blob/main/stubs/ext/pgsql/pg_query.php but cannot spot an issue there as those signatures include the correct PHP 8.1 derivative.
Code snippet that reproduces the problem
function test(): \PgSql\Result|false {
return \pg_query(\pg_connect(''), '');
}
@@ @@-PHP 8.1 (3 errors)+PHP 8.1 (1 error)
==========
-3: Function test() never returns PgSql\Result so it can be removed from the return type.-4: Function test() should return PgSql\Result|false but returns resource|false.-4: Parameter #1 $connection of function pg_query expects resource, PgSql\Connection|false given.+4: Parameter #1 $connection of function pg_query expects PgSql\Connection|string, PgSql\Connection|false given.
PHP 8.0 (4 errors)
==========
Full report
PHP 8.1 (1 error)
Line
Error
4
`Parameter #1 $connection of function pg_query expects PgSql\Connection
PHP 8.0 (4 errors)
Line
Error
3
Function test() has invalid return type PgSql\Result.
3
Function test() never returns PgSql\Result so it can be removed from the return type.
4
`Function test() should return PgSql\Result
4
`Parameter #1 $connection of function pg_query expects resource, resource
PHP 7.1 – 7.4 (5 errors)
Line
Error
3
Function test() has invalid return type PgSql\Result.
3
Function test() never returns PgSql\Result so it can be removed from the return type.
3
Function test() uses native union types but they're supported only on PHP 8.0 and later.
4
`Function test() should return PgSql\Result
4
`Parameter #1 $connection of function pg_query expects resource, resource
Bug report
PHPStan (1.6.2) incorrectly reports errors for
pg_query()
for PHP 8.1:It does not seam to be aware that
pg_query()
expects aPgSql\Connection
object as the first parameter and returns aPgSql\Result
object as of PHP 8.1. I have checked the PHP 8 stubs at https://github.com/phpstan/php-8-stubs/blob/main/stubs/ext/pgsql/pg_query.php but cannot spot an issue there as those signatures include the correct PHP 8.1 derivative.Code snippet that reproduces the problem
https://phpstan.org/r/e6aba2b0-e06c-4e46-835a-a1b1fbe294d3
Expected output
No error messages
The text was updated successfully, but these errors were encountered: