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

Fix #184 - prevent classes without reflected classes from breaking everything

This commit is contained in:
Matthew Brown 2017-07-09 14:36:06 -04:00
parent a2a86ef9b1
commit 32ff386b4a
2 changed files with 28 additions and 14 deletions

View File

@ -447,8 +447,18 @@ class MethodChecker extends FunctionLikeChecker
$declaring_method_id = self::getDeclaringMethodId($method_id);
$appearing_method_id = self::getAppearingMethodId($method_id);
list($declaring_method_class) = explode('::', (string)$declaring_method_id);
list($appearing_method_class) = explode('::', (string)$appearing_method_id);
if ($declaring_method_id === null && $appearing_method_id === null) {
list($method_class, $method_name) = explode('::', $method_id);
if ($method_name === '__construct') {
return null;
}
throw new \UnexpectedValueException('$declaring_method_id not expected to be null here');
}
list($declaring_method_class) = explode('::', $declaring_method_id);
list($appearing_method_class) = explode('::', $appearing_method_id);
// if the calling class is the same, we know the method exists, so it must be visible
if ($appearing_method_class === $calling_context) {

View File

@ -12,6 +12,10 @@ class MethodCallTest extends TestCase
public function providerFileCheckerValidCodeParse()
{
return [
'notInCallMapTest' => [
'<?php
new DOMImplementation();'
],
'parentStaticCall' => [
'<?php
class A {