Esempio n. 1
0
 /**
  * This method checks that the given property postfix is accessed on an
  * instance or static reference to the given class.
  *
  * @param PHP_PMD_Node_Class   $class   The context class node instance.
  * @param PHP_PMD_Node_ASTNode $postfix The context property postfix node.
  *
  * @return boolean
  */
 protected function isInScopeOfClass(PHP_PMD_Node_Class $class, PHP_PMD_Node_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;
 }
Esempio n. 2
0
 /**
  * This method checks that the given method postfix is accessed on an
  * instance or static reference to the given class.
  *
  * @param PHP_PMD_Node_Class   $class   The context class node instance.
  * @param PHP_PMD_Node_ASTNode $postfix The context method postfix node.
  *
  * @return boolean
  */
 private function _isClassScope(PHP_PMD_Node_Class $class, PHP_PMD_Node_ASTNode $postfix)
 {
     $owner = $postfix->getParent()->getChild(0);
     if ($owner->isInstanceOf('MethodPostfix')) {
         $owner = $owner->getParent()->getParent()->getChild(0);
     }
     return $owner->isInstanceOf('SelfReference') || $owner->isInstanceOf('StaticReference') || strcasecmp($owner->getImage(), '$this') === 0 || strcasecmp($owner->getImage(), $class->getImage()) === 0;
 }
Esempio n. 3
0
 /**
  * This method checks that the given method postfix is accessed on an
  * instance or static reference to the given class.
  *
  * @param PHP_PMD_Node_Class   $class   The context class node instance.
  * @param PHP_PMD_Node_ASTNode $postfix The context method postfix node.
  *
  * @return boolean
  */
 private function _isClassScope(PHP_PMD_Node_Class $class, PHP_PMD_Node_ASTNode $postfix)
 {
     $prefix = $postfix->getParent()->getChild(0);
     return $prefix->isInstanceOf('SelfReference') || $prefix->isInstanceOf('StaticReference') || strcasecmp($prefix->getImage(), '$this') === 0 || strcasecmp($prefix->getImage(), $class->getImage()) === 0;
 }
Esempio n. 4
0
 /**
  * testHasSuppressWarningsAnnotationForReturnsTrue
  *
  * @return void
  */
 public function testHasSuppressWarningsAnnotationForReturnsTrue()
 {
     $class = new \PDepend\Source\AST\ASTClass(null);
     $class->setDocComment('/** @SuppressWarnings("PMD") */');
     $rule = $this->getMock('PHP_PMD_AbstractRule');
     $node = new PHP_PMD_Node_Class($class);
     $this->assertTrue($node->hasSuppressWarningsAnnotationFor($rule));
 }