File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 55use PhpParser \Node ;
66use PHPStan \Analyser \ArgumentsNormalizer ;
77use PHPStan \Analyser \Scope ;
8+ use PHPStan \Php \PhpVersion ;
89use PHPStan \Reflection \ExtendedParametersAcceptor ;
910use PHPStan \Reflection \ReflectionProvider ;
1011use PHPStan \Rules \IdentifierRuleError ;
2223final class NamedArgumentsRule implements Rule
2324{
2425
25- public function __construct (private ReflectionProvider $ reflectionProvider )
26+ public function __construct (
27+ private ReflectionProvider $ reflectionProvider ,
28+ private PhpVersion $ phpVersion ,
29+ )
2630 {
2731 }
2832
@@ -33,6 +37,10 @@ public function getNodeType(): string
3337
3438 public function processNode (Node $ node , Scope $ scope ): array
3539 {
40+ if (!$ this ->phpVersion ->supportsNamedArguments ()) {
41+ return [];
42+ }
43+
3644 if ($ node ->isFirstClassCallable ()) {
3745 return [];
3846 }
Original file line number Diff line number Diff line change 22
33namespace PHPStan \Build ;
44
5+ use PHPStan \Php \PhpVersion ;
56use PHPStan \Rules \Rule ;
67use PHPStan \Testing \RuleTestCase ;
78use const PHP_VERSION_ID ;
@@ -14,7 +15,7 @@ class NamedArgumentsRuleTest extends RuleTestCase
1415
1516 protected function getRule (): Rule
1617 {
17- return new NamedArgumentsRule ($ this ->createReflectionProvider ());
18+ return new NamedArgumentsRule ($ this ->createReflectionProvider (), new PhpVersion ( PHP_VERSION_ID ) );
1819 }
1920
2021 public function testRule (): void
@@ -41,6 +42,10 @@ public function testRule(): void
4142
4243 public function testNoFix (): void
4344 {
45+ if (PHP_VERSION_ID < 80000 ) {
46+ $ this ->markTestSkipped ('Test requires PHP 8.0. ' );
47+ }
48+
4449 $ this ->fix (
4550 __DIR__ . '/data/named-arguments-no-errors.php ' ,
4651 __DIR__ . '/data/named-arguments-no-errors.php ' ,
@@ -49,6 +54,10 @@ public function testNoFix(): void
4954
5055 public function testFix (): void
5156 {
57+ if (PHP_VERSION_ID < 80000 ) {
58+ $ this ->markTestSkipped ('Test requires PHP 8.0. ' );
59+ }
60+
5261 $ this ->fix (
5362 __DIR__ . '/data/named-arguments.php ' ,
5463 __DIR__ . '/data/named-arguments.php.fixed ' ,
You can’t perform that action at this time.
0 commit comments