From 787a5bffa2cb91a3d363ede3fcb0e0c59702eea0 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sun, 24 May 2026 23:41:02 +0200 Subject: [PATCH 1/3] Try phpstan 2.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 007974fa..fb624f07 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "keywords": ["static analysis"], "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.1.34" + "phpstan/phpstan": "^2.1.56" }, "conflict": { "doctrine/collections": "<1.0", From 14a9d4a1194effce4846459ff9508e3d8afe3c77 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sun, 24 May 2026 23:48:49 +0200 Subject: [PATCH 2/3] Fix build --- ...eryResultTypeWalkerFetchTypeMatrixTest.php | 27 ++++++++++++++----- ...QueryResultTypeWalkerHydrationModeTest.php | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) 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 { From 5f3f10b67a39c87b2e8ccab30b84d426b1d8bb86 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 25 May 2026 00:09:29 +0200 Subject: [PATCH 3/3] Revert bump --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fb624f07..007974fa 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "keywords": ["static analysis"], "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.1.56" + "phpstan/phpstan": "^2.1.34" }, "conflict": { "doctrine/collections": "<1.0",