From 300470ed0da4f61fb1faaad29bd8693969e185af Mon Sep 17 00:00:00 2001 From: Markus Staab <47448731+clxmstaab@users.noreply.github.com> Date: Wed, 12 Mar 2025 17:01:28 +0100 Subject: [PATCH 1/5] fix build --- composer.json | 2 +- src/Rules/PHPUnit/ClassCoversExistsRule.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 3453041e..01bb8000 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.0.4" + "phpstan/phpstan": "^2.1.8" }, "conflict": { "phpunit/phpunit": "<7.0" diff --git a/src/Rules/PHPUnit/ClassCoversExistsRule.php b/src/Rules/PHPUnit/ClassCoversExistsRule.php index f8d831c9..a36317ef 100644 --- a/src/Rules/PHPUnit/ClassCoversExistsRule.php +++ b/src/Rules/PHPUnit/ClassCoversExistsRule.php @@ -50,7 +50,7 @@ public function processNode(Node $node, Scope $scope): array { $classReflection = $node->getClassReflection(); - if (!$classReflection->isSubclassOf(TestCase::class)) { + if (!$classReflection->is(TestCase::class)) { return []; } From 8df1567d10ed4a43d42082b4e346bf3e17b2ab1d Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 12 Mar 2025 17:03:14 +0100 Subject: [PATCH 2/5] fix --- src/Rules/PHPUnit/ClassMethodCoversExistsRule.php | 2 +- src/Rules/PHPUnit/DataProviderDeclarationRule.php | 2 +- src/Rules/PHPUnit/NoMissingSpaceInClassAnnotationRule.php | 2 +- src/Rules/PHPUnit/NoMissingSpaceInMethodAnnotationRule.php | 2 +- src/Rules/PHPUnit/ShouldCallParentMethodsRule.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Rules/PHPUnit/ClassMethodCoversExistsRule.php b/src/Rules/PHPUnit/ClassMethodCoversExistsRule.php index 4bfdc417..dd328f83 100644 --- a/src/Rules/PHPUnit/ClassMethodCoversExistsRule.php +++ b/src/Rules/PHPUnit/ClassMethodCoversExistsRule.php @@ -56,7 +56,7 @@ public function processNode(Node $node, Scope $scope): array return []; } - if (!$classReflection->isSubclassOf(TestCase::class)) { + if (!$classReflection->is(TestCase::class)) { return []; } diff --git a/src/Rules/PHPUnit/DataProviderDeclarationRule.php b/src/Rules/PHPUnit/DataProviderDeclarationRule.php index cc44eeb4..1983493c 100644 --- a/src/Rules/PHPUnit/DataProviderDeclarationRule.php +++ b/src/Rules/PHPUnit/DataProviderDeclarationRule.php @@ -52,7 +52,7 @@ public function processNode(Node $node, Scope $scope): array { $classReflection = $scope->getClassReflection(); - if ($classReflection === null || !$classReflection->isSubclassOf(TestCase::class)) { + if ($classReflection === null || !$classReflection->is(TestCase::class)) { return []; } diff --git a/src/Rules/PHPUnit/NoMissingSpaceInClassAnnotationRule.php b/src/Rules/PHPUnit/NoMissingSpaceInClassAnnotationRule.php index c8fd3a14..a2fc39f1 100644 --- a/src/Rules/PHPUnit/NoMissingSpaceInClassAnnotationRule.php +++ b/src/Rules/PHPUnit/NoMissingSpaceInClassAnnotationRule.php @@ -33,7 +33,7 @@ public function getNodeType(): string public function processNode(Node $node, Scope $scope): array { $classReflection = $scope->getClassReflection(); - if ($classReflection === null || $classReflection->isSubclassOf(TestCase::class) === false) { + if ($classReflection === null || $classReflection->is(TestCase::class) === false) { return []; } diff --git a/src/Rules/PHPUnit/NoMissingSpaceInMethodAnnotationRule.php b/src/Rules/PHPUnit/NoMissingSpaceInMethodAnnotationRule.php index a44fc539..906e60b1 100644 --- a/src/Rules/PHPUnit/NoMissingSpaceInMethodAnnotationRule.php +++ b/src/Rules/PHPUnit/NoMissingSpaceInMethodAnnotationRule.php @@ -33,7 +33,7 @@ public function getNodeType(): string public function processNode(Node $node, Scope $scope): array { $classReflection = $scope->getClassReflection(); - if ($classReflection === null || $classReflection->isSubclassOf(TestCase::class) === false) { + if ($classReflection === null || $classReflection->is(TestCase::class) === false) { return []; } diff --git a/src/Rules/PHPUnit/ShouldCallParentMethodsRule.php b/src/Rules/PHPUnit/ShouldCallParentMethodsRule.php index 4035dcc9..bfd31690 100644 --- a/src/Rules/PHPUnit/ShouldCallParentMethodsRule.php +++ b/src/Rules/PHPUnit/ShouldCallParentMethodsRule.php @@ -33,7 +33,7 @@ public function processNode(Node $node, Scope $scope): array return []; } - if (!$scope->getClassReflection()->isSubclassOf(TestCase::class)) { + if (!$scope->getClassReflection()->is(TestCase::class)) { return []; } From 4f89c2da9d0e00730857bfd418c38bfaff001c99 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Wed, 12 Mar 2025 17:19:33 +0100 Subject: [PATCH 3/5] Discard changes to composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 01bb8000..3453041e 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ ], "require": { "php": "^7.4 || ^8.0", - "phpstan/phpstan": "^2.1.8" + "phpstan/phpstan": "^2.0.4" }, "conflict": { "phpunit/phpunit": "<7.0" From 685fcc58290f8a1f56982d811ff386fb38215064 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 13 Mar 2025 13:55:35 +0100 Subject: [PATCH 4/5] Update composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 3453041e..212c518f 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ }, "require-dev": { "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan-deprecation-rules": "^2.0", "phpstan/phpstan-strict-rules": "^2.0", "phpunit/phpunit": "^9.6" }, From 839b279a1ddf1bfda8345da765f27c6c3fefc419 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 13 Mar 2025 13:57:37 +0100 Subject: [PATCH 5/5] fix --- phpstan.neon | 1 + src/Rules/PHPUnit/DataProviderHelper.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 2b8fa1ae..7c96296a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,6 +2,7 @@ includes: - extension.neon - rules.neon - vendor/phpstan/phpstan-strict-rules/rules.neon + - vendor/phpstan/phpstan-deprecation-rules/rules.neon - phar://phpstan.phar/conf/bleedingEdge.neon - phpstan-baseline.neon diff --git a/src/Rules/PHPUnit/DataProviderHelper.php b/src/Rules/PHPUnit/DataProviderHelper.php index ad354fa5..aad678e3 100644 --- a/src/Rules/PHPUnit/DataProviderHelper.php +++ b/src/Rules/PHPUnit/DataProviderHelper.php @@ -76,7 +76,7 @@ public function getDataProviderMethods( } $dataProviderMethod = $this->parseDataProviderAnnotationValue($scope, $dataProviderValue); - $dataProviderMethod[] = $node->getLine(); + $dataProviderMethod[] = $node->getStartLine(); yield $dataProviderValue => $dataProviderMethod; } @@ -257,7 +257,7 @@ private function parseDataProviderExternalAttribute(Attribute $attribute): ?arra sprintf('%s::%s', $className, $methodNameArg->value) => [ $dataProviderClassReflection, $methodNameArg->value, - $attribute->getLine(), + $attribute->getStartLine(), ], ]; } @@ -279,7 +279,7 @@ private function parseDataProviderAttribute(Attribute $attribute, ClassReflectio $methodNameArg->value => [ $classReflection, $methodNameArg->value, - $attribute->getLine(), + $attribute->getStartLine(), ], ]; }