File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types = 1 );
2
+
3
+ namespace PHPStan \Build ;
4
+
5
+ use PhpParser \Node ;
6
+ use PhpParser \Node \Attribute ;
7
+ use PHPStan \Analyser \Scope ;
8
+ use PHPStan \Rules \Rule ;
9
+ use PHPStan \Rules \RuleErrorBuilder ;
10
+ use function sprintf ;
11
+
12
+ /**
13
+ * @implements Rule<Attribute>
14
+ */
15
+ final class AttributeNamedArgumentsRule implements Rule
16
+ {
17
+
18
+ public function getNodeType (): string
19
+ {
20
+ return Attribute::class;
21
+ }
22
+
23
+ public function processNode (Node $ node , Scope $ scope ): array
24
+ {
25
+ foreach ($ node ->args as $ arg ) {
26
+ if ($ arg ->name !== null ) {
27
+ continue ;
28
+ }
29
+
30
+ return [
31
+ RuleErrorBuilder::message (sprintf ('Attribute %s is not using named arguments. ' , $ node ->name ->toString ()))
32
+ ->identifier ('phpstan.attributeWithoutNamedArguments ' )
33
+ ->nonIgnorable ()
34
+ ->build (),
35
+ ];
36
+ }
37
+
38
+ return [];
39
+ }
40
+
41
+ }
Original file line number Diff line number Diff line change @@ -117,6 +117,7 @@ parameters:
117
117
118
118
rules :
119
119
- PHPStan\Build\FinalClassRule
120
+ - PHPStan\Build\AttributeNamedArgumentsRule
120
121
121
122
services :
122
123
-
You can’t perform that action at this time.
0 commit comments