Skip to content
Permalink
Browse files

Fix #1949 - check that aliased name doesn’t exist before transforming

  • Loading branch information...
muglug committed Jul 18, 2019
1 parent 59dd639 commit ab50c6ce2e3c0c610714de0f05476f61e22260f7
Showing with 21 additions and 1 deletion.
  1. +6 −1 src/Psalm/Internal/Codebase/ClassLikes.php
  2. +15 −0 tests/ClassTest.php
@@ -702,7 +702,12 @@ public function addClassAlias(string $fq_class_name, string $alias_name)
*/
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 Foo {}
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',
],
];
}
}

0 comments on commit ab50c6c

Please sign in to comment.
You can’t perform that action at this time.