From 8f373606639d22a704f0f067f43c5c5eb9fe62ec Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Sat, 4 Jun 2022 09:37:35 +0200 Subject: [PATCH] reproduce bug 1396 --- .../Analyser/NodeScopeResolverTest.php | 1 + tests/PHPStan/Analyser/data/bug-1396.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/PHPStan/Analyser/data/bug-1396.php 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()); + } +}