/** * @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; }
public function testDifferentStages() { $output = $this->prophesize('Symfony\\Component\\Console\\Output\\OutputInterface'); $output->writeln(Argument::any())->shouldBeCalledTimes(9); $stopwatch = $this->prophesize('Symfony\\Component\\Stopwatch\\Stopwatch'); $stopwatch->start(DefaultProgressOutput::PROGRESS_NAME)->shouldBeCalled(); $stopwatchEvent = $this->prophesize('Symfony\\Component\\Stopwatch\\StopwatchEvent'); $stopwatch->stop(DefaultProgressOutput::PROGRESS_NAME)->willReturn($stopwatchEvent->reveal())->shouldBeCalled($stopwatch); $defaultProgressOutput = new DefaultProgressOutput($output->reveal(), $stopwatch->reveal()); $defaultProgressOutput->startProgress(); $defaultProgressOutput->startRuleSetGeneration(); $defaultProgressOutput->endRuleSetGeneration(); $defaultProgressOutput->startUsageDetection(); $defaultProgressOutput->endUsageDetection(); $defaultProgressOutput->startOutputRendering(); $defaultProgressOutput->endOutputRendering(); $defaultProgressOutput->endProgress(0, 0); }