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

Fix #1035 - ignore issues where method is in a custom library

This commit is contained in:
Matthew Brown 2018-10-27 11:47:27 -04:00
parent 1d77b61ff9
commit aff6844c62
3 changed files with 19 additions and 19 deletions

View File

@ -688,21 +688,23 @@ class MethodCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
if (count($lhs_types) === 1) {
$method_storage = $codebase->methods->getUserMethodStorage($method_id);
if ($method_storage->assertions) {
self::applyAssertionsToContext(
$method_storage->assertions,
$args,
$context,
$statements_checker
);
}
if ($method_storage) {
if ($method_storage->assertions) {
self::applyAssertionsToContext(
$method_storage->assertions,
$args,
$context,
$statements_checker
);
}
if ($method_storage->if_true_assertions) {
$stmt->ifTrueAssertions = $method_storage->if_true_assertions;
}
if ($method_storage->if_true_assertions) {
$stmt->ifTrueAssertions = $method_storage->if_true_assertions;
}
if ($method_storage->if_false_assertions) {
$stmt->ifFalseAssertions = $method_storage->if_false_assertions;
if ($method_storage->if_false_assertions) {
$stmt->ifFalseAssertions = $method_storage->if_false_assertions;
}
}
}
}

View File

@ -505,9 +505,9 @@ class StaticCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
}
}
try {
$method_storage = $codebase->methods->getUserMethodStorage($method_id);
$method_storage = $codebase->methods->getUserMethodStorage($method_id);
if ($method_storage) {
if ($method_storage->assertions) {
self::applyAssertionsToContext(
$method_storage->assertions,
@ -524,8 +524,6 @@ class StaticCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
if ($method_storage->if_false_assertions) {
$stmt->ifFalseAssertions = $method_storage->if_false_assertions;
}
} catch (\UnexpectedValueException $e) {
// do nothing for non-user-defined methods
}
if ($config->after_method_checks) {

View File

@ -535,7 +535,7 @@ class Methods
/**
* @param string $method_id
*
* @return MethodStorage
* @return ?MethodStorage
*/
public function getUserMethodStorage($method_id)
{
@ -548,7 +548,7 @@ class Methods
$storage = $this->getStorage($declaring_method_id);
if (!$storage->location) {
throw new \UnexpectedValueException('Storage for ' . $method_id . ' is not user-defined');
return null;
}
return $storage;