mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +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) {
|
if (count($lhs_types) === 1) {
|
||||||
$method_storage = $codebase->methods->getUserMethodStorage($method_id);
|
$method_storage = $codebase->methods->getUserMethodStorage($method_id);
|
||||||
|
|
||||||
if ($method_storage->assertions) {
|
if ($method_storage) {
|
||||||
self::applyAssertionsToContext(
|
if ($method_storage->assertions) {
|
||||||
$method_storage->assertions,
|
self::applyAssertionsToContext(
|
||||||
$args,
|
$method_storage->assertions,
|
||||||
$context,
|
$args,
|
||||||
$statements_checker
|
$context,
|
||||||
);
|
$statements_checker
|
||||||
}
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($method_storage->if_true_assertions) {
|
if ($method_storage->if_true_assertions) {
|
||||||
$stmt->ifTrueAssertions = $method_storage->if_true_assertions;
|
$stmt->ifTrueAssertions = $method_storage->if_true_assertions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($method_storage->if_false_assertions) {
|
if ($method_storage->if_false_assertions) {
|
||||||
$stmt->ifFalseAssertions = $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) {
|
if ($method_storage->assertions) {
|
||||||
self::applyAssertionsToContext(
|
self::applyAssertionsToContext(
|
||||||
$method_storage->assertions,
|
$method_storage->assertions,
|
||||||
@ -524,8 +524,6 @@ class StaticCallChecker extends \Psalm\Checker\Statements\Expression\CallChecker
|
|||||||
if ($method_storage->if_false_assertions) {
|
if ($method_storage->if_false_assertions) {
|
||||||
$stmt->ifFalseAssertions = $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) {
|
if ($config->after_method_checks) {
|
||||||
|
@ -535,7 +535,7 @@ class Methods
|
|||||||
/**
|
/**
|
||||||
* @param string $method_id
|
* @param string $method_id
|
||||||
*
|
*
|
||||||
* @return MethodStorage
|
* @return ?MethodStorage
|
||||||
*/
|
*/
|
||||||
public function getUserMethodStorage($method_id)
|
public function getUserMethodStorage($method_id)
|
||||||
{
|
{
|
||||||
@ -548,7 +548,7 @@ class Methods
|
|||||||
$storage = $this->getStorage($declaring_method_id);
|
$storage = $this->getStorage($declaring_method_id);
|
||||||
|
|
||||||
if (!$storage->location) {
|
if (!$storage->location) {
|
||||||
throw new \UnexpectedValueException('Storage for ' . $method_id . ' is not user-defined');
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $storage;
|
return $storage;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user