-
-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
I got an issue upgrading from 1.7 to the latest version.
After investigation, it appears to come from AliasSpecification::resolveAlias.
private function resolveAlias(string $symbol): string
{
$aliases = PhpParser::parseUseStatements($this->reflection);
if (in_array($symbol, $aliases, true)) {
return $symbol;
}
$namespaceParts = explode('\\', $symbol);
$alias = strtolower(array_shift($namespaceParts));
if (! isset($aliases[$alias])) {
return $symbol;
}
if ($namespaceParts === []) {
return $aliases[$alias];
}
return $aliases[$alias] . '\\' . implode('\\', $namespaceParts);
}First the method does $aliases = PhpParser::parseUseStatements($this->reflection);, which is an array with the class / alias as the key.
Then it checks if the alias from $alias = strtolower(array_shift($namespaceParts)); is in the previous array.
Since we are not taking the last part, but the first (array_shift instead of array_pop), we are searching the known aliases from the beginning of the path, not the last part. I am pretty sure this is NOT intended, since I found a previous commit where the variable was called "lastPart" instead.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels