mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 13:51:54 +01:00
classlike_alias incorrect casing not handled correctly
This commit is contained in:
parent
f84e7af826
commit
249d61ec1b
@ -131,7 +131,12 @@ class ClassLikes
|
||||
/**
|
||||
* @var array<lowercase-string, string>
|
||||
*/
|
||||
private $classlike_aliases = [];
|
||||
private $classlike_aliases_map = [];
|
||||
|
||||
/**
|
||||
* @var array<string, bool>
|
||||
*/
|
||||
private $existing_classlike_aliases = [];
|
||||
|
||||
/**
|
||||
* @var array<string, PhpParser\Node\Stmt\Trait_>
|
||||
@ -750,7 +755,7 @@ class ClassLikes
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isset($this->classlike_aliases[strtolower($fq_class_name)])) {
|
||||
if (isset($this->existing_classlike_aliases[$fq_class_name])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -759,7 +764,7 @@ class ClassLikes
|
||||
|
||||
public function interfaceHasCorrectCasing(string $fq_interface_name): bool
|
||||
{
|
||||
if (isset($this->classlike_aliases[strtolower($fq_interface_name)])) {
|
||||
if (isset($this->existing_classlike_aliases[$fq_interface_name])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -768,7 +773,7 @@ class ClassLikes
|
||||
|
||||
public function enumHasCorrectCasing(string $fq_enum_name): bool
|
||||
{
|
||||
if (isset($this->classlike_aliases[strtolower($fq_enum_name)])) {
|
||||
if (isset($this->existing_classlike_aliases[$fq_enum_name])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -777,7 +782,7 @@ class ClassLikes
|
||||
|
||||
public function traitHasCorrectCase(string $fq_trait_name): bool
|
||||
{
|
||||
if (isset($this->classlike_aliases[strtolower($fq_trait_name)])) {
|
||||
if (isset($this->existing_classlike_aliases[$fq_trait_name])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -820,12 +825,10 @@ class ClassLikes
|
||||
throw new UnexpectedValueException('Could not locate trait statement');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lowercase-string $alias_name
|
||||
*/
|
||||
public function addClassAlias(string $fq_class_name, string $alias_name): void
|
||||
{
|
||||
$this->classlike_aliases[$alias_name] = $fq_class_name;
|
||||
$this->classlike_aliases_map[strtolower($alias_name)] = $fq_class_name;
|
||||
$this->existing_classlike_aliases[$alias_name] = true;
|
||||
}
|
||||
|
||||
public function getUnAliasedName(string $alias_name): string
|
||||
@ -835,7 +838,7 @@ class ClassLikes
|
||||
return $alias_name;
|
||||
}
|
||||
|
||||
$result = $this->classlike_aliases[$alias_name_lc] ?? $alias_name;
|
||||
$result = $this->classlike_aliases_map[$alias_name_lc] ?? $alias_name;
|
||||
if ($result === $alias_name) {
|
||||
return $result;
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ class Scanner
|
||||
}
|
||||
|
||||
foreach ($file_storage->classlikes_in_file as $fq_classlike_name) {
|
||||
$this->codebase->exhumeClassLikeStorage(strtolower($fq_classlike_name), $file_path);
|
||||
$this->codebase->exhumeClassLikeStorage($fq_classlike_name, $file_path);
|
||||
}
|
||||
|
||||
foreach ($file_storage->required_classes as $fq_classlike_name) {
|
||||
@ -736,7 +736,7 @@ class Scanner
|
||||
$new_fq_class_name_lc = strtolower($new_fq_class_name);
|
||||
|
||||
if ($new_fq_class_name_lc !== $fq_class_name_lc) {
|
||||
$classlikes->addClassAlias($new_fq_class_name, $fq_class_name_lc);
|
||||
$classlikes->addClassAlias($new_fq_class_name, $fq_class_name);
|
||||
$fq_class_name_lc = $new_fq_class_name_lc;
|
||||
}
|
||||
|
||||
|
@ -257,8 +257,6 @@ class ExpressionScanner
|
||||
$second_arg_value = substr($second_arg_value, 1);
|
||||
}
|
||||
|
||||
$second_arg_value = strtolower($second_arg_value);
|
||||
|
||||
$codebase->classlikes->addClassAlias(
|
||||
$first_arg_value,
|
||||
$second_arg_value
|
||||
|
@ -86,7 +86,7 @@ class FileStorage
|
||||
public $type_aliases = [];
|
||||
|
||||
/**
|
||||
* @var array<lowercase-string, string>
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public $classlike_aliases = [];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user