phpstan: [0.12.0] False negative "Unreachable statement - code above always terminates."
Bug report
In some cases phpstan 0.12.0 raise unnecessarily “Unreachable statement - code above always terminates.”
Code snippet that reproduces the problem
https://phpstan.org/r/9ecd0c68-4d6f-4ea6-925c-11f47ac9dd4e
<?php declare(strict_types = 1);
function test(PDO $object, ReflectionParameter $parameter): void
{
$class = $parameter->getClass();
if (!$class) return;
$parameterClassName = $class->getName();
if ($object instanceof $parameterClassName) return;
echo "bar";
}
Expected output
echo "bar"; is reachable, there should be no warning.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (9 by maintainers)
Update - works if i cast
$parameterClassNametostringhttps://phpstan.org/r/0e8dc937-a55d-4ebb-8960-9f020510a5c9