@@ -123,7 +123,7 @@ public function __construct(PhpParser\Node\Stmt $class, SourceAnalyzer $source,
123123 throw new UnexpectedValueException ('Anonymous enums are not allowed ' );
124124 }
125125
126- $ fq_class_name = self ::getAnonymousClassName ($ class , $ source ->getFilePath ());
126+ $ fq_class_name = self ::getAnonymousClassName ($ class , $ source ->getAliases (), $ source -> getFilePath ());
127127 }
128128
129129 parent ::__construct ($ class , $ source , $ fq_class_name );
@@ -137,10 +137,25 @@ public function __construct(PhpParser\Node\Stmt $class, SourceAnalyzer $source,
137137 }
138138
139139 /** @return non-empty-string */
140- public static function getAnonymousClassName (PhpParser \Node \Stmt \Class_ $ class , string $ file_path ): string
141- {
142- return preg_replace ('/[^A-Za-z0-9]/ ' , '_ ' , $ file_path )
143- . '_ ' . $ class ->getLine () . '_ ' . (int )$ class ->getAttribute ('startFilePos ' );
140+ public static function getAnonymousClassName (
141+ PhpParser \Node \Stmt \Class_ $ class ,
142+ Aliases $ aliases ,
143+ string $ file_path
144+ ): string {
145+ $ class_name = preg_replace ('/[^A-Za-z0-9]/ ' , '_ ' , $ file_path )
146+ . '_ ' . $ class ->getLine ()
147+ . '_ ' . (int )$ class ->getAttribute ('startFilePos ' );
148+
149+ $ fq_class_name = Type::getFQCLNFromString (
150+ $ class_name ,
151+ $ aliases ,
152+ );
153+
154+ if ($ fq_class_name === '' ) {
155+ throw new LogicException ('Invalid class name, should never happen ' );
156+ }
157+
158+ return $ fq_class_name ;
144159 }
145160
146161 public function analyze (
0 commit comments