diff --git a/src/Linter.php b/src/Linter.php index 86bda986..0c9e759c 100644 --- a/src/Linter.php +++ b/src/Linter.php @@ -131,9 +131,9 @@ public function lint($files = [], $cache = true) if ($lint->hasSyntaxError()) { $processCallback('error', $item['file']); $errors[$filename] = array_merge(['file' => $filename, 'file_name' => $item['relativePath']], $lint->getSyntaxError()); - } elseif ($this->warning && $lint->hasSyntaxWarning()) { + } elseif ($this->warning && $lint->hasSyntaxIssue()) { $processCallback('warning', $item['file']); - $errors[$filename] = array_merge(['file' => $filename, 'file_name' => $item['relativePath']], $lint->getSyntaxWarning()); + $errors[$filename] = array_merge(['file' => $filename, 'file_name' => $item['relativePath']], $lint->getSyntaxIssue()); } else { $newCache[$item['relativePath']] = md5_file($filename); $processCallback('ok', $item['file']); diff --git a/src/Process/Lint.php b/src/Process/Lint.php index 9792c55d..b01340d3 100644 --- a/src/Process/Lint.php +++ b/src/Process/Lint.php @@ -72,7 +72,7 @@ public function parseError($message) /** * @return bool */ - public function hasSyntaxWarning() + public function hasSyntaxIssue() { $output = trim($this->getOutput()); @@ -81,18 +81,18 @@ public function hasSyntaxWarning() } - return false !== strpos($output, 'Warning: '); + return (bool)preg_match('/(Warning:|Deprecated:|Notice:)/', $output); } /** * @return bool|array */ - public function getSyntaxWarning() + public function getSyntaxIssue() { - if ($this->hasSyntaxWarning()) { + if ($this->hasSyntaxIssue()) { $out = explode("\n", trim($this->getOutput())); - return $this->parseWarning(array_shift($out)); + return $this->parseIssue(array_shift($out)); } return false; @@ -105,9 +105,9 @@ public function getSyntaxWarning() * * @return array */ - public function parseWarning($message) + private function parseIssue($message) { - $pattern = '/^(PHP\s+)?Warning:\s*\s*?(?.+?)\s+in\s+.+?\s*line\s+(?\d+)/'; + $pattern = '/^(PHP\s+)?(Warning|Deprecated|Notice):\s*?(?.+?)\s+in\s+.+?\s*line\s+(?\d+)/'; $matched = preg_match($pattern, $message, $match);