1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 01:37:23 +01:00

bugfix: resolve recursive aliases in multiple methods

- `ClassLikes#hasFullyQualifiedClassName`
- `ClassLikes#hasFullyQualifiedInterfaceName`
- `ClassLikes#hasFullyQualifiedEnumName`
- `ClassLikes#hasFullyQualifiedTraitName`
- `ClassLikes#classExtends`
- `ClassLikes#classImplements`

Signed-off-by: Maximilian Bösing <2189546+boesing@users.noreply.github.com>
This commit is contained in:
Maximilian Bösing 2021-08-18 16:37:08 +02:00
parent 4e0484f283
commit c9aebe3082
No known key found for this signature in database
GPG Key ID: 9A8988C93CEC81A3

View File

@ -321,11 +321,7 @@ class ClassLikes
?string $calling_fq_class_name = null,
?string $calling_method_id = null
): bool {
$fq_class_name_lc = strtolower($fq_class_name);
if (isset($this->classlike_aliases[$fq_class_name_lc])) {
$fq_class_name_lc = strtolower($this->classlike_aliases[$fq_class_name_lc]);
}
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));
if ($code_location) {
if ($calling_method_id) {
@ -392,11 +388,7 @@ class ClassLikes
?string $calling_fq_class_name = null,
?string $calling_method_id = null
): bool {
$fq_class_name_lc = strtolower($fq_class_name);
if (isset($this->classlike_aliases[$fq_class_name_lc])) {
$fq_class_name_lc = strtolower($this->classlike_aliases[$fq_class_name_lc]);
}
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));
if (!isset($this->existing_interfaces_lc[$fq_class_name_lc])
|| !$this->existing_interfaces_lc[$fq_class_name_lc]
@ -463,11 +455,7 @@ class ClassLikes
?string $calling_fq_class_name = null,
?string $calling_method_id = null
): bool {
$fq_class_name_lc = strtolower($fq_class_name);
if (isset($this->classlike_aliases[$fq_class_name_lc])) {
$fq_class_name_lc = strtolower($this->classlike_aliases[$fq_class_name_lc]);
}
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));
if (!isset($this->existing_enums_lc[$fq_class_name_lc])
|| !$this->existing_enums_lc[$fq_class_name_lc]
@ -530,11 +518,7 @@ class ClassLikes
public function hasFullyQualifiedTraitName(string $fq_class_name, ?CodeLocation $code_location = null): bool
{
$fq_class_name_lc = strtolower($fq_class_name);
if (isset($this->classlike_aliases[$fq_class_name_lc])) {
$fq_class_name_lc = strtolower($this->classlike_aliases[$fq_class_name_lc]);
}
$fq_class_name_lc = strtolower($this->getUnAliasedName($fq_class_name));
if (!isset($this->existing_traits_lc[$fq_class_name_lc]) ||
!$this->existing_traits_lc[$fq_class_name_lc]
@ -622,15 +606,14 @@ class ClassLikes
*/
public function classExtends(string $fq_class_name, string $possible_parent, bool $from_api = false): bool
{
$fq_class_name_lc = strtolower($fq_class_name);
$unaliased_fq_class_name = $this->getUnAliasedName($fq_class_name);
$unaliased_fq_class_name_lc = strtolower($unaliased_fq_class_name);
if ($fq_class_name_lc === 'generator') {
if ($unaliased_fq_class_name_lc === 'generator') {
return false;
}
$fq_class_name = $this->classlike_aliases[$fq_class_name_lc] ?? $fq_class_name;
$class_storage = $this->classlike_storage_provider->get($fq_class_name_lc);
$class_storage = $this->classlike_storage_provider->get($unaliased_fq_class_name);
if ($from_api && !$class_storage->populated) {
throw new UnpopulatedClasslikeException($fq_class_name);
@ -666,9 +649,7 @@ class ClassLikes
return false;
}
if (isset($this->classlike_aliases[$fq_class_name])) {
$fq_class_name = $this->classlike_aliases[$fq_class_name];
}
$fq_class_name = $this->getUnAliasedName($fq_class_name);
if (!$this->classlike_storage_provider->has($fq_class_name)) {
return false;