Skip to content

Commit 467b31d

Browse files
committed
Ignore warning in LintProcess
1 parent 1618405 commit 467b31d

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

src/Process/LintProcess.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<?php
22
namespace JakubOnderka\PhpParallelLint\Process;
33

4+
use JakubOnderka\PhpParallelLint\RunTimeException;
5+
46
class LintProcess extends PhpProcess
57
{
8+
const FATAL_ERROR = 'Fatal error';
9+
const PARSE_ERROR = 'Parse error';
10+
611
/**
712
* @param PhpExecutable $phpExecutable
813
* @param string $fileToCheck Path to file to check
@@ -32,18 +37,23 @@ public function __construct(PhpExecutable $phpExecutable, $fileToCheck, $aspTags
3237
*/
3338
public function hasSyntaxError()
3439
{
35-
return strpos($this->getOutput(), 'Fatal error') !== false ||
36-
strpos($this->getOutput(), 'Parse error') !== false;
40+
return $this->containsParserOrFatalError($this->getOutput());
3741
}
3842

3943
/**
40-
* @return bool|string
44+
* @return string
45+
* @throws RunTimeException
4146
*/
4247
public function getSyntaxError()
4348
{
4449
if ($this->hasSyntaxError()) {
45-
list(, $out) = explode("\n", $this->getOutput());
46-
return $out;
50+
foreach (explode("\n", $this->getOutput()) as $line) {
51+
if ($this->containsParserOrFatalError($line)) {
52+
return $line;
53+
}
54+
}
55+
56+
throw new RunTimeException("The output '{$this->getOutput()}' does not contains Parse or Syntax error");
4757
}
4858

4959
return false;
@@ -64,4 +74,14 @@ public function isSuccess()
6474
{
6575
return $this->getStatusCode() === 0;
6676
}
77+
78+
/**
79+
* @param $string
80+
* @return bool
81+
*/
82+
private function containsParserOrFatalError($string)
83+
{
84+
return strpos($string, self::FATAL_ERROR) !== false ||
85+
strpos($string, self::PARSE_ERROR) !== false;
86+
}
6787
}

0 commit comments

Comments
 (0)