public function testGetClass() { $classDeprecation = $this->prophesize('SensioLabs\\DeprecationDetector\\FileInfo\\Deprecation\\ClassDeprecation'); $classDeprecations = array('class' => $classDeprecation->reveal()); $ruleSet = new RuleSet($classDeprecations); $this->assertSame($classDeprecation->reveal(), $ruleSet->getClass('class')); $this->assertNull($ruleSet->getClass('not existing')); }
/** * {@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) { $violations = array(); foreach ($phpFileInfo->typeHintUsages() as $typeHintUsage) { $isClass = $this->ruleSet->hasClass($typeHintUsage->name()); if ($isClass || $this->ruleSet->hasInterface($typeHintUsage->name())) { $usage = $isClass ? new ClassUsage($typeHintUsage->name(), $typeHintUsage->getLineNumber()) : new InterfaceUsage($typeHintUsage->name(), '', $typeHintUsage->getLineNumber()); $comment = $isClass ? $this->ruleSet->getClass($typeHintUsage->name())->comment() : $this->ruleSet->getInterface($typeHintUsage->name())->comment(); $violations[] = new Violation($usage, $phpFileInfo, $comment); } } return $violations; }
/** * {@inheritdoc} */ public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet) { $violations = array(); foreach ($phpFileInfo->superTypeUsages() as $superTypeUsage) { if ($ruleSet->hasClass($superTypeUsage->name())) { $violations[] = new Violation($superTypeUsage, $phpFileInfo, $ruleSet->getClass($superTypeUsage->name())->comment()); } } return $violations; }