@@ -51,6 +51,7 @@ trait CanAlias
5151
5252 public function visitUse (PhpParser \Node \Stmt \Use_ $ stmt ): void
5353 {
54+ /** @var Codebase $codebase */
5455 $ codebase = $ this ->getCodebase ();
5556
5657 foreach ($ stmt ->uses as $ use ) {
@@ -75,11 +76,10 @@ public function visitUse(PhpParser\Node\Stmt\Use_ $stmt): void
7576 (int ) $ use ->getAttribute ('endFilePos ' ),
7677 $ use_path ,
7778 );
78- if ($ codebase ->collect_locations ) {
79- // register the path
80- $ loc = new CodeLocation ($ this , $ use );
81- $ codebase ->use_referencing_locations [$ use_path_lc ][$ loc ->getHash ()] = $ loc ;
82- }
79+ $ codebase ->addReferenceToClass (
80+ $ use_path_lc ,
81+ new CodeLocation ($ this , $ use ),
82+ );
8383
8484 if ($ codebase ->alter_code ) {
8585 if (isset ($ codebase ->class_transforms [$ use_path_lc ])) {
@@ -127,11 +127,10 @@ public function visitGroupUse(PhpParser\Node\Stmt\GroupUse $stmt): void
127127 break ;
128128
129129 case PhpParser \Node \Stmt \Use_::TYPE_NORMAL :
130- if ($ codebase ->collect_locations ) {
131- // register the path
132- $ loc = new CodeLocation ($ this , $ use );
133- $ codebase ->use_referencing_locations [strtolower ($ use_path )][$ loc ->getHash ()] = $ loc ;
134- }
130+ $ codebase ->addReferenceToClass (
131+ strtolower ($ use_path ),
132+ new CodeLocation ($ this , $ use ),
133+ );
135134
136135 $ this ->aliased_classes [strtolower ($ use_alias )] = $ use_path ;
137136 $ this ->aliased_classes_flipped [strtolower ($ use_path )] = $ use_alias ;
0 commit comments