showDeprecatedErrors = $deprecated; parent::__construct($phpExecutable, $parameters); } /** * @return bool * @throws */ public function containsError() { return $this->containsParserError($this->getOutput()) || $this->containsFatalError($this->getOutput()) || $this->containsDeprecatedError($this->getOutput()); } /** * @return string * @throws RunTimeException */ public function getSyntaxError() { if ($this->containsError()) { // Look for fatal errors first foreach (explode("\n", $this->getOutput()) as $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; } } // Look for deprecated errors third foreach (explode("\n", $this->getOutput()) as $line) { if ($this->containsDeprecatedError($line)) { return $line; } } throw new RunTimeException("The output '{$this->getOutput()}' does not contain Parse or Syntax errors"); } return false; } /** * @return bool * @throws RunTimeException */ public function isFail() { return defined('PHP_WINDOWS_VERSION_MAJOR') ? $this->getStatusCode() === 1 : parent::isFail(); } /** * @return bool * @throws RunTimeException */ public function isSuccess() { return $this->getStatusCode() === 0; } /** * @param string $string * @return bool */ private function containsParserError($string) { return strpos($string, self::PARSE_ERROR) !== false; } /** * @param string $string * @return bool */ private function containsFatalError($string) { return strpos($string, self::FATAL_ERROR) !== false; } /** * @param string $string * @return bool */ private function containsDeprecatedError($string) { if ($this->showDeprecatedErrors === false) { return false; } return strpos($string, self::DEPRECATED_ERROR) !== false; } }