diff --git a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php index 9eaa82d4cb..e0dd1ad3fa 100644 --- a/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php +++ b/tests/PHPStan/Rules/Methods/CallMethodsRuleTest.php @@ -2384,4 +2384,22 @@ public function testBug6118(): void $this->analyse([__DIR__ . '/data/bug-6118.php'], []); } + public function testBug6464(): void + { + $this->checkThisOnly = false; + $this->checkNullables = true; + $this->checkUnionTypes = true; + $this->checkExplicitMixed = true; + $this->analyse([__DIR__ . '/data/bug-6464.php'], []); + } + + public function testBug6423(): void + { + $this->checkThisOnly = false; + $this->checkNullables = true; + $this->checkUnionTypes = true; + $this->checkExplicitMixed = true; + $this->analyse([__DIR__ . '/data/bug-6423.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php b/tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php index a637934679..dd17e454e9 100644 --- a/tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php +++ b/tests/PHPStan/Rules/Methods/ReturnTypeRuleTest.php @@ -603,4 +603,22 @@ public function testBug6589(): void ]); } + public function testBug6418(): void + { + $this->checkExplicitMixed = true; + $this->analyse([__DIR__ . '/data/bug-6418.php'], []); + } + + public function testBug6230(): void + { + $this->checkExplicitMixed = true; + $this->analyse([__DIR__ . '/data/bug-6230.php'], []); + } + + public function testBug5860(): void + { + $this->checkExplicitMixed = true; + $this->analyse([__DIR__ . '/data/bug-5860.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Methods/data/bug-5860.php b/tests/PHPStan/Rules/Methods/data/bug-5860.php new file mode 100644 index 0000000000..f41cab6c93 --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/bug-5860.php @@ -0,0 +1,20 @@ + $it + * @return ?iterable + */ + function test($it): ?iterable + { + return $it; + } + +} + +/** + * @template T + */ +class Example +{ + /** + * @var ?iterable + */ + private $input; + + + /** + * @param iterable $input + */ + public function __construct(iterable $input) + { + $this->input = $input; + } + + /** @return ?iterable */ + public function get(): ?iterable + { + return $this->input; + } +} diff --git a/tests/PHPStan/Rules/Methods/data/bug-6418.php b/tests/PHPStan/Rules/Methods/data/bug-6418.php new file mode 100644 index 0000000000..d1fb02a4fe --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/bug-6418.php @@ -0,0 +1,19 @@ + $foos + */ + function doFoo(?array $foos = null): void {} + + /** + * @return list + */ + function doBar(): array + { + return [ + 'hello', + 'world', + ]; + } + + function doBaz() + { + $this->doFoo([ + 'foo', + 'bar', + ...$this->doBar(), + ]); + } + +} diff --git a/tests/PHPStan/Rules/Methods/data/bug-6464.php b/tests/PHPStan/Rules/Methods/data/bug-6464.php new file mode 100644 index 0000000000..0cc01b2790 --- /dev/null +++ b/tests/PHPStan/Rules/Methods/data/bug-6464.php @@ -0,0 +1,20 @@ + $g */ + public function foo(\Generator $g): void; +} + +class Bar +{ + + function test(Foo $foo): void { + $foo->foo((function(string $str) { + yield $str; + })('hello')); + } + +}