diff --git a/tests/PHPStan/Analyser/NodeScopeResolverTest.php b/tests/PHPStan/Analyser/NodeScopeResolverTest.php index 121efe3e7fd..0045de406de 100644 --- a/tests/PHPStan/Analyser/NodeScopeResolverTest.php +++ b/tests/PHPStan/Analyser/NodeScopeResolverTest.php @@ -1335,6 +1335,7 @@ public function dataFileAsserts(): iterable yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-9293.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/nullsafe-vs-scalar.php'); yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-8517.php'); + yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-1396.php'); } /** diff --git a/tests/PHPStan/Analyser/data/bug-1396.php b/tests/PHPStan/Analyser/data/bug-1396.php new file mode 100644 index 00000000000..2088211716b --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-1396.php @@ -0,0 +1,30 @@ +getValue()); + + if ($constantType->getValue() === null) { + return new SpecifiedTypes(); + } + + assertType('bool|float|int|string', $constantType->getValue()); + + if ( + $constantType instanceof ConstantStringType + ) { + assertType('string', $constantType->getValue()); + } + assertType('bool|float|int|string', $constantType->getValue()); + } +}