public function testHasInterface() { $interfaceDeprecation = $this->prophesize('SensioLabs\\DeprecationDetector\\FileInfo\\Deprecation\\InterfaceDeprecation'); $interfaceDeprecations = array('interface' => $interfaceDeprecation->reveal()); $ruleSet = new RuleSet(array(), $interfaceDeprecations); $this->assertTrue($ruleSet->hasInterface('interface')); $this->assertFalse($ruleSet->hasInterface('someOtherInterface')); }
/** * {@inheritdoc} */ public function check(PhpFileInfo $phpFileInfo) { $violations = array(); foreach ($phpFileInfo->interfaceUsages() as $interfaceUsageGroup) { foreach ($interfaceUsageGroup as $interfaceUsage) { if ($this->ruleSet->hasInterface($interfaceUsage->name())) { $violations[] = new Violation($interfaceUsage, $phpFileInfo, $this->ruleSet->getInterface($interfaceUsage->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; }