diff --git a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php index 613a1cf371..1ef527efb9 100644 --- a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php +++ b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php @@ -835,6 +835,18 @@ public function testBug7248(): void $this->assertNoErrors($errors); } + public function testBug6653(): void + { + $errors = $this->runAnalyse(__DIR__ . '/data/bug-6653.php'); + $this->assertNoErrors($errors); + } + + public function testBug5592(): void + { + $errors = $this->runAnalyse(__DIR__ . '/data/bug-5592.php'); + $this->assertNoErrors($errors); + } + /** * @param string[]|null $allAnalysedFiles * @return Error[] diff --git a/tests/PHPStan/Analyser/data/bug-5592.php b/tests/PHPStan/Analyser/data/bug-5592.php new file mode 100644 index 0000000000..63268b9524 --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-5592.php @@ -0,0 +1,12 @@ + $map + * @return numeric-string + */ +function mapGet(\Ds\Map $map, \Ds\Hashable $key): string +{ + return $map->get($key, '0'); +} diff --git a/tests/PHPStan/Analyser/data/bug-6653.php b/tests/PHPStan/Analyser/data/bug-6653.php new file mode 100644 index 0000000000..02eb5d36fa --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-6653.php @@ -0,0 +1,38 @@ +|false + */ + public function sayHello() + { + $test = $this->getTest(); + return $this->filterEvent('sayHello', $test); + } + + /** + * @template TValue of mixed + * @param TValue $value + * @return TValue + */ + private function filterEvent(string $eventName, $value) + { + // do event + return $value; + } + + /** + * @return array|false + */ + private function getTest() + { + $failure = random_int(0, PHP_INT_MAX) % 2 ? true : false; + if ($failure === true) { + return false; + } + return ['foo' => 123]; + } +}