Example #1
0
 /**
  * Tests if the property <b>$checkParameterizedMethods</b> is set to <b>true</b>
  * or has no parameters.
  *
  * @param PHP_PMD_Node_Method $node The context method node.
  *
  * @return boolean
  */
 private function _isParameterizedOrIgnored(PHP_PMD_Node_Method $node)
 {
     if ($this->getBooleanProperty('checkParameterizedMethods')) {
         return $node->getParameterCount() === 0;
     }
     return true;
 }
Example #2
0
 /**
  * testMagicCallThrowsExceptionWhenNoMatchingMethodExists
  *
  * @return void
  * @covers PHP_PMD_Node_AbstractCallable::__call
  * @group phpmd
  * @group phpmd::node
  * @group unittest
  * @expectedException BadMethodCallException
  */
 public function testMagicCallThrowsExceptionWhenNoMatchingMethodExists()
 {
     $node = new PHP_PMD_Node_Method(new PHP_Depend_Code_Method(null));
     $node->getFooBar();
 }
Example #3
0
 /**
  * Returns <b>true</b> when the given method should be used for this rule's
  * analysis.
  *
  * @param PHP_PMD_Node_Class  $class  The context class instance.
  * @param PHP_PMD_Node_Method $method The context method instance.
  *
  * @return boolean
  */
 private function _acceptMethod(PHP_PMD_Node_Class $class, PHP_PMD_Node_Method $method)
 {
     return $method->isPrivate() && strcasecmp($method->getImage(), $class->getImage()) !== 0 && strcasecmp($method->getImage(), '__construct') !== 0 && strcasecmp($method->getImage(), '__destruct') !== 0 && strcasecmp($method->getImage(), '__clone') !== 0;
 }
Example #4
0
 /**
  * Returns <b>true</b> when the given method should be used for this rule's
  * analysis.
  *
  * @param PHP_PMD_Node_Class  $class  The context class instance.
  * @param PHP_PMD_Node_Method $method The context method instance.
  *
  * @return boolean
  */
 private function _acceptMethod(PHP_PMD_Node_Class $class, PHP_PMD_Node_Method $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;
 }
Example #5
0
 /**
  * Initializes the getMetric() method of the given function or method node.
  *
  * @param PHP_PMD_Node_Function|PHP_PMD_Node_Method $mock   Mock instance.
  * @param string                                    $metric Metric acronym.
  * @param mixed                                     $value  Expected value.
  *
  * @return PHP_PMD_Node_Function|PHP_PMD_Node_Method
  */
 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;
 }
Example #6
0
 /**
  * Initializes the getParameterCount() method of the given callable.
  *
  * @param PHP_PMD_Node_Function|PHP_PMD_Node_Method $mock Mocked callable.
  * @param integer $parameterCount Number of parameters.
  *
  * @return PHP_PMD_Node_Function|PHP_PMD_Node_Method
  */
 private function _initFunctionOrMethod($mock, $parameterCount)
 {
     $mock->expects($this->once())->method('getParameterCount')->will($this->returnValue($parameterCount));
     return $mock;
 }