Skip to content

Commit 60ad44d

Browse files
committed
Symbol: add getAlias function
This function returns the last segment string of the symbol (eg: for the symbol `Foo\Bar\Baz`, it would return `Baz`). This is important because the part we need to check for each used symbol is comparing its top level namespace with the aliases of each imported symbol.
1 parent 92472ab commit 60ad44d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ImportDetection/Symbol.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ public function getName(): string {
3131
return $this->joinSymbolParts($this->tokens);
3232
}
3333

34+
public function getAlias(): string {
35+
return $this->tokens[count($this->tokens) - 1]['content'];
36+
}
37+
3438
public function isAbsoluteNamespace(): bool {
3539
$type = $this->tokens[0]['type'] ?? '';
3640
return $type === 'T_NS_SEPARATOR';

0 commit comments

Comments
 (0)