private function formatErrorMessage(Error $e, $code) { if ($e->hasColumnInfo()) { return $e->getMessageWithColumnInfo($code); } else { return $e->getMessage(); } }
public function enterNode(Node $node) { parent::enterNode($node); try { if ($doc = $node->getDocComment()) { $docBlock = new DocBlock($doc->getText()); if ($tagNames = $this->collectTagNamesBy($docBlock->getTags())) { $node->setAttribute(self::TAG_NAMES_ATTRIBUTE, $tagNames); } } } catch (\Exception $e) { $parseError = new Error($e->getMessage(), $node->getLine()); $this->logger->warning($parseError->getMessage(), array($this->file)); } }
/** * @param CheckInterface $check * @param ParseErrorException $e * @param string $file * @return static */ public static function fromCheckAndCodeParseFailure(CheckInterface $check, ParseErrorException $e, $file) { return new static($check->getName(), sprintf('File: "%s" could not be parsed. Error: "%s"', $file, $e->getMessage())); }
/** * @param \PhpParser\Error $exception * @param string $filepath * @return bool */ public function sytaxError(\PhpParser\Error $exception, $filepath) { $code = file($filepath); $this->output->writeln('<error>Syntax error: ' . $exception->getMessage() . " in {$filepath} </error>"); $this->output->writeln(''); $code = trim($code[$exception->getStartLine() - 2]); $this->output->writeln("<comment>\t {$code} </comment>"); return true; }
/** * @param \SplFileInfo $file * @param Error $error */ public function __construct(\SplFileInfo $file, Error $error) { $this->file = $file; $this->error = $error; $this->message = sprintf('%s in %s', $this->error->getMessage(), $this->file->getRealPath()); }
/** * Creates a syntax error message. * * @param \PhpParser\Error $exception * @param string $filepath * @return bool */ public function syntaxError(\PhpParser\Error $exception, $filepath) { $code = file($filepath); $this->output->writeln('<error>Syntax error: ' . $exception->getMessage() . " in {$filepath} </error>"); $this->output->writeln(''); $issueCollector = $this->application->getIssuesCollector(); $issueCollector->addIssue(new Issue('syntax-error', 'syntax-error', new IssueLocation($filepath, $exception->getStartLine() - 2))); $code = trim($code[$exception->getStartLine() - 2]); $this->output->writeln("<comment>\t {$code} </comment>"); return true; }
public function enterNode(Node $node) { parent::enterNode($node); try { if ($doc = $node->getDocComment()) { $docBlock = $this->docBlockFactory->create(str_replace('[]', '', $doc->getText()), new Context((string) $this->namespace, (array) $this->namespaceAliases)); if ($tagNames = $this->collectTagNamesBy($docBlock->getTags())) { $node->setAttribute(self::TAG_NAMES_ATTRIBUTE, $tagNames); } } } catch (\Exception $e) { $parseError = new Error($e->getMessage(), $node->getLine()); $this->logger->warning($parseError->getMessage(), array($this->file)); } }
/** * @param \PhpParser\Error $e * @param $filepath * @return bool */ public function sytaxError(\PhpParser\Error $e, $filepath) { $code = file($e->getFile()); $this->output->writeln('<error>Syntax error: ' . $e->getMessage() . " in {$filepath} </error>"); $this->output->writeln(''); return true; }