From 6325243140828dbb4744b8a11ba6b89e8452cd2c Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sun, 26 Feb 2023 08:15:50 +0100 Subject: [PATCH] handle optional dependencies in build step --- composer.json | 20 +++++- phpstan-baseline.neon | 40 ------------ .../config/.phpunit-phpstan-dba-mysqli.cache | 64 ++++++++++++++++--- .../.phpunit-phpstan-dba-pdo-mysql.cache | 64 ++++++++++++++++--- 4 files changed, 129 insertions(+), 59 deletions(-) diff --git a/composer.json b/composer.json index 9a23c9d04..6dbaadec4 100644 --- a/composer.json +++ b/composer.json @@ -50,6 +50,7 @@ "vendor/bin/ecs --ansi --fix" ], "test": [ + "@build", "@putenv DBA_REFLECTOR=mysqli", "@phpunit", "@phpstan", @@ -58,9 +59,11 @@ "@phpunit", "@phpstan", - "@csfix" + "@csfix", + "@clean" ], "record": [ + "@build", "phpstan clear-result-cache", "@putenv DBA_MODE=recording", @@ -72,7 +75,8 @@ "@phpunit", "@phpstan", - "@csfix" + "@csfix", + "@clean" ], "phpstan": [ "phpstan analyse -c phpstan.neon.dist", @@ -83,7 +87,9 @@ "phpstan analyse -c tests/defaultFetchNumeric/config/phpstan.neon.dist" ], "phpstan-baseline": [ - "phpstan analyse -c phpstan.neon.dist --generate-baseline" + "@build", + "phpstan analyse -c phpstan.neon.dist --generate-baseline", + "@clean" ], "phpunit": [ "phpunit -c tests/default/config/phpunit.xml", @@ -91,6 +97,14 @@ "phpunit -c tests/stringify/config/phpunit.xml", "phpunit -c tests/defaultFetchAssoc/config/phpunit.xml", "phpunit -c tests/defaultFetchNumeric/config/phpunit.xml" + ], + "build": [ + "composer require sqlftw/sqlftw --ignore-platform-req=php+", + "composer require doctrine/dbal --ignore-platform-req=php+" + ], + "clean": [ + "composer remove sqlftw/sqlftw --ignore-platform-req=php+", + "composer remove doctrine/dbal --ignore-platform-req=php+" ] }, "config": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index eb532e39e..20608af10 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -25,16 +25,6 @@ parameters: count: 1 path: src/DoctrineReflection/DoctrineReflection.php - - - message: "#^Class Doctrine\\\\DBAL\\\\Result not found\\.$#" - count: 1 - path: src/DoctrineReflection/DoctrineResultObjectType.php - - - - message: "#^Class Doctrine\\\\DBAL\\\\Statement not found\\.$#" - count: 1 - path: src/DoctrineReflection/DoctrineStatementObjectType.php - - message: """ #^Call to deprecated method resolveQueryString\\(\\) of class staabm\\\\PHPStanDba\\\\QueryReflection\\\\QueryReflection\\: @@ -53,41 +43,11 @@ parameters: count: 2 path: src/Extensions/DibiConnectionFetchDynamicReturnTypeExtension.php - - - message: "#^Class Doctrine\\\\DBAL\\\\Connection not found\\.$#" - count: 1 - path: src/Extensions/DoctrineConnectionExecuteQueryDynamicReturnTypeExtension.php - - - - message: "#^Class Doctrine\\\\DBAL\\\\Connection not found\\.$#" - count: 1 - path: src/Extensions/DoctrineConnectionFetchDynamicReturnTypeExtension.php - - - - message: "#^Class Doctrine\\\\DBAL\\\\Connection not found\\.$#" - count: 1 - path: src/Extensions/DoctrineConnectionPrepareDynamicReturnTypeExtension.php - - - - message: "#^Class Doctrine\\\\DBAL\\\\Connection not found\\.$#" - count: 1 - path: src/Extensions/DoctrineConnectionQueryDynamicReturnTypeExtension.php - - - - message: "#^Class Doctrine\\\\DBAL\\\\Result not found\\.$#" - count: 1 - path: src/Extensions/DoctrineResultDynamicReturnTypeExtension.php - - message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantArrayType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantArrays\\(\\) instead\\.$#" count: 1 path: src/Extensions/DoctrineResultDynamicReturnTypeExtension.php - - - message: "#^Class Doctrine\\\\DBAL\\\\Statement not found\\.$#" - count: 1 - path: src/Extensions/DoctrineStatementExecuteDynamicReturnTypeExtension.php - - message: "#^Doing instanceof PHPStan\\\\Type\\\\Constant\\\\ConstantArrayType is error\\-prone and deprecated\\. Use Type\\:\\:getConstantArrays\\(\\) instead\\.$#" count: 1 diff --git a/tests/default/config/.phpunit-phpstan-dba-mysqli.cache b/tests/default/config/.phpunit-phpstan-dba-mysqli.cache index d25872b02..6a3b67b72 100644 --- a/tests/default/config/.phpunit-phpstan-dba-mysqli.cache +++ b/tests/default/config/.phpunit-phpstan-dba-mysqli.cache @@ -5908,7 +5908,13 @@ FROM ada' => 1 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), 'value' => 'adaid', 'isClassString' => false, )), @@ -5930,7 +5936,13 @@ FROM ada' => 0 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), 'value' => 'adaid', 'isClassString' => false, )), @@ -5962,7 +5974,13 @@ FROM ada' => 'keyType' => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), 'value' => 'adaid', 'isClassString' => false, )), @@ -5981,7 +5999,13 @@ FROM ada' => 0 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), 'value' => 'adaid', 'isClassString' => false, )), @@ -10491,7 +10515,13 @@ FROM ada' => 'keyType' => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), 'value' => 'email', 'isClassString' => false, )), @@ -10508,7 +10538,13 @@ FROM ada' => 0 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), 'value' => 'email', 'isClassString' => false, )), @@ -10542,7 +10578,13 @@ FROM ada' => 1 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), 'value' => 'email', 'isClassString' => false, )), @@ -10562,7 +10604,13 @@ FROM ada' => 0 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), 'value' => 'email', 'isClassString' => false, )), diff --git a/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache b/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache index f14957faf..35cbed1de 100644 --- a/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache +++ b/tests/default/config/.phpunit-phpstan-dba-pdo-mysql.cache @@ -5565,7 +5565,13 @@ FROM ada' => 1 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), 'value' => 'adaid', 'isClassString' => false, )), @@ -5587,7 +5593,13 @@ FROM ada' => 0 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), 'value' => 'adaid', 'isClassString' => false, )), @@ -5619,7 +5631,13 @@ FROM ada' => 'keyType' => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), 'value' => 'adaid', 'isClassString' => false, )), @@ -5638,7 +5656,13 @@ FROM ada' => 0 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'adaid', + 'isClassString' => false, + )), 'value' => 'adaid', 'isClassString' => false, )), @@ -9446,7 +9470,13 @@ FROM ada' => 'keyType' => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), 'value' => 'email', 'isClassString' => false, )), @@ -9463,7 +9493,13 @@ FROM ada' => 0 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), 'value' => 'email', 'isClassString' => false, )), @@ -9497,7 +9533,13 @@ FROM ada' => 1 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), 'value' => 'email', 'isClassString' => false, )), @@ -9517,7 +9559,13 @@ FROM ada' => 0 => PHPStan\Type\Constant\ConstantStringType::__set_state(array( 'objectType' => NULL, - 'arrayKeyType' => NULL, + 'arrayKeyType' => + PHPStan\Type\Constant\ConstantStringType::__set_state(array( + 'objectType' => NULL, + 'arrayKeyType' => NULL, + 'value' => 'email', + 'isClassString' => false, + )), 'value' => 'email', 'isClassString' => false, )),