mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #1949 - check that aliased name doesn’t exist before transforming
This commit is contained in:
parent
59dd6393f5
commit
ab50c6ce2e
@ -702,7 +702,12 @@ class ClassLikes
|
||||
*/
|
||||
public function getUnAliasedName(string $alias_name)
|
||||
{
|
||||
return $this->classlike_aliases[strtolower($alias_name)] ?? $alias_name;
|
||||
$alias_name_lc = strtolower($alias_name);
|
||||
if (isset($this->existing_classlikes_lc[$alias_name_lc])) {
|
||||
return $alias_name;
|
||||
}
|
||||
|
||||
return $this->classlike_aliases[$alias_name_lc] ?? $alias_name;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -642,6 +642,21 @@ class ClassTest extends TestCase
|
||||
class Bar implements Foo {}',
|
||||
'error_message' => 'UndefinedInterface',
|
||||
],
|
||||
'classAliasAlreadyDefinedClass' => [
|
||||
'<?php
|
||||
class A {}
|
||||
|
||||
class B {}
|
||||
|
||||
if (false) {
|
||||
class_alias(A::class, B::class);
|
||||
}
|
||||
|
||||
function foo(A $a, B $b) : void {
|
||||
if ($a === $b) {}
|
||||
}',
|
||||
'error_message' => 'TypeDoesNotContainType',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user