Example #1
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 #2
0
 /**
  * Tests if the given variable node os part of an index expression.
  *
  * @param \PHPMD\Node\ASTNode $node
  * @return boolean
  */
 protected function isWrappedByIndexExpression(ASTNode $node)
 {
     return $node->getParent()->isInstanceOf('ArrayIndexExpression') || $node->getParent()->isInstanceOf('StringIndexExpression');
 }
Example #3
0
 /**
  * Stores the given literal node in an internal list of found variables.
  *
  * @param \PHPMD\Node\ASTNode $node
  * @return void
  */
 private function collectLiteral(ASTNode $node)
 {
     $variable = '$' . trim($node->getImage(), '\'');
     if (!isset($this->images[$variable])) {
         $this->images[$variable] = array();
     }
     $this->images[$variable][] = $node;
 }
Example #4
0
 /**
  * testGetNamespaceNameReturnsNull
  *
  * @return void
  */
 public function testGetNamespaceNameReturnsNull()
 {
     $mock = $this->getMock('PDepend\\Source\\AST\\ASTNode');
     $node = new ASTNode($mock, __FILE__);
     $this->assertNull($node->getNamespaceName());
 }
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;
 }