Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Look for fatal errors before syntax errors #105

Merged
merged 3 commits into from
Aug 13, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions src/Process/LintProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ public function hasSyntaxError()
public function getSyntaxError()
{
if ($this->hasSyntaxError()) {
//Look for fatal errors first
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just code style: Please add space after // and then I will merge it :)

foreach (explode("\n", $this->getOutput()) as $line) {
if ($this->containsParserOrFatalError($line)) {
if ($this->containsFatalError($line)) {
return $line;
}
}

//Look for parser errors second
foreach (explode("\n", $this->getOutput()) as $line) {
if ($this->containsParserError($line)) {
return $line;
}
}
Expand Down Expand Up @@ -81,7 +89,24 @@ public function isSuccess()
*/
private function containsParserOrFatalError($string)
{
return strpos($string, self::FATAL_ERROR) !== false ||
strpos($string, self::PARSE_ERROR) !== false;
return $this->containsParserError($string) || $this->containsFatalError($string);
}

/**
* @param $string
* @return bool
*/
private function containsParserError($string)
{
return strpos($string, self::PARSE_ERROR) !== false;
}

/**
* @param $string
* @return bool
*/
private function containsFatalError($string)
{
return strpos($string, self::FATAL_ERROR) !== false;
}
}
}