Skip to content

Commit c1128ea

Browse files
committed
Cleanup
1 parent 1a8f21d commit c1128ea

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

src/Psalm/Codebase.php

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,6 @@
110110
*/
111111
final class Codebase
112112
{
113-
/**
114-
* A map of fully-qualified use declarations to the files
115-
* that reference them (keyed by filename)
116-
*
117-
* @var array<lowercase-string, array<string, CodeLocation>>
118-
*/
119-
public array $use_referencing_locations = [];
120-
121113
public FileStorageProvider $file_storage_provider;
122114

123115
public ClassLikeStorageProvider $classlike_storage_provider;
@@ -784,13 +776,7 @@ public function findReferencesToProperty(string $property_id): array
784776
public function findReferencesToClassLike(string $fq_class_name): array
785777
{
786778
$fq_class_name_lc = strtolower($fq_class_name);
787-
$locations = $this->code_use_graph?->getClassReferenceLocations($fq_class_name_lc) ?? [];
788-
789-
if (isset($this->use_referencing_locations[$fq_class_name_lc])) {
790-
$locations = [...$locations, ...$this->use_referencing_locations[$fq_class_name_lc]];
791-
}
792-
793-
return $locations;
779+
return $this->code_use_graph?->getClassReferenceLocations($fq_class_name_lc) ?? [];
794780
}
795781

796782
public function findReferencesToClassConstant(string $const_id): array

src/Psalm/Internal/Analyzer/CanAlias.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)