From 35e7599344c14d023c89590985fa0042aa1b5f0f Mon Sep 17 00:00:00 2001 From: Dragos Protung Date: Tue, 24 Feb 2026 11:27:13 +0100 Subject: [PATCH] Upgrade PHPStan --- composer.json | 2 +- phpstan-baseline.neon | 18 ++++++++++++++++++ src/Test/KernelTestCase.php | 5 +++-- src/Test/RestControllerWebTestCase.php | 4 ++-- src/Test/Twig/IntegrationTestCase.php | 2 +- .../Constraint/ResponseStatusCodeSameTest.php | 4 ++-- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 79bdb7e..3d376f1 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "moneyphp/money": "^4.8.0", "nesbot/carbon": "^3.11.0", "php-standard-library/phpstan-extension": "^2.0.2", - "phpstan/phpstan": "<=2.1.12", + "phpstan/phpstan": "^2.1.12", "phpstan/phpstan-phpunit": "^2.0.6", "phpstan/phpstan-strict-rules": "^2.0.6", "phpstan/phpstan-symfony": "^2.0.4", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e101479..a269f8a 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3,6 +3,18 @@ parameters: - identifier: trait.unused + - + identifier: staticMethod.internalClass + + - + identifier: method.internal + + - + identifier: method.internalClass + + - + identifier: classConstant.internalClass + - message: '#^Call to method scalarNode\(\) on an unknown class Symfony\\Component\\Config\\Definition\\Builder\\NodeBuilder\\.$#' identifier: class.notFound @@ -93,6 +105,12 @@ parameters: count: 1 path: src/Test/bootstrap.php + - + message: '#^Call to function method_exists\(\) with Doctrine\\ORM\\Configuration and ''enableNativeLazyObj…'' will always evaluate to false\.$#' + identifier: function.impossibleType + count: 1 + path: src/Test/Doctrine/ORM/Query/AST/FunctionTestCase.php + - message: '#^Call to function method_exists\(\) with Doctrine\\ORM\\Configuration and ''enableNativeLazyObj…'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType diff --git a/src/Test/KernelTestCase.php b/src/Test/KernelTestCase.php index 7e3244e..feabb06 100644 --- a/src/Test/KernelTestCase.php +++ b/src/Test/KernelTestCase.php @@ -36,6 +36,7 @@ use function assert; use function class_exists; +use function file_exists; use function str_starts_with; abstract class KernelTestCase extends SymfonyKernelTestCase @@ -249,7 +250,7 @@ protected function loadTestFixtures(): void ); $fixturesFile = $this->getFixturesFileForTest(); - if (! Filesystem\exists($fixturesFile)) { + if (! file_exists($fixturesFile)) { return; } @@ -413,7 +414,7 @@ protected function getPayloadContentFile(string $type): string } $payloadFile = $this->getCurrentPayloadContentFile($type, true); - if (Filesystem\exists($payloadFile)) { + if (file_exists($payloadFile)) { return $payloadFile; } diff --git a/src/Test/RestControllerWebTestCase.php b/src/Test/RestControllerWebTestCase.php index 4b6a9a4..0431638 100644 --- a/src/Test/RestControllerWebTestCase.php +++ b/src/Test/RestControllerWebTestCase.php @@ -6,7 +6,6 @@ use PHPUnit\Framework\ExpectationFailedException; use Psl\File; -use Psl\Filesystem; use Psl\Json; use Psl\Type; use Speicher210\FunctionalTestBundle\Constraint\JsonContentMatches; @@ -19,6 +18,7 @@ use Symfony\Component\Security\Core\User\UserInterface; use function array_replace_recursive; +use function file_exists; use function parse_str; use function parse_url; @@ -233,7 +233,7 @@ protected function assertRestRequest(Request $request, int $expectedStatusCode = $expected = null; if ($expectedStatusCode !== Response::HTTP_NO_CONTENT) { $expectedFile = $this->getExpectedResponseContentFile('json'); - if (Filesystem\exists($expectedFile)) { + if (file_exists($expectedFile)) { $expected = $this->prettifyJson(File\read($expectedFile)); } } diff --git a/src/Test/Twig/IntegrationTestCase.php b/src/Test/Twig/IntegrationTestCase.php index 4f084c2..ba5b450 100644 --- a/src/Test/Twig/IntegrationTestCase.php +++ b/src/Test/Twig/IntegrationTestCase.php @@ -31,7 +31,7 @@ final public function testLegacyIntegration( */ public static function dataProviderTestIntegration(): iterable { - return (new static('test'))->getTests('test'); + return (new static('test'))->getTests('test'); // @phpstan-ignore-line } #[DataProvider('dataProviderTestIntegration')] diff --git a/tests/Constraint/ResponseStatusCodeSameTest.php b/tests/Constraint/ResponseStatusCodeSameTest.php index ec65389..4a7bf43 100644 --- a/tests/Constraint/ResponseStatusCodeSameTest.php +++ b/tests/Constraint/ResponseStatusCodeSameTest.php @@ -14,7 +14,7 @@ final class ResponseStatusCodeSameTest extends TestCase public function testEvaluateReturnsNullForTheSameStatusCode(): void { $response = $this->createMock(Response::class); - $response->expects(self::once())->method('getStatusCode')->willReturn(200); + $response->expects($this->once())->method('getStatusCode')->willReturn(200); $constraint = new ResponseStatusCodeSame(200); @@ -24,7 +24,7 @@ public function testEvaluateReturnsNullForTheSameStatusCode(): void public function testEvaluateThrowsExceptionForDifferentStatusCode(): void { $response = $this->createMock(Response::class); - $response->expects(self::exactly(2))->method('getStatusCode')->willReturn(201); + $response->expects($this->exactly(2))->method('getStatusCode')->willReturn(201); $constraint = new ResponseStatusCodeSame(200);