File tree 2 files changed +31
-1
lines changed
lib/PhpParser/NodeVisitor
test/PhpParser/NodeVisitor
2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,12 @@ public function enterNode(Node $node) {
110
110
$ node ->type = $ this ->resolveType ($ node ->type );
111
111
}
112
112
$ this ->resolveAttrGroups ($ node );
113
+ } elseif ($ node instanceof Node \PropertyHook) {
114
+ foreach ($ node ->params as $ param ) {
115
+ $ param ->type = $ this ->resolveType ($ param ->type );
116
+ $ this ->resolveAttrGroups ($ param );
117
+ }
118
+ $ this ->resolveAttrGroups ($ node );
113
119
} elseif ($ node instanceof Stmt \Const_) {
114
120
foreach ($ node ->consts as $ const ) {
115
121
$ this ->addNamespacedName ($ const );
Original file line number Diff line number Diff line change @@ -201,6 +201,18 @@ class A extends B implements C, D {
201
201
public const X A = X::Bar;
202
202
public const X\Foo B = X\Foo::Bar;
203
203
public const \X\Foo C = \X\Foo::Bar;
204
+
205
+ public Foo $foo {
206
+ #[X]
207
+ set(#[X] Bar $v) {}
208
+ }
209
+
210
+ public function __construct(
211
+ public Foo $bar {
212
+ #[X]
213
+ set(#[X] Bar $v) {}
214
+ }
215
+ ) {}
204
216
}
205
217
206
218
#[X]
@@ -269,6 +281,18 @@ class A extends \NS\B implements \NS\C, \NS\D
269
281
public const \NS\X A = \NS\X::Bar;
270
282
public const \NS\X\Foo B = \NS\X\Foo::Bar;
271
283
public const \X\Foo C = \X\Foo::Bar;
284
+ public \NS\Foo $foo {
285
+ #[\NS\X]
286
+ set(#[\NS\X] \NS\Bar $v) {
287
+ }
288
+ }
289
+ public function __construct(public \NS\Foo $bar {
290
+ #[\NS\X]
291
+ set(#[\NS\X] \NS\Bar $v) {
292
+ }
293
+ })
294
+ {
295
+ }
272
296
}
273
297
#[\NS\X]
274
298
interface A extends \NS\C, \NS\D
@@ -543,7 +567,7 @@ public function testAttributeOnlyMode(): void {
543
567
}
544
568
545
569
private function parseAndResolve (string $ code ): array {
546
- $ parser = new PhpParser \Parser \Php7 (new PhpParser \Lexer \Emulative ());
570
+ $ parser = new PhpParser \Parser \Php8 (new PhpParser \Lexer \Emulative ());
547
571
$ traverser = new PhpParser \NodeTraverser ();
548
572
$ traverser ->addVisitor (new NameResolver ());
549
573
You can’t perform that action at this time.
0 commit comments