コード例 #1
0
 public function testCheckReturnsArrayIfAnExceptionIsThrown()
 {
     $file = $this->prophesize('SensioLabs\\DeprecationDetector\\FileInfo\\PhpFileInfo');
     $file = $file->reveal();
     $concreteChecker = $this->prophesize('SensioLabs\\DeprecationDetector\\Violation\\ViolationChecker\\ViolationCheckerInterface');
     $concreteChecker->check($file)->willThrow(new \Exception())->shouldBeCalled();
     $checker = new ComposedViolationChecker(array($concreteChecker->reveal()));
     $this->assertSame([], $checker->check($file));
 }
コード例 #2
0
 /**
  * @param RuleSet             $ruleSet
  * @param ParsedPhpFileFinder $files
  *
  * @return Violation[]
  */
 protected function getViolations(RuleSet $ruleSet, ParsedPhpFileFinder $files)
 {
     $container = $this->getApplication()->getContainer();
     // TODO: move to container?
     $checker = new ComposedViolationChecker(array(new ViolationChecker\ClassViolationChecker($ruleSet), new ViolationChecker\InterfaceViolationChecker($ruleSet), new ViolationChecker\MethodViolationChecker($ruleSet, $container['ancestor_resolver']), new ViolationChecker\SuperTypeViolationChecker($ruleSet), new ViolationChecker\TypeHintViolationChecker($ruleSet), new ViolationChecker\MethodDefinitionViolationChecker($ruleSet, $container['ancestor_resolver'])));
     $total = count($files);
     $container['event_dispatcher']->dispatch(ProgressEvent::CHECKER, new ProgressEvent(0, $total));
     $result = array();
     foreach ($files as $i => $file) {
         $result = array_merge($result, $checker->check($file));
         $container['event_dispatcher']->dispatch(ProgressEvent::CHECKER, new ProgressEvent(++$i, $total));
     }
     return $result;
 }