public function satisfy(array $configuration, AstClassReferenceInterface $abstractClassReference, AstMap $astMap, CollectorFactory $collectorFactory, AstParserInterface $astParser)
 {
     $classInherits = $astMap->getClassInherits($abstractClassReference->getClassName());
     foreach ($classInherits as $classInherit) {
         if (count($classInherit->getPath()) >= $configuration['level']) {
             return true;
         }
     }
     return false;
 }
 public function satisfy(array $configuration, AstClassReferenceInterface $classReference, AstMap $astMap, CollectorFactory $collectorFactory, AstParserInterface $astParser)
 {
     if (!$astParser instanceof NikicPhpParser) {
         return false;
     }
     $ast = $astParser->getAstForClassname($classReference->getClassName());
     /** @var $classMethods ClassMethod[] */
     $classMethods = $astParser->findNodesOfType($ast, ClassMethod::class);
     foreach ($classMethods as $classMethod) {
         if (preg_match('/' . $this->getMethodNameRegexByConfiguration($configuration) . '/i', $classMethod->name, $collectorFactory)) {
             return true;
         }
     }
     return false;
 }
Beispiel #3
0
 /**
  * @param AstClassReferenceInterface $astClassReference
  */
 public function addAstClassReference(AstClassReferenceInterface $astClassReference)
 {
     $this->astClassReferences[$astClassReference->getClassName()] = $astClassReference;
 }
 public function satisfy(array $configuration, AstClassReferenceInterface $abstractClassReference, AstMap $astMap, CollectorFactory $collectorFactory, AstParserInterface $astParser)
 {
     return preg_match('/' . $this->getRegexByConfiguration($configuration) . '/i', $abstractClassReference->getClassName(), $collectorFactory);
 }
 private function getStaticMethodCalls(NikicPhpParser $astParser, AstClassReferenceInterface $classReference)
 {
     $buffer = [];
     $ast = $astParser->getAstForClassname($classReference->getClassName());
     foreach ($astParser->findNodesOfType($ast, StaticCall::class) as $node) {
         if (!$node->class instanceof Name) {
             continue;
             // @codeCoverageIgnore
         }
         $buffer[] = new EmittedDependency($node->class->toString(), $node->class->getLine(), 'static_method');
     }
     return $buffer;
 }