/**
  * @param string  $path
  * @param RuleSet $ruleSet
  *
  * @return RuleSet
  */
 public function traverse($path, RuleSet $ruleSet = null)
 {
     $files = $this->finder->in($path);
     if (!$ruleSet instanceof RuleSet) {
         $ruleSet = new RuleSet();
     }
     foreach ($files as $i => $file) {
         /** @var PhpFileInfo $file */
         if ($file->hasDeprecations()) {
             $ruleSet->merge($file);
         }
     }
     return $ruleSet;
 }
 /**
  * @param string $sourceArg
  * @param string $ruleSetArg
  *
  * @return Violation[]
  *
  * @throws \Exception
  */
 public function checkForDeprecations($sourceArg, $ruleSetArg)
 {
     $this->output->startProgress();
     $this->output->startRuleSetGeneration();
     $ruleSet = $this->ruleSetLoader->loadRuleSet($ruleSetArg);
     $this->output->endRuleSetGeneration();
     $this->output->startUsageDetection();
     // TODO: Move to AncestorResolver not hard coded
     $lib = is_dir($ruleSetArg) ? $ruleSetArg : realpath('vendor');
     $this->ancestorResolver->setSourcePaths(array($sourceArg, $lib));
     /** @var ParsedPhpFileFinder $files */
     $files = $this->deprecationFinder->in($sourceArg);
     $violations = $this->violationDetector->getViolations($ruleSet, $files);
     $this->output->endUsageDetection();
     $this->output->startOutputRendering();
     $this->renderer->renderViolations($violations, $files->getParserErrors());
     $this->output->endOutputRendering();
     $this->output->endProgress($files->count(), count($violations));
     return $violations;
 }