Skip to content
Permalink
Browse files

Fix #1891 - don’t enter class_alias if the class doesn’t exist

  • Loading branch information...
muglug committed Jul 4, 2019
1 parent af52ad2 commit 802016757cfb519bf79488ad18f8ee37609d5db3
@@ -848,7 +848,7 @@ private function registerClassMapFunctionCall(
}
}
if ($function_id === 'class_alias') {
if ($function_id === 'class_alias' && !$this->skip_if_descendants) {
$first_arg = $node->args[0]->value ?? null;
$second_arg = $node->args[1]->value ?? null;
@@ -416,6 +416,19 @@ function foo(string $s) : void {
}
}'
],
'classAliasOnNonexistantClass' => [
'<?php
if (!class_exists(\PHPUnit\Framework\TestCase::class)) {
/** @psalm-suppress UndefinedClass */
class_alias(\PHPUnit_Framework_TestCase::class, \PHPUnit\Framework\TestCase::class);
}
class T extends \PHPUnit\Framework\TestCase {
}',
[],
['PropertyNotSetInConstructor']
],
];
}
@@ -34,3 +34,4 @@ class_alias(A::class, C::class);
// Psalm cannot reason about this in the loading step
class_alias($orig, $alias);
}
@@ -22,3 +22,4 @@ function new_random_bytes($bytes)
return 5;
}
}

0 comments on commit 8020167

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