From 2b59f0bbcaee44879e2137fc990afe22a7f516ad Mon Sep 17 00:00:00 2001 From: Dave Liddament Date: Mon, 16 Dec 2024 17:56:27 +0000 Subject: [PATCH 1/2] BUMP support for PHPStan v2. Also drop composer.lock as this is really a library --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9705cda..0357027 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "library", "require": { "php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", - "phpstan/phpstan": "^1.6" + "phpstan/phpstan": "^1.6|^2.0" }, "require-dev": { "phpunit/phpunit": "^9.0", From 0a65d47568b1124891fbbff2cc405b58121b3433 Mon Sep 17 00:00:00 2001 From: Dave Liddament Date: Mon, 16 Dec 2024 18:09:08 +0000 Subject: [PATCH 2/2] FIX test by adding returning RuleError instead of string --- tests/Integration/NoGotoPhpstanRule.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/Integration/NoGotoPhpstanRule.php b/tests/Integration/NoGotoPhpstanRule.php index ee4622a..f750d11 100644 --- a/tests/Integration/NoGotoPhpstanRule.php +++ b/tests/Integration/NoGotoPhpstanRule.php @@ -8,6 +8,7 @@ use PhpParser\Node\Stmt\Goto_; use PHPStan\Analyser\Scope; use PHPStan\Rules\Rule; +use PHPStan\Rules\RuleErrorBuilder; /** @implements Rule */ final class NoGotoPhpstanRule implements Rule @@ -19,6 +20,10 @@ public function getNodeType(): string public function processNode(Node $node, Scope $scope): array { - return ['goto statement is not allowed. Label: '.$node->name->toString()]; + return [ + RuleErrorBuilder::message('goto statement is not allowed. Label: '.$node->name->toString()) + ->identifier('test.noGoto') + ->build(), + ]; } }