From 1d553a84c2b2b673688a0fd3fc74236fdd9da9cd Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Fri, 22 Nov 2024 17:04:29 +0100 Subject: [PATCH 1/2] Fix broken test --- tests/Rules/CallMethodRuleTest.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/Rules/CallMethodRuleTest.php b/tests/Rules/CallMethodRuleTest.php index 4b8e362..1409c07 100644 --- a/tests/Rules/CallMethodRuleTest.php +++ b/tests/Rules/CallMethodRuleTest.php @@ -8,6 +8,7 @@ use PHPStan\Rules\Methods\MethodCallCheck; use PHPStan\Rules\NullsafeCheck; use PHPStan\Rules\PhpDoc\UnresolvableTypeHelper; +use PHPStan\Rules\Properties\PropertyReflectionFinder; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleLevelHelper; use PHPStan\Testing\RuleTestCase; @@ -17,15 +18,31 @@ class CallMethodRuleTest extends RuleTestCase { protected function getRule(): Rule { - $reflectionProvider = $this->createReflectionProvider(); - $ruleLevelHelper = new RuleLevelHelper($reflectionProvider, true, true, true, false); + $reflectionProvider = self::createReflectionProvider(); + $ruleLevelHelper = new RuleLevelHelper($reflectionProvider, true, true, true, true, false, true); + return new CallMethodsRule( - new MethodCallCheck($reflectionProvider, $ruleLevelHelper, true, true), - new FunctionCallParametersCheck($ruleLevelHelper, new NullsafeCheck(), new PhpVersion(PHP_VERSION_ID), new UnresolvableTypeHelper(), true, false, false, false) + new MethodCallCheck( + $reflectionProvider, + $ruleLevelHelper, + true, + true + ), + new FunctionCallParametersCheck( + $ruleLevelHelper, + new NullsafeCheck(), + new PhpVersion(PHP_VERSION_ID), + new UnresolvableTypeHelper(), + new PropertyReflectionFinder(), + true, + true, + true, + true + ) ); } - public function testSafePregReplace() + public function testSafePregReplace(): void { // FIXME: this rule actually runs code but will always return no error because the rule executed is not the correct one. // This provides code coverage but assert is not ok. From 593271e0dc943615153347cfef95d4ce73d0333d Mon Sep 17 00:00:00 2001 From: Alessandro Lai Date: Sun, 24 Nov 2024 22:40:44 +0100 Subject: [PATCH 2/2] Make requirement of PhpParser 5 explicit --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 14771e8..4b4513b 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,8 @@ "require": { "php": "^7.4 || ^8.0", "phpstan/phpstan": "^2.0", - "thecodingmachine/safe": "^1.0 || ^2.0" + "thecodingmachine/safe": "^1.0 || ^2.0", + "nikic/php-parser": "^5" }, "require-dev": { "phpunit/phpunit": "^9.6",