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

Downgrade UndefinedMethod to PossiblyUndefinedMethod issue when one type has __call defined

This commit is contained in:
Matthew Brown 2018-03-04 13:23:40 -05:00
parent 5f03d08cb2
commit 806b032b13
2 changed files with 16 additions and 0 deletions

View File

@ -267,6 +267,8 @@ class MethodCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
$statements_checker->getSource()
)
) {
$has_valid_method_call_type = true;
$existent_method_ids[] = $method_id;
$return_type = Type::getMixed();
continue;
}

View File

@ -91,6 +91,20 @@ class MethodCallTest extends TestCase
$a = new A;
$a->bar();',
],
'canBeCalledOnMagic' => [
'<?php
class A {
public function __call(string $method) {}
}
class B {}
$a = rand(0, 1) ? new A : new B;
$a->maybeUndefinedMethod();',
'assertions' => [],
'error_levels' => ['PossiblyUndefinedMethod'],
],
];
}