-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Support question
I have a unit test for an "older" code base that was first built for PHP 7.0/7.1. I run my test from inside a docker container and do not have the PDO_MySQL extension installed. With the following PHPUnit data provider ;
/**
* @return array<int, array<int|string>>
*/
public function attributeDataProvider(): array
{
return [
[\PDO::MYSQL_ATTR_SSL_CA, 'sslCAFile', '/ca/file'],
[\PDO::MYSQL_ATTR_SSL_CERT, 'sslCertFile', '/cert/file'],
[\PDO::MYSQL_ATTR_SSL_KEY, 'sslKeyFile', '/key/file']
];
}
PHPStan throws:
------ ----------------------------------------------------------------------
Line tests/UnitTests/ConnectionAttributeTest.php
------ ----------------------------------------------------------------------
37 Access to undefined constant PDO::MYSQL_ATTR_SSL_CA.
38 Access to undefined constant PDO::MYSQL_ATTR_SSL_CERT.
39 Access to undefined constant PDO::MYSQL_ATTR_SSL_KEY.
65 Access to undefined constant PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT.
------ ----------------------------------------------------------------------
If I install the PDO_MySQL extension in the container, the PHPStan doesn't squawk about the PDO constants. I read in issue #2840 Stub PDO constants? that PHPStan uses constants from JetBrains/phpstorm-stubs. The aforementioned PDO::* constants are present in the phpstorm-stubs. Does PHPStan require the PDO_MySQL extension to be installed or did I stumble across a bug?
If the former, is there anyway to use \PDO::constants and the like without having to install their respective php extensions to avoid false positives?