Author: Manuel Pichler (mapi@phpmd.org)
Inheritance: extends PHPMD\Node\AbstractCallableNode
 /**
  * @param MethodNode $node
  *
  * @return int
  */
 private function count(MethodNode $node)
 {
     $count = 0;
     $methodPostfixes = $node->findChildrenOfType('MethodPostfix');
     foreach ($methodPostfixes as $methodPostfix) {
         if (true === $this->isMethodPostfixInNames($methodPostfix)) {
             $count++;
         }
     }
     return $count;
 }
 /**
  * @param MethodNode $node
  *
  * @return bool
  */
 private function hasNotAllowedChildren(MethodNode $node)
 {
     $children = $node->findChildrenOfType('ScopeStatement');
     $allowedChildren = explode($this->getStringProperty('delimiter'), $this->getStringProperty('allowedChildren'));
     /** @var AbstractNode $child */
     foreach ($children as $child) {
         if (true === in_array($child->getImage(), $allowedChildren) || true === $this->isChildOfTry($child)) {
             continue;
         }
         return true;
     }
     return false;
 }
示例#3
0
 /**
  * Initializes the getParameterCount() method of the given callable.
  *
  * @param \PHPMD\Node\FunctionNode|\PHPMD\Node\MethodNode $mock
  * @param integer $parameterCount
  * @return \PHPMD\Node\FunctionNode|\PHPMD\Node\MethodNode
  */
 private function initFunctionOrMethodMock($mock, $parameterCount)
 {
     $mock->expects($this->once())->method('getParameterCount')->will($this->returnValue($parameterCount));
     return $mock;
 }
示例#4
0
 /**
  * Returns <b>true</b> when the given method should be used for this rule's
  * analysis.
  *
  * @param \PHPMD\Node\ClassNode $class
  * @param \PHPMD\Node\MethodNode $method
  * @return boolean
  */
 private function acceptMethod(ClassNode $class, MethodNode $method)
 {
     return $method->isPrivate() && false === $method->hasSuppressWarningsAnnotationFor($this) && strcasecmp($method->getImage(), $class->getImage()) !== 0 && strcasecmp($method->getImage(), '__construct') !== 0 && strcasecmp($method->getImage(), '__destruct') !== 0 && strcasecmp($method->getImage(), '__clone') !== 0;
 }
示例#5
0
 /**
  * Tests if the property <b>$checkParameterizedMethods</b> is set to <b>true</b>
  * or has no parameters.
  *
  * @param \PHPMD\Node\MethodNode $node
  * @return boolean
  */
 private function isParameterizedOrIgnored(MethodNode $node)
 {
     if ($this->getBooleanProperty('checkParameterizedMethods')) {
         return $node->getParameterCount() === 0;
     }
     return true;
 }
示例#6
0
 /**
  * testMagicCallThrowsExceptionWhenNoMatchingMethodExists
  *
  * @return void
  * @expectedException \BadMethodCallException
  */
 public function testMagicCallThrowsExceptionWhenNoMatchingMethodExists()
 {
     $node = new MethodNode(new \PDepend\Source\AST\ASTMethod(null));
     $node->getFooBar();
 }
 /**
  * @param MethodNode $node
  *
  * @return int
  */
 private function countThis(MethodNode $node)
 {
     $count = 0;
     $variables = $node->findChildrenOfType('Variable');
     foreach ($variables as $variable) {
         if ($variable->getImage() === '$this') {
             $count++;
         }
     }
     return $count;
 }
示例#8
0
 /**
  * Initializes the getMetric() method of the given function or method node.
  *
  * @param \PHPMD\Node\FunctionNode|\PHPMD\Node\MethodNode $mock
  * @param string $metric
  * @param mixed $value
  * @return \PHPMD\Node\FunctionNode|\PHPMD\Node\MethodNode
  */
 protected function initFunctionOrMethod($mock, $metric, $value)
 {
     if ($metric === null) {
         return $mock;
     }
     $mock->expects($this->atLeastOnce())->method('getMetric')->with($this->equalTo($metric))->will($this->returnValue($value));
     return $mock;
 }