コード例 #1
0
ファイル: UnusedPrivateField.php プロジェクト: flavius/phpmd
 /**
  * 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;
 }
コード例 #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');
 }
コード例 #3
0
ファイル: UnusedLocalVariable.php プロジェクト: flavius/phpmd
 /**
  * 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;
 }
コード例 #4
0
ファイル: ASTNodeTest.php プロジェクト: flavius/phpmd
 /**
  * testGetNamespaceNameReturnsNull
  *
  * @return void
  */
 public function testGetNamespaceNameReturnsNull()
 {
     $mock = $this->getMock('PDepend\\Source\\AST\\ASTNode');
     $node = new ASTNode($mock, __FILE__);
     $this->assertNull($node->getNamespaceName());
 }
コード例 #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;
 }