1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Be less brittle when interface does not exist

This commit is contained in:
Matt Brown 2017-01-12 11:16:00 -05:00
parent c20f31855c
commit e300550209
2 changed files with 21 additions and 0 deletions

View File

@ -329,6 +329,10 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
$class_interfaces = ClassChecker::getInterfacesForClass($this->fq_class_name);
foreach ($class_interfaces as $interface_id => $interface_name) {
if (!isset(self::$storage[strtolower($interface_name)])) {
continue;
}
$interface_storage = self::$storage[strtolower($interface_name)];
$storage->public_class_constants += $interface_storage->public_class_constants;

View File

@ -365,4 +365,21 @@ class InterfaceTest extends PHPUnit_Framework_TestCase
$context = new Context('somefile.php');
$file_checker->visitAndAnalyzeMethods($context);
}
/**
* @expectedException \Psalm\Exception\CodeException
* @expectedExceptionMessage UndefinedClass
*/
public function testInvalidImplements()
{
$this->project_checker->registerFile(
getcwd() . '/somefile.php',
'<?php
class C2 implements A {
}
');
$file_checker = new FileChecker(getcwd() . '/somefile.php', $this->project_checker);
$context = new Context('somefile.php');
$file_checker->visitAndAnalyzeMethods($context);
}
}