/**
  * @param string $path
  * @param array $options
  * @param AbstractLogger $logger
  * @return Result
  */
 public function run($path, array $options, AbstractLogger $logger)
 {
     $result = new Result();
     foreach (FilesystemHelper::findFiles($path, $options['files']) as $filename) {
         $result->merge($this->processFile($filename, $options));
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * @param string $path
  * @param array $options
  * @param AbstractLogger $logger
  *
  * @return Result
  */
 public function run($path, array $options, AbstractLogger $logger)
 {
     $result = new Result();
     $files = FilesystemHelper::findFiles($path, $options['files']);
     foreach ($files as $file) {
         foreach ((new \PHP_Token_Stream($file))->getClasses() as $className => $class) {
             foreach ($class['methods'] as $methodName => $method) {
                 if ($methodName === 'anonymous function') {
                     continue;
                 }
                 $result->merge($this->processMethod($options, $method, $className, $file));
             }
         }
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * @param string $path
  * @param array $options
  * @param AbstractLogger $logger
  * @return Result
  */
 public function run($path, array $options, AbstractLogger $logger)
 {
     $result = new Result();
     $files = FilesystemHelper::findFiles($path, $options['files'], '*.twig');
     foreach ($files as $file) {
         try {
             $this->twig->parse($this->twig->tokenize(file_get_contents($file), $file));
         } catch (\Twig_Error $e) {
             $message = get_class($e) . ': ' . $e->getRawMessage();
             $issue = new Issue($this, $message);
             $issue->setLevel($options['error_level']);
             $issue->setFile($file);
             $issue->setLine($e->getTemplateLine());
             $result->addIssue($issue);
         }
     }
     return $result;
 }
 /**
  * @param string         $path
  * @param array          $options
  * @param AbstractLogger $logger
  *
  * @return Result
  */
 public function run($path, array $options, AbstractLogger $logger)
 {
     $result = new Result();
     $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP5);
     $visitor = new Visitor($this, $options['blacklist'], $result);
     $traverser = new NodeTraverser();
     $traverser->addVisitor($visitor);
     $files = FilesystemHelper::findFiles($path, $options['files']);
     foreach ($files as $file) {
         try {
             $visitor->setCurrentFile($file);
             $statements = $parser->parse(file_get_contents($file));
             $traverser->traverse($statements);
         } catch (\Exception $e) {
             $visitor->addException($e);
         }
     }
     return $result;
 }