diff --git a/tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php b/tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php index c9f07109..af1218a4 100644 --- a/tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php +++ b/tests/Platform/QueryResultTypeWalkerFetchTypeMatrixTest.php @@ -52,10 +52,12 @@ use PHPUnit\Framework\Constraint\IsIdentical; use Psr\Log\LoggerInterface; use Throwable; +use function assert; use function class_exists; use function floor; use function getenv; use function in_array; +use function is_string; use function method_exists; use function reset; use function sprintf; @@ -65,6 +67,9 @@ /** * This test ensures our query type inferring never differs from actual result types produced by PHP, Database drivers and Doctrine (with various versions and configurations). * + * @phpstan-type Driver 'ibm_db2'|'mysqli'|'oci8'|'pdo_mysql'|'pdo_oci'|'pdo_pgsql'|'pdo_sqlite'|'pdo_sqlsrv'|'pgsql'|'sqlite3'|'sqlsrv' + * @phpstan-import-type Params from DriverManager + * * @group platform */ final class QueryResultTypeWalkerFetchTypeMatrixTest extends PHPStanTestCase @@ -4432,6 +4437,7 @@ public static function provideCases(): iterable } /** + * @param Driver $driver * @param mixed $expectedFirstResult * @param array $data * @param self::STRINGIFY_* $stringification @@ -4511,7 +4517,7 @@ private function performDriverTest( } /** - * @param array $connectionParams + * @param Params $connectionParams */ private function createConnection( array $connectionParams @@ -4534,7 +4540,7 @@ private function createConnection( $connection->executeQuery('USE foo'); } - if ($connectionParams['driver'] === 'pdo_mysql') { + if (isset($connectionParams['driver']) && $connectionParams['driver'] === 'pdo_mysql') { $connection->executeQuery('SET GLOBAL max_connections = 1000'); } @@ -4734,23 +4740,29 @@ private function assertInferredResultMatchesExpected( } /** - * @return array + * @return Params */ private function getConnectionParamsForDriver(string $driver): array { switch ($driver) { case 'pdo_mysql': case 'mysqli': + $host = getenv('MYSQL_HOST'); + assert(is_string($host)); + return [ - 'host' => getenv('MYSQL_HOST'), + 'host' => $host, 'user' => 'root', 'password' => 'secret', 'dbname' => 'foo', ]; case 'pdo_pgsql': case 'pgsql': + $host = getenv('PGSQL_HOST'); + assert(is_string($host)); + return [ - 'host' => getenv('PGSQL_HOST'), + 'host' => $host, 'user' => 'root', 'password' => 'secret', 'dbname' => 'foo', @@ -4763,8 +4775,11 @@ private function getConnectionParamsForDriver(string $driver): array ]; case 'pdo_sqlsrv': case 'sqlsrv': + $host = getenv('MSSQL_HOST'); + assert(is_string($host)); + return [ - 'host' => getenv('MSSQL_HOST'), + 'host' => $host, 'user' => 'SA', 'password' => 'Secret.123', // user database is created after connection diff --git a/tests/Type/Doctrine/Query/QueryResultTypeWalkerHydrationModeTest.php b/tests/Type/Doctrine/Query/QueryResultTypeWalkerHydrationModeTest.php index 4c86b2b3..8debc627 100644 --- a/tests/Type/Doctrine/Query/QueryResultTypeWalkerHydrationModeTest.php +++ b/tests/Type/Doctrine/Query/QueryResultTypeWalkerHydrationModeTest.php @@ -114,7 +114,7 @@ public function test(Type $expectedType, string $dql, string $methodName, ?int $ } /** - * @return iterable + * @return iterable */ public static function getTestData(): iterable {