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