File tree Expand file tree Collapse file tree
src/phpDocumentor/Reflection Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313
1414namespace phpDocumentor \Reflection \NodeVisitor ;
1515
16+ use InvalidArgumentException ;
1617use Override ;
1718use phpDocumentor \Reflection \Fqsen ;
1819use PhpParser \Node ;
@@ -118,14 +119,13 @@ public function enterNode(Node $node): int|null
118119 case Function_::class:
119120 $ this ->parts ->push ($ node ->name . '() ' );
120121 $ this ->setFqsen ($ node );
121-
122- return NodeTraverser::DONT_TRAVERSE_CHILDREN ;
122+ break ;
123123
124124 case ClassMethod::class:
125125 $ this ->parts ->push (':: ' . $ node ->name . '() ' );
126126 $ this ->setFqsen ($ node );
127127
128- return NodeTraverser:: DONT_TRAVERSE_CHILDREN ;
128+ break ;
129129
130130 case ClassConst::class:
131131 $ this ->parts ->push (':: ' );
@@ -172,7 +172,12 @@ private function buildName(): string
172172
173173 private function setFqsen (Node $ node ): void
174174 {
175- $ fqsen = new Fqsen ($ this ->buildName ());
176- $ node ->setAttribute ('fqsen ' , $ fqsen );
175+ try {
176+ $ fqsen = new Fqsen ($ this ->buildName ());
177+ $ node ->setAttribute ('fqsen ' , $ fqsen );
178+ } catch (InvalidArgumentException ) {
179+ // If the name is invalid, we do not set the fqsen attribute. This allows us to continue processing
180+ // the rest of the nodes without interruption.
181+ }
177182 }
178183}
Original file line number Diff line number Diff line change @@ -104,6 +104,13 @@ protected function pExpr_ClassConstFetch(Expr\ClassConstFetch $node): string
104104 return $ placeholder ;
105105 }
106106
107+ // protected function pExpr_ConstFetch(Expr\ConstFetch $node): string
108+ // {
109+ // $className = parent::pName($node->name);
110+ // $className = $this->typeResolver->resolve($className, $this->context);
111+ // return 'trst';
112+ // }
113+
107114 /** @return array<string, Fqsen|Type> */
108115 public function getParts (): array
109116 {
Original file line number Diff line number Diff line change @@ -275,12 +275,22 @@ public function testFunctionContantDefaultIsResolved() : void
275275
276276 self ::assertEquals (
277277 new Expression (
278- '{{ PHPDOCa8cfde6331bd59eb2ac96f8911c4b666 }} ' ,
278+ '{{ PHPDOC0de51a5acf75f22ec3c4a9568981d703 }} ' ,
279279 [
280- '{{ PHPDOCa8cfde6331bd59eb2ac96f8911c4b666 }} ' => new Object_ ( ),
280+ '{{ PHPDOC0de51a5acf75f22ec3c4a9568981d703 }} ' => new Fqsen ( ' \OBJECT ' ),
281281 ],
282282 ),
283283 $ functions ['\bar() ' ]->getArguments ()[0 ]->getDefault ()
284284 );
285+
286+ self ::assertEquals (
287+ new Expression (
288+ '{{ PHPDOC342481e8fedbe60c956b14c1f80f5274 }} ' ,
289+ [
290+ '{{ PHPDOC342481e8fedbe60c956b14c1f80f5274 }} ' => new Fqsen ('\Acme\FOO ' ),
291+ ],
292+ ),
293+ $ functions ['\bar2() ' ]->getArguments ()[0 ]->getDefault ()
294+ );
285295 }
286296}
Original file line number Diff line number Diff line change 22
33use Acme \Plugin ;
44
5+ use const Acme \FOO ;
6+
57function foo ( $ output = Plugin::class ) {}
68
79function bar ( $ output = OBJECT ) {}
10+
11+ function bar2 ( $ output = FOO ) {}
You can’t perform that action at this time.
0 commit comments