File tree 6 files changed +141
-1
lines changed
6 files changed +141
-1
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,8 @@ These are the available attributes and their corresponding PHPDoc annotations:
122
122
| [ Property] ( https://github.com/php-static-analysis/attributes/blob/main/doc/Property.md ) | ` @property ` ` @var ` |
123
123
| [ PropertyRead] ( https://github.com/php-static-analysis/attributes/blob/main/doc/PropertyRead.md ) | ` @property-read ` |
124
124
| [ PropertyWrite] ( https://github.com/php-static-analysis/attributes/blob/main/doc/PropertyWrite.md ) | ` @property-write ` |
125
+ | [ RequireExtends] ( https://github.com/php-static-analysis/attributes/blob/main/doc/RequireExtends.md ) | ` @require-extends ` |
126
+ | [ RequireImplements] ( https://github.com/php-static-analysis/attributes/blob/main/doc/RequireImplements.md ) | ` @require-implements ` |
125
127
| [ Returns] ( https://github.com/php-static-analysis/attributes/blob/main/doc/Returns.md ) | ` @return ` |
126
128
| [ SelfOutAttributeTest.php] ( ..%2Fphpstan-extension%2Ftests%2FSelfOutAttributeTest.php ) | [ Template] ( https://github.com/php-static-analysis/attributes/blob/main/doc/Template.md ) | ` @template ` |
127
129
| [ TemplateContravariant] ( https://github.com/php-static-analysis/attributes/blob/main/doc/TemplateContravariant.md ) | ` @template-contravariant ` |
Original file line number Diff line number Diff line change 28
28
"require" : {
29
29
"php" : " >=8.0" ,
30
30
"cweagans/composer-patches" : " ^1.7" ,
31
- "php-static-analysis/attributes" : " ^0.1.13 || dev-main" ,
31
+ "php-static-analysis/attributes" : " ^0.1.14 || dev-main" ,
32
32
"rector/rector" : " ^0.19 || ^1.0"
33
33
},
34
34
"require-dev" : {
Original file line number Diff line number Diff line change 9
9
use PhpStaticAnalysis \Attributes \ParamOut ;
10
10
use PhpStaticAnalysis \Attributes \PropertyRead ;
11
11
use PhpStaticAnalysis \Attributes \PropertyWrite ;
12
+ use PhpStaticAnalysis \Attributes \RequireExtends ;
13
+ use PhpStaticAnalysis \Attributes \RequireImplements ;
12
14
use PhpStaticAnalysis \Attributes \SelfOut ;
13
15
use PhpStaticAnalysis \Attributes \TemplateContravariant ;
14
16
use PhpStaticAnalysis \Attributes \TemplateCovariant ;
41
43
new AnnotationToAttribute ('property_read ' , PropertyRead::class),
42
44
new AnnotationToAttribute ('property_write ' , PropertyWrite::class),
43
45
new AnnotationToAttribute ('readonly ' , IsReadOnly::class),
46
+ new AnnotationToAttribute ('require_extends ' , RequireExtends::class),
47
+ new AnnotationToAttribute ('require_implements ' , RequireImplements::class),
44
48
new AnnotationToAttribute ('return ' , Returns::class),
45
49
new AnnotationToAttribute ('self_out ' , SelfOut::class),
46
50
new AnnotationToAttribute ('template ' , Template::class),
Original file line number Diff line number Diff line change 21
21
use PHPStan \PhpDocParser \Ast \PhpDoc \ParamTagValueNode ;
22
22
use PHPStan \PhpDocParser \Ast \PhpDoc \PhpDocTagNode ;
23
23
use PHPStan \PhpDocParser \Ast \PhpDoc \PropertyTagValueNode ;
24
+ use PHPStan \PhpDocParser \Ast \PhpDoc \RequireExtendsTagValueNode ;
25
+ use PHPStan \PhpDocParser \Ast \PhpDoc \RequireImplementsTagValueNode ;
24
26
use PHPStan \PhpDocParser \Ast \PhpDoc \ReturnTagValueNode ;
25
27
use PHPStan \PhpDocParser \Ast \PhpDoc \SelfOutTagValueNode ;
26
28
use PHPStan \PhpDocParser \Ast \PhpDoc \TemplateTagValueNode ;
@@ -287,6 +289,8 @@ private function processAnnotations(PhpDocInfo $phpDocInfo): array
287
289
case $ tagValueNode instanceof ExtendsTagValueNode:
288
290
case $ tagValueNode instanceof ImplementsTagValueNode:
289
291
case $ tagValueNode instanceof MixinTagValueNode:
292
+ case $ tagValueNode instanceof RequireExtendsTagValueNode:
293
+ case $ tagValueNode instanceof RequireImplementsTagValueNode:
290
294
case $ tagValueNode instanceof ReturnTagValueNode:
291
295
case $ tagValueNode instanceof SelfOutTagValueNode:
292
296
case $ tagValueNode instanceof UsesTagValueNode:
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace test \PhpStaticAnalysis \RectorRule \Fixture ;
4
+
5
+ use PhpStaticAnalysis \Attributes \Property ;
6
+
7
+ class RequireClass
8
+ {
9
+ }
10
+
11
+ /**
12
+ * @phpstan-require-extends RequireClass
13
+ */
14
+ trait RequireExtendsAttributeTest
15
+ {
16
+ }
17
+
18
+ /**
19
+ * @codeCoverageIgnore
20
+ * @phpstan-require-extends RequireClass this is the class that needs to be extended
21
+ */
22
+ #[Property(name:'string ' )]
23
+ trait RequireExtendsAttributeTest2
24
+ {
25
+ }
26
+
27
+ /**
28
+ * @psalm-require-extends RequireClass
29
+ */
30
+ trait RequireExtendsAttributeTest3
31
+ {
32
+ }
33
+
34
+ ?>
35
+ -----
36
+ <?php
37
+
38
+ namespace test \PhpStaticAnalysis \RectorRule \Fixture ;
39
+
40
+ use PhpStaticAnalysis \Attributes \Property ;
41
+
42
+ class RequireClass
43
+ {
44
+ }
45
+
46
+ #[\PhpStaticAnalysis \Attributes \RequireExtends('RequireClass ' )]
47
+ trait RequireExtendsAttributeTest
48
+ {
49
+ }
50
+
51
+ /**
52
+ * @codeCoverageIgnore
53
+ */
54
+ #[Property(name:'string ' )]
55
+ #[\PhpStaticAnalysis \Attributes \RequireExtends('RequireClass ' )] // this is the class that needs to be extended
56
+ trait RequireExtendsAttributeTest2
57
+ {
58
+ }
59
+
60
+ #[\PhpStaticAnalysis \Attributes \RequireExtends('RequireClass ' )]
61
+ trait RequireExtendsAttributeTest3
62
+ {
63
+ }
64
+
65
+ ?>
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace test \PhpStaticAnalysis \RectorRule \Fixture ;
4
+
5
+ use PhpStaticAnalysis \Attributes \Property ;
6
+
7
+ interface RequireInterface
8
+ {
9
+ }
10
+
11
+ /**
12
+ * @phpstan-require-implements RequireInterface
13
+ */
14
+ trait RequireImplementsAttributeTest
15
+ {
16
+ }
17
+
18
+ /**
19
+ * @codeCoverageIgnore
20
+ * @phpstan-require-implements RequireInterface this is the interface that needs to be implemented
21
+ */
22
+ #[Property(name:'string ' )]
23
+ trait RequireImplementsAttributeTest2
24
+ {
25
+ }
26
+
27
+ /**
28
+ * @psalm-require-implements RequireInterface
29
+ */
30
+ trait RequireImplementsAttributeTest3
31
+ {
32
+ }
33
+
34
+ ?>
35
+ -----
36
+ <?php
37
+
38
+ namespace test \PhpStaticAnalysis \RectorRule \Fixture ;
39
+
40
+ use PhpStaticAnalysis \Attributes \Property ;
41
+
42
+ interface RequireInterface
43
+ {
44
+ }
45
+
46
+ #[\PhpStaticAnalysis \Attributes \RequireImplements('RequireInterface ' )]
47
+ trait RequireImplementsAttributeTest
48
+ {
49
+ }
50
+
51
+ /**
52
+ * @codeCoverageIgnore
53
+ */
54
+ #[Property(name:'string ' )]
55
+ #[\PhpStaticAnalysis \Attributes \RequireImplements('RequireInterface ' )] // this is the interface that needs to be implemented
56
+ trait RequireImplementsAttributeTest2
57
+ {
58
+ }
59
+
60
+ #[\PhpStaticAnalysis \Attributes \RequireImplements('RequireInterface ' )]
61
+ trait RequireImplementsAttributeTest3
62
+ {
63
+ }
64
+
65
+ ?>
You can’t perform that action at this time.
0 commit comments