diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f9333d935..3b055a5ea 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -345,11 +345,6 @@ parameters: count: 1 path: src/Twig/SourceCodeExtension.php - - - message: "#^Parameter \\#1 \\$array of function array_slice expects array, array\\\\|false given\\.$#" - count: 1 - path: src/Twig/SourceCodeExtension.php - - message: "#^Parameter \\#1 \\$filename of function file expects string, string\\|false given\\.$#" count: 1 diff --git a/src/Twig/SourceCodeExtension.php b/src/Twig/SourceCodeExtension.php index ff2145a5d..e3a4b2028 100644 --- a/src/Twig/SourceCodeExtension.php +++ b/src/Twig/SourceCodeExtension.php @@ -65,7 +65,9 @@ private function getController(): ?array $method = $this->getCallableReflector($this->controller); - $classCode = file($method->getFileName()); + if (false === $classCode = file($method->getFileName())) { + throw new \LogicException(sprintf('There was an error while trying to read the contents of the "%s" file.', $method->getFileName())); + } $startLine = $method->getStartLine() - 1; $endLine = $method->getEndLine();