File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
src/phpDocumentor/Reflection/NodeVisitor
tests/unit/phpDocumentor/Reflection/NodeVisitor Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 25
25
use PhpParser \Node \Stmt \Namespace_ ;
26
26
use PhpParser \Node \Stmt \PropertyProperty ;
27
27
use PhpParser \Node \Stmt \Trait_ ;
28
+ use PhpParser \NodeTraverser ;
28
29
use PhpParser \NodeVisitorAbstract ;
29
30
30
31
final class ElementNameResolver extends NodeVisitorAbstract
@@ -81,6 +82,10 @@ public function enterNode(Node $node)
81
82
case Class_::class:
82
83
case Trait_::class:
83
84
case Interface_::class:
85
+ if (is_null ($ node ->name )) {
86
+ return NodeTraverser::DONT_TRAVERSE_CHILDREN ;
87
+ }
88
+
84
89
$ this ->parts ->push ((string )$ node ->name );
85
90
$ node ->fqsen = new Fqsen ($ this ->buildName ());
86
91
break ;
Original file line number Diff line number Diff line change 20
20
use PhpParser \Node \Stmt \ClassConst ;
21
21
use PhpParser \Node \Stmt \Function_ ;
22
22
use PhpParser \Node \Stmt \Namespace_ ;
23
+ use PhpParser \NodeTraverser ;
23
24
24
25
/**
25
26
* Testcase for FqsenResolver
@@ -61,6 +62,21 @@ public function testWithClass()
61
62
$ this ->assertEquals ('\myClass ' , (string )$ class ->fqsen );
62
63
}
63
64
65
+ /**
66
+ * If anonymous classes were processed, we would obtain a
67
+ * InvalidArgumentException for an invalid Fqsen.
68
+ *
69
+ * @covers ::enterNode
70
+ */
71
+ public function testDoesNotEnterAnonymousClass ()
72
+ {
73
+ $ class = new Class_ (null );
74
+ $ this ->assertEquals (
75
+ NodeTraverser::DONT_TRAVERSE_CHILDREN ,
76
+ $ this ->fixture ->enterNode ($ class )
77
+ );
78
+ }
79
+
64
80
/**
65
81
* @covers ::enterNode
66
82
*/
You can’t perform that action at this time.
0 commit comments