1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Stop analysis if parent class cannot be located

This commit is contained in:
Matthew Brown 2017-01-23 13:36:06 -07:00
parent 3ad6ec2e34
commit daa923e243
2 changed files with 13 additions and 3 deletions

View File

@ -354,6 +354,16 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
$storage = self::$storage[strtolower($fq_class_name)];
if (($this->class instanceof PhpParser\Node\Stmt\Class_ ||
$this->class instanceof PhpParser\Node\Stmt\Interface_
) &&
$this->parent_fq_class_name &&
!ClassLikeChecker::classOrInterfaceExists($this->parent_fq_class_name, $this->getFileChecker())
) {
// we should not normally get here
return;
}
if ($this instanceof ClassChecker && $this->class instanceof PhpParser\Node\Stmt\Class_) {
$class_interfaces = ClassChecker::getInterfacesForClass($this->fq_class_name);

View File

@ -554,11 +554,11 @@ class ClassTest extends PHPUnit_Framework_TestCase
public function testMissingParentWithFunction()
{
Config::getInstance()->setCustomErrorLevel('UndefinedClass', Config::REPORT_SUPPRESS);
Config::getInstance()->setCustomErrorLevel('MissingReturnType', Config::REPORT_SUPPRESS);
$stmts = self::$parser->parse('<?php
class A extends B {
/** @return void */
public function foo() { }
class B extends C {
public function fooA() { }
}
');