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:
parent
c20f31855c
commit
e300550209
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user