Skip to content

Commit

Permalink
Fix crash on aliased exception
Browse files Browse the repository at this point in the history
Ref #3465
  • Loading branch information
muglug committed May 27, 2020
1 parent 769ac5c commit ef53ee3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Psalm/Internal/Analyzer/Statements/Block/TryAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ public static function analyze(
$statements_analyzer->getAliases()
);

$fq_catch_class = $codebase->classlikes->getUnAliasedName($fq_catch_class);

if ($codebase->alter_code && $fq_catch_class) {
$codebase->classlikes->handleClassLikeReferenceInMigration(
$codebase,
Expand Down
25 changes: 25 additions & 0 deletions tests/TryCatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,31 @@ function foo() : void {
} while (rand(0, 1));
}'
],
'aliasException' => [
'<?php
namespace UserException;
class UserException extends \Exception {
}
namespace Alias\UserException;
use function class_alias;
class_alias(
\UserException\UserException::class,
\Alias\UserException\UserExceptionAlias::class
);
namespace Client;
try {
throw new \Alias\UserException\UserExceptionAlias();
} catch (\Alias\UserException\UserExceptionAlias $e) {
// do nothing
}'
],
];
}

Expand Down

0 comments on commit ef53ee3

Please sign in to comment.