Ejemplo n.º 1
0
 private function formatErrorMessage(Error $e, $code)
 {
     if ($e->hasColumnInfo()) {
         return $e->getMessageWithColumnInfo($code);
     } else {
         return $e->getMessage();
     }
 }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo n.º 3
0
 /**
  * @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()));
 }
Ejemplo n.º 4
0
 /**
  * @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;
 }
Ejemplo n.º 5
0
 /**
  * @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());
 }
Ejemplo n.º 6
0
 /**
  * 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));
     }
 }
Ejemplo n.º 8
0
 /**
  * @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;
 }