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 5
5
use PhpParser \Node ;
6
6
use PHPStan \Analyser \ArgumentsNormalizer ;
7
7
use PHPStan \Analyser \Scope ;
8
+ use PHPStan \Php \PhpVersion ;
8
9
use PHPStan \Reflection \ExtendedParametersAcceptor ;
9
10
use PHPStan \Reflection \ReflectionProvider ;
10
11
use PHPStan \Rules \IdentifierRuleError ;
22
23
final class NamedArgumentsRule implements Rule
23
24
{
24
25
25
- public function __construct (private ReflectionProvider $ reflectionProvider )
26
+ public function __construct (
27
+ private ReflectionProvider $ reflectionProvider ,
28
+ private PhpVersion $ phpVersion ,
29
+ )
26
30
{
27
31
}
28
32
@@ -33,6 +37,10 @@ public function getNodeType(): string
33
37
34
38
public function processNode (Node $ node , Scope $ scope ): array
35
39
{
40
+ if (!$ this ->phpVersion ->supportsNamedArguments ()) {
41
+ return [];
42
+ }
43
+
36
44
if ($ node ->isFirstClassCallable ()) {
37
45
return [];
38
46
}
Original file line number Diff line number Diff line change 2
2
3
3
namespace PHPStan \Build ;
4
4
5
+ use PHPStan \Php \PhpVersion ;
5
6
use PHPStan \Rules \Rule ;
6
7
use PHPStan \Testing \RuleTestCase ;
7
8
use const PHP_VERSION_ID ;
@@ -14,7 +15,7 @@ class NamedArgumentsRuleTest extends RuleTestCase
14
15
15
16
protected function getRule (): Rule
16
17
{
17
- return new NamedArgumentsRule ($ this ->createReflectionProvider ());
18
+ return new NamedArgumentsRule ($ this ->createReflectionProvider (), new PhpVersion ( PHP_VERSION_ID ) );
18
19
}
19
20
20
21
public function testRule (): void
@@ -41,6 +42,10 @@ public function testRule(): void
41
42
42
43
public function testNoFix (): void
43
44
{
45
+ if (PHP_VERSION_ID < 80000 ) {
46
+ $ this ->markTestSkipped ('Test requires PHP 8.0. ' );
47
+ }
48
+
44
49
$ this ->fix (
45
50
__DIR__ . '/data/named-arguments-no-errors.php ' ,
46
51
__DIR__ . '/data/named-arguments-no-errors.php ' ,
@@ -49,6 +54,10 @@ public function testNoFix(): void
49
54
50
55
public function testFix (): void
51
56
{
57
+ if (PHP_VERSION_ID < 80000 ) {
58
+ $ this ->markTestSkipped ('Test requires PHP 8.0. ' );
59
+ }
60
+
52
61
$ this ->fix (
53
62
__DIR__ . '/data/named-arguments.php ' ,
54
63
__DIR__ . '/data/named-arguments.php.fixed ' ,
You can’t perform that action at this time.
0 commit comments