diff --git a/src/collector/backend/SourceFileException.php b/src/collector/backend/SourceFileException.php index 2baa4ab4..63220328 100644 --- a/src/collector/backend/SourceFileException.php +++ b/src/collector/backend/SourceFileException.php @@ -3,6 +3,6 @@ class SourceFileException extends \Exception { public const BadEncoding = 1; - public const InvalidDataBytes = 2; + public const RegexError = 3; } diff --git a/src/collector/project/SourceFile.php b/src/collector/project/SourceFile.php index c81f1a1c..418b7620 100644 --- a/src/collector/project/SourceFile.php +++ b/src/collector/project/SourceFile.php @@ -43,7 +43,7 @@ public function getSource(): string { $source = \file_get_contents($this->getPathname()); - if ($source == '') { + if ($source === '') { $this->src = ''; return ''; @@ -71,6 +71,13 @@ function (array $matches) { $source ); + if ($this->src === null) { + throw new SourceFileException( + sprintf('Error %d while executing regular expression callback', \preg_last_error()), + SourceFileException::RegexError + ); + } + return $this->src; }