/**
  * {@inheritdoc}
  */
 public function loadRuleSet($lock)
 {
     $composer = $this->getComposerObject($lock);
     $packages = $this->getComposerPackages($composer);
     $ruleSet = new RuleSet();
     foreach ($packages as $i => $package) {
         $ruleSet->merge($this->loadPackageRuleSet($package));
     }
     return $ruleSet;
 }
 /**
  * {@inheritdoc}
  */
 public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
 {
     $violations = array();
     foreach ($phpFileInfo->getFunctionUsages() as $functionUsage) {
         if ($ruleSet->hasFunction($functionUsage->name())) {
             $violations[] = new Violation($functionUsage, $phpFileInfo, $ruleSet->getFunction($functionUsage->name())->comment());
         }
     }
     return $violations;
 }
 /**
  * {@inheritdoc}
  */
 public function check(PhpFileInfo $phpFileInfo)
 {
     $violations = array();
     foreach ($phpFileInfo->classUsages() as $classUsage) {
         if ($this->ruleSet->hasClass($classUsage->name())) {
             $violations[] = new Violation($classUsage, $phpFileInfo, $this->ruleSet->getClass($classUsage->name())->comment());
         }
     }
     return $violations;
 }
 /**
  * {@inheritdoc}
  */
 public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
 {
     $violations = array();
     foreach ($phpFileInfo->interfaceUsages() as $interfaceUsageGroup) {
         foreach ($interfaceUsageGroup as $interfaceUsage) {
             if ($ruleSet->hasInterface($interfaceUsage->name())) {
                 $violations[] = new Violation($interfaceUsage, $phpFileInfo, $ruleSet->getInterface($interfaceUsage->name())->comment());
             }
         }
     }
     return $violations;
 }
 /**
  * @param string  $path
  * @param RuleSet $ruleSet
  *
  * @return RuleSet
  */
 public function traverse($path, RuleSet $ruleSet = null)
 {
     $result = $this->finder->parsePhpFiles($path);
     if (!$ruleSet instanceof RuleSet) {
         $ruleSet = new RuleSet();
     }
     foreach ($result->parsedFiles() as $file) {
         if ($file->hasDeprecations()) {
             $ruleSet->merge($file);
         }
     }
     return $ruleSet;
 }
 /**
  * {@inheritdoc}
  */
 public function check(PhpFileInfo $phpFileInfo)
 {
     $violations = array();
     foreach ($phpFileInfo->methodDefinitions() as $methodDefinition) {
         $ancestors = $this->ancestorResolver->getClassAncestors($phpFileInfo, $methodDefinition->parentName());
         foreach ($ancestors as $ancestor) {
             if ($this->ruleSet->hasMethod($methodDefinition->name(), $ancestor)) {
                 $violations[] = new Violation($methodDefinition, $phpFileInfo, $this->ruleSet->getMethod($methodDefinition->name(), $ancestor)->comment());
             }
         }
     }
     return $violations;
 }
 /**
  * {@inheritdoc}
  */
 public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
 {
     $violations = array();
     foreach ($phpFileInfo->typeHintUsages() as $typeHintUsage) {
         $isClass = $ruleSet->hasClass($typeHintUsage->name());
         if ($isClass || $ruleSet->hasInterface($typeHintUsage->name())) {
             $usage = $isClass ? new ClassUsage($typeHintUsage->name(), $typeHintUsage->getLineNumber()) : new InterfaceUsage($typeHintUsage->name(), '', $typeHintUsage->getLineNumber());
             $comment = $isClass ? $ruleSet->getClass($typeHintUsage->name())->comment() : $ruleSet->getInterface($typeHintUsage->name())->comment();
             $violations[] = new Violation($usage, $phpFileInfo, $comment);
         }
     }
     return $violations;
 }
 /**
  * {@inheritdoc}
  */
 public function loadRuleSet($lock)
 {
     try {
         $composer = $this->factory->fromLock($lock);
     } catch (ComposerException $e) {
         throw new CouldNotLoadRuleSetException($e->getMessage());
     }
     $ruleSet = new RuleSet();
     foreach ($composer->getPackages() as $package) {
         $ruleSet->merge($this->loadPackageRuleSet($package));
     }
     return $ruleSet;
 }
 /**
  * @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;
 }
 /**
  * {@inheritdoc}
  */
 public function loadRuleSet($lock)
 {
     $composer = $this->getComposerObject($lock);
     $packages = $this->getComposerPackages($composer);
     $total = count($packages);
     $this->eventDispatcher->dispatch(ProgressEvent::RULESET, new ProgressEvent(0, $total));
     $ruleSet = new RuleSet();
     foreach ($packages as $i => $package) {
         $packageRuleSet = $this->loadPackageRuleSet($package);
         if (null !== $packageRuleSet) {
             $ruleSet->merge($packageRuleSet);
         }
         $this->eventDispatcher->dispatch(ProgressEvent::RULESET, new ProgressEvent(++$i, $total));
     }
     return $ruleSet;
 }
 /**
  * {@inheritdoc}
  */
 public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
 {
     $violations = array();
     foreach ($phpFileInfo->methodUsages() as $methodUsage) {
         $className = $methodUsage->className();
         if ($ruleSet->hasMethod($methodUsage->name(), $className)) {
             $violations[] = new Violation($methodUsage, $phpFileInfo, $ruleSet->getMethod($methodUsage->name(), $className)->comment());
         }
         $ancestors = $this->ancestorResolver->getClassAncestors($phpFileInfo, $methodUsage->className());
         foreach ($ancestors as $ancestor) {
             if ($ruleSet->hasMethod($methodUsage->name(), $ancestor)) {
                 $violations[] = new Violation(new MethodUsage($methodUsage->name(), $ancestor, $methodUsage->getLineNumber(), $methodUsage->isStatic()), $phpFileInfo, $ruleSet->getMethod($methodUsage->name(), $ancestor)->comment());
             }
         }
     }
     return $violations;
 }
 /**
  * @param $path
  * @param $quite
  *
  * @return null|RuleSet
  */
 public function traverse($path, $quite = false)
 {
     $files = $this->container['finder.php_deprecation']->in($path);
     $ruleSet = new RuleSet();
     $hasDeprecations = false;
     if (!$quite && null !== $this->eventDispatcher) {
         $total = count($files);
         $this->eventDispatcher->dispatch(ProgressEvent::RULESET, new ProgressEvent(0, $total));
     }
     foreach ($files as $i => $file) {
         /** @var PhpFileInfo $file */
         if ($file->hasDeprecations()) {
             $ruleSet->merge($file);
             $hasDeprecations = true;
         }
         if (!$quite && null !== $this->eventDispatcher) {
             $this->eventDispatcher->dispatch(ProgressEvent::RULESET, new ProgressEvent(++$i, $total));
         }
     }
     return $hasDeprecations ? $ruleSet : null;
 }
 public function testGetMethod()
 {
     $methodDeprecation = $this->prophesize('SensioLabs\\DeprecationDetector\\FileInfo\\Deprecation\\MethodDeprecation');
     $methodDeprecations = array('class' => array('method' => $methodDeprecation->reveal()));
     $ruleSet = new RuleSet(array(), array(), $methodDeprecations);
     $this->assertSame($methodDeprecation->reveal(), $ruleSet->getMethod('method', 'class'));
     $this->assertNull($ruleSet->getMethod('someOtherMethod', 'class'));
 }