Describe the bug
Intelephense incorrectly raises an error for valid PHP code using PostgreSQL API functions with instance of PgSql\Connection instead of a resource.
To Reproduce
A code snippet (NOT a screenshot of a code snippet) or steps to reproduce the issue
namespace Database;
class Connection
{
/**
* PostgreSQL database handle for open socket
* @var \PgSql\Connection
*/
private $dbconnection;
public function disconnect()
{
if ($this->dbconnection)
{
$status = pg_flush($this->dbconnection); /* error shown here */
}
}
}
Expected behavior
The code should have been accepted as correct because I've set workspace Intelephense settings to PHP version 8.1 which should expect PgSql\Connection as the argument to pg_flush() as documented in official documentation: https://www.php.net/manual/en/function.pg-flush.php
Note that this same error is shown for at least pg_flush(), pg_close(), pg_connection_status(), pg_send_query(), pg_get_result(), pg_last_notice() and pg_errormessage(). Probably for all functions that used to take resource instead of PgSql\Connection in PHP versions older than version 8.1.
Platform and version
VS Code 1.86.2 and Intelephense version v1.10.2 running on Ubuntu 22.04 LTS.
I can only reproduce this if I set my intelephense.environment.phpVersion to something less than 8.1.0. Does reindexing fix it? ctrl + shift + p -> Index workspace .
Describe the bug Intelephense incorrectly raises an error for valid PHP code using PostgreSQL API functions with instance of
PgSql\Connection
instead of a resource.To Reproduce A code snippet (NOT a screenshot of a code snippet) or steps to reproduce the issue
Actual result
Expected behavior The code should have been accepted as correct because I've set workspace Intelephense settings to PHP version 8.1 which should expect
PgSql\Connection
as the argument topg_flush()
as documented in official documentation: https://www.php.net/manual/en/function.pg-flush.phpNote that this same error is shown for at least
pg_flush()
,pg_close()
,pg_connection_status()
,pg_send_query()
,pg_get_result()
,pg_last_notice()
andpg_errormessage()
. Probably for all functions that used to takeresource
instead ofPgSql\Connection
in PHP versions older than version 8.1.Platform and version VS Code 1.86.2 and Intelephense version v1.10.2 running on Ubuntu 22.04 LTS.