From 5a66742e707fa220aea8dfeae7670d226c57879f Mon Sep 17 00:00:00 2001 From: Ivan Sidorov Date: Wed, 14 Feb 2024 16:51:31 +0000 Subject: [PATCH] Failed and regression tests with suppression "UndefinedMethod" Apply suggestions from code review. Failed tests: ``` 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 ``` Co-authored-by: Bruce Weirdan --- tests/MagicMethodAnnotationTest.php | 63 ++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/tests/MagicMethodAnnotationTest.php b/tests/MagicMethodAnnotationTest.php index 109dc08fd..cd091a263 100644 --- a/tests/MagicMethodAnnotationTest.php +++ b/tests/MagicMethodAnnotationTest.php @@ -960,9 +960,44 @@ class MagicMethodAnnotationTest extends TestCase class B extends A {} function consumeInt(int $i): void {} - /** @psalm-suppress UndefinedMethod */ + /** @psalm-suppress UndefinedMethod, MixedArgument */ consumeInt(B::bar());', ], + 'magicStaticMethodInheritanceWithoutCallStatic_WithReturnAndManyArgs' => [ + // This is compatible with "magicMethodInheritanceWithoutCall_WithReturnAndManyArgs" + 'code' => <<<'PHP' + [ + '$a===' => 'mixed', + ], + ], + 'magicMethodInheritanceWithoutCall_WithReturnAndManyArgs' => [ + 'code' => <<<'PHP' + bar(123, "whatever"); + PHP, + 'assertions' => [ + '$a===' => 'mixed', + ], + ], 'callUsingParent' => [ 'code' => ' 'NonStaticSelfCall', ], + 'suppressUndefinedMethodWithObjectCall_WithNotExistsFunc' => [ + 'code' => <<<'PHP' + bar(function_does_not_exist(123)); + PHP, + 'error_message' => 'UndefinedFunction', + ], + 'suppressUndefinedMethodWithStaticCall_WithNotExistsFunc' => [ + 'code' => <<<'PHP' + 'UndefinedFunction', + ], ]; }