/**
  * @param ClassNode $node
  *
  * @return bool
  */
 protected function isTest(ClassNode $node)
 {
     if ('Test' === substr($node->getImage(), -4, 4)) {
         return true;
     }
     return false;
 }
 /**
  * @param ClassNode|ASTClass $node
  *
  * @return bool
  */
 private function isController(ClassNode $node)
 {
     if (true === $node->isAbstract()) {
         return false;
     }
     if ('Controller' === substr($node->getImage(), -10, 10)) {
         return true;
     }
     return false;
 }
 /**
  * @param ClassNode|ASTClass $node
  *
  * @return bool
  */
 protected function isEntity(ClassNode $node)
 {
     $docComment = $node->getDocComment();
     if (0 < preg_match($this->getStringProperty('classIsEntityRegex'), $docComment)) {
         return true;
     }
     if (true === $node->isAbstract()) {
         return false;
     }
     if (0 < preg_match($this->getStringProperty('entityRegex'), $docComment)) {
         return true;
     }
     return false;
 }
Example #4
0
 /**
  * This method checks that the given property postfix is accessed on an
  * instance or static reference to the given class.
  *
  * @param \PHPMD\Node\ClassNode $class
  * @param \PHPMD\Node\ASTNode $postfix
  * @return boolean
  */
 protected function isInScopeOfClass(ClassNode $class, ASTNode $postfix)
 {
     $owner = $postfix->getParent()->getChild(0);
     if ($owner->isInstanceOf('PropertyPostfix')) {
         $owner = $owner->getParent()->getParent()->getChild(0);
     }
     return $owner->isInstanceOf('SelfReference') || $owner->isInstanceOf('StaticReference') || strcasecmp($owner->getImage(), '$this') === 0 || strcasecmp($owner->getImage(), $class->getImage()) === 0;
 }
Example #5
0
 /**
  * This method checks that the given method postfix is accessed on an
  * instance or static reference to the given class.
  *
  * @param \PHPMD\Node\ClassNode $class
  * @param \PHPMD\Node\ASTNode $postfix
  * @return boolean
  */
 private function isClassScope(ClassNode $class, ASTNode $postfix)
 {
     $owner = $postfix->getParent()->getChild(0);
     return $owner->isInstanceOf('MethodPostfix') || $owner->isInstanceOf('SelfReference') || $owner->isInstanceOf('StaticReference') || strcasecmp($owner->getImage(), '$this') === 0 || strcasecmp($owner->getImage(), $class->getImage()) === 0;
 }
Example #6
0
 /**
  * testHasSuppressWarningsAnnotationForReturnsTrue
  *
  * @return void
  */
 public function testHasSuppressWarningsAnnotationForReturnsTrue()
 {
     $class = new \PDepend\Source\AST\ASTClass(null);
     $class->setDocComment('/** @SuppressWarnings("PMD") */');
     $rule = $this->getMock('PHPMD\\AbstractRule');
     $node = new ClassNode($class);
     $this->assertTrue($node->hasSuppressWarningsAnnotationFor($rule));
 }