예제 #1
0
 /**
  * @inheritDoc
  */
 public function printContext(ContextInterface $context)
 {
     $this->output->writeln('');
     $this->output->writeln(sprintf('File: %s', $context->getCheckedResourceName()));
     foreach ($context->getMessages() as $message) {
         $nodes = $this->nodeStatementsRemover->removeInnerStatements($message->getNodes());
         $this->output->writeln(sprintf('Line %d. %s: %s', $message->getLine(), $message->getText(), $this->prettyPrinter->prettyPrint($nodes)));
     }
     $this->output->writeln('');
 }
예제 #2
0
 /**
  * @param ContextInterface $context
  *
  * @return FileContext
  */
 public function checkContext(ContextInterface $context)
 {
     try {
         $parsedStatements = $this->parser->parse($context->getCheckedCode());
         $this->traverser->traverse($parsedStatements, $context, $this->lexer->getTokens());
     } catch (\Exception $e) {
         $context->addError(new CheckError($e->getMessage()));
     } catch (\ParseException $e) {
         $context->addError(new CheckError($e->getMessage(), $e->getLine()));
     }
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function printContext(ContextInterface $context)
 {
     $this->output->writeln('');
     $this->output->writeln(sprintf('File: <fg=cyan>%s</fg=cyan>', $context->getCheckedResourceName()));
     foreach ($context->getMessages() as $message) {
         $this->output->writeln($this->formatMessage($message));
     }
     foreach ($context->getErrors() as $error) {
         $this->output->writeln(sprintf('> <fg=red>%s</fg=red>', $error->getText()));
     }
     $this->output->writeln('');
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function printContext(ContextInterface $context)
 {
     $this->output->writeln('');
     $this->output->writeln(sprintf('File: <fg=cyan>%s</fg=cyan>', $context->getCheckedResourceName()));
     foreach ($context->getMessages() as $message) {
         $nodes = $this->nodeStatementsRemover->removeInnerStatements($message->getNodes());
         $this->output->writeln(sprintf("> Line <fg=cyan>%s</fg=cyan>: <fg=yellow>%s</fg=yellow>\n    %s", $message->getLine(), $message->getRawText(), str_replace("\n", "\n    ", $this->prettyPrinter->prettyPrint($nodes))));
     }
     foreach ($context->getErrors() as $error) {
         $this->output->writeln(sprintf('> <fg=red>%s</fg=red>', $error->getText()));
     }
     $this->output->writeln('');
 }
예제 #5
0
 /**
  * @param ContextInterface $context
  * @return FileContext
  */
 public function checkContext(ContextInterface $context)
 {
     $parsedStatements = $this->parser->parse($context->getCheckedCode());
     $this->traverser->traverse($parsedStatements, $context, $this->lexer->getTokens());
 }
예제 #6
0
 /**
  * @param string $text
  * @param Node   $node
  */
 protected function addContextMessage($text, Node $node)
 {
     $this->context->addMessage(new Message($text, $node->getAttribute('startLine'), array($node)));
 }