Skip to content
Permalink
Browse files

Fix #2018 - prevent fatal error on class_aliased class reference

  • Loading branch information...
muglug committed Aug 15, 2019
1 parent 86264a7 commit a4d57e552401231a16443cd882a49fcaf5a5e2fa
Showing with 16 additions and 1 deletion.
  1. +2 −1 src/Psalm/Internal/Codebase/ClassLikes.php
  2. +14 −0 tests/ClassTest.php
@@ -716,7 +716,8 @@ public function addClassAlias(string $fq_class_name, string $alias_name)
public function getUnAliasedName(string $alias_name)
{
$alias_name_lc = strtolower($alias_name);
if (isset($this->existing_classlikes_lc[$alias_name_lc])) {
if ($this->existing_classlikes_lc[$alias_name_lc] ?? false) {
return $alias_name;
}
@@ -429,6 +429,20 @@ class T extends \PHPUnit\Framework\TestCase {
[],
['PropertyNotSetInConstructor'],
],
'classAliasNoException' => [
'<?php
class_alias("Bar\F1", "Bar\F2");
namespace Bar {
class F1 {
public static function baz() : void {}
}
}
namespace {
Bar\F2::baz();
}',
],
];
}

0 comments on commit a4d57e5

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