Skip to content

Commit 5830684

Browse files
committed
Look for fatal errors before syntax errors (#105)
* Look for fatal errors before syntax errors * Accidentally committed a file with an undo * Space after comments
1 parent d5f69a5 commit 5830684

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/Process/LintProcess.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ public function hasSyntaxError()
4747
public function getSyntaxError()
4848
{
4949
if ($this->hasSyntaxError()) {
50+
// Look for fatal errors first
5051
foreach (explode("\n", $this->getOutput()) as $line) {
51-
if ($this->containsParserOrFatalError($line)) {
52+
if ($this->containsFatalError($line)) {
53+
return $line;
54+
}
55+
}
56+
57+
// Look for parser errors second
58+
foreach (explode("\n", $this->getOutput()) as $line) {
59+
if ($this->containsParserError($line)) {
5260
return $line;
5361
}
5462
}
@@ -81,7 +89,24 @@ public function isSuccess()
8189
*/
8290
private function containsParserOrFatalError($string)
8391
{
84-
return strpos($string, self::FATAL_ERROR) !== false ||
85-
strpos($string, self::PARSE_ERROR) !== false;
92+
return $this->containsParserError($string) || $this->containsFatalError($string);
93+
}
94+
95+
/**
96+
* @param $string
97+
* @return bool
98+
*/
99+
private function containsParserError($string)
100+
{
101+
return strpos($string, self::PARSE_ERROR) !== false;
102+
}
103+
104+
/**
105+
* @param $string
106+
* @return bool
107+
*/
108+
private function containsFatalError($string)
109+
{
110+
return strpos($string, self::FATAL_ERROR) !== false;
86111
}
87-
}
112+
}

0 commit comments

Comments
 (0)