1
0
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:
Matthew Brown 2019-07-17 20:33:44 -04:00
parent 59dd6393f5
commit ab50c6ce2e
2 changed files with 21 additions and 1 deletions

View File

@ -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;
}
/**

View File

@ -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',
],
];
}
}