SensioLabs\DeprecationDetector\Violation\ViolationDetector::getViolations PHP Method

getViolations() public method

public getViolations ( SensioLabs\DeprecationDetector\RuleSet\RuleSet $ruleSet, array $files ) : SensioLabs\DeprecationDetector\Violation\Violation[]
$ruleSet SensioLabs\DeprecationDetector\RuleSet\RuleSet
$files array
return SensioLabs\DeprecationDetector\Violation\Violation[]
    public function getViolations(RuleSet $ruleSet, array $files)
    {
        $result = array();
        foreach ($files as $i => $file) {
            $unfilteredResult = $this->violationChecker->check($file, $ruleSet);
            foreach ($unfilteredResult as $unfilteredViolation) {
                if (false === $this->violationFilter->isViolationFiltered($unfilteredViolation)) {
                    $result[] = $unfilteredViolation;
                }
            }
        }
        return $result;
    }

Usage Example

 /**
  * @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);
     $ruleSet->merge($this->preDefinedRuleSet);
     $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));
     $result = $this->deprecationFinder->parsePhpFiles($sourceArg);
     $violations = $this->violationDetector->getViolations($ruleSet, $result->parsedFiles());
     $this->output->endUsageDetection();
     $this->output->startOutputRendering();
     $this->renderer->renderViolations($violations, $result->parserErrors());
     $this->output->endOutputRendering();
     $this->output->endProgress($result->fileCount(), count($violations));
     return $violations;
 }
All Usage Examples Of SensioLabs\DeprecationDetector\Violation\ViolationDetector::getViolations