mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 09:37:59 +01:00
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 <weirdan@gmail.com>
This commit is contained in:
parent
37240624f6
commit
5a66742e70
@ -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'
|
||||
<?php
|
||||
/**
|
||||
* @method static void bar()
|
||||
*/
|
||||
class A {}
|
||||
class B extends A {}
|
||||
|
||||
/** @psalm-suppress UndefinedMethod, MixedAssignment */
|
||||
$a = B::bar(123, "whatever");
|
||||
PHP,
|
||||
'assertions' => [
|
||||
'$a===' => 'mixed',
|
||||
],
|
||||
],
|
||||
'magicMethodInheritanceWithoutCall_WithReturnAndManyArgs' => [
|
||||
'code' => <<<'PHP'
|
||||
<?php
|
||||
/**
|
||||
* @method void bar()
|
||||
*/
|
||||
class A {}
|
||||
class B extends A {}
|
||||
|
||||
$obj = new B();
|
||||
|
||||
/** @psalm-suppress UndefinedMethod, MixedAssignment */
|
||||
$a = $obj->bar(123, "whatever");
|
||||
PHP,
|
||||
'assertions' => [
|
||||
'$a===' => 'mixed',
|
||||
],
|
||||
],
|
||||
'callUsingParent' => [
|
||||
'code' => '<?php
|
||||
/**
|
||||
@ -1367,6 +1402,32 @@ class MagicMethodAnnotationTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'NonStaticSelfCall',
|
||||
],
|
||||
'suppressUndefinedMethodWithObjectCall_WithNotExistsFunc' => [
|
||||
'code' => <<<'PHP'
|
||||
<?php
|
||||
/** @method int bar() */
|
||||
class A {}
|
||||
class B extends A {}
|
||||
|
||||
$obj = new B();
|
||||
|
||||
/** @psalm-suppress UndefinedMethod */
|
||||
$a = $obj->bar(function_does_not_exist(123));
|
||||
PHP,
|
||||
'error_message' => 'UndefinedFunction',
|
||||
],
|
||||
'suppressUndefinedMethodWithStaticCall_WithNotExistsFunc' => [
|
||||
'code' => <<<'PHP'
|
||||
<?php
|
||||
/** @method static int bar() */
|
||||
class A {}
|
||||
class B extends A {}
|
||||
|
||||
/** @psalm-suppress UndefinedMethod */
|
||||
$a = B::bar(function_does_not_exist(123));
|
||||
PHP,
|
||||
'error_message' => 'UndefinedFunction',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user