diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 47ac0acf51..b8fb0297a6 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -236,7 +236,7 @@ parameters: - message: "#^Dead catch \\- PHPStan\\\\BetterReflection\\\\Identifier\\\\Exception\\\\InvalidIdentifierName is never thrown in the try block\\.$#" - count: 3 + count: 4 path: src/Reflection/BetterReflection/BetterReflectionProvider.php - diff --git a/src/Reflection/BetterReflection/BetterReflectionProvider.php b/src/Reflection/BetterReflection/BetterReflectionProvider.php index 6ae28ec9c6..427cf10af6 100644 --- a/src/Reflection/BetterReflection/BetterReflectionProvider.php +++ b/src/Reflection/BetterReflection/BetterReflectionProvider.php @@ -434,6 +434,8 @@ public function resolveConstantName(Node\Name $nameNode, ?NamespaceAnswerer $nam return true; } catch (IdentifierNotFound) { // pass + } catch (InvalidIdentifierName) { + // pass } catch (UnableToCompileNode) { // pass } diff --git a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php index 1e5491bbc3..61ff4a3c1d 100644 --- a/tests/PHPStan/Analyser/AnalyserIntegrationTest.php +++ b/tests/PHPStan/Analyser/AnalyserIntegrationTest.php @@ -1493,6 +1493,12 @@ public function testBug12979(): void $this->assertNoErrors($errors); } + public function testBug12095(): void + { + $errors = $this->runAnalyse(__DIR__ . '/data/bug-12095.php'); + $this->assertNoErrors($errors); + } + /** * @param string[]|null $allAnalysedFiles * @return Error[] diff --git a/tests/PHPStan/Analyser/data/bug-12095.php b/tests/PHPStan/Analyser/data/bug-12095.php new file mode 100644 index 0000000000..54c41421fd --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-12095.php @@ -0,0 +1,15 @@ +