From 8a70bc250685b747e8b2a15ae2206e8221a68bee Mon Sep 17 00:00:00 2001 From: Ivan Sidorov Date: Wed, 14 Feb 2024 20:40:35 +0000 Subject: [PATCH] Resolve tests with suppression "UndefinedMethod" Apply suggestions from code review. Resolved problems: ``` 1) MagicMethodAnnotationTest::testValidCode with data set "magicStaticMethodInheritanceWithoutCallStatic" Psalm\Exception\CodeException: UnusedPsalmSuppress - src/somefile.php:9:58 - This suppression is never used 2) MagicMethodAnnotationTest::testValidCode with data set "magicStaticMethodInheritanceWithoutCallStatic_WithReturnAndManyArgs" Psalm\Exception\CodeException: TooManyArguments - src/somefile.php:9:6 - Too many arguments for B::bar - expecting 0 but saw 2 ``` --- .../Call/StaticMethod/AtomicStaticCallAnalyzer.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php index 1b53bc578..5056d25b1 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Call/StaticMethod/AtomicStaticCallAnalyzer.php @@ -710,7 +710,7 @@ final class AtomicStaticCallAnalyzer return false; } } - } elseif ($found_method_and_class_storage) { + } elseif ($found_method_and_class_storage && ($naive_method_exists || $with_pseudo)) { [$pseudo_method_storage, $defining_class_storage] = $found_method_and_class_storage; if (self::checkPseudoMethod( @@ -727,9 +727,7 @@ final class AtomicStaticCallAnalyzer return false; } - if ($pseudo_method_storage->return_type - && ($naive_method_exists || $with_pseudo) - ) { + if ($pseudo_method_storage->return_type) { return true; } } elseif ($stmt->class instanceof PhpParser\Node\Name && $stmt->class->getFirst() === 'parent'