PHPMD\Rule\UnusedLocalVariable::apply PHP Method

apply() public method

This method checks that all local variables within the given function or method are used at least one time.
public apply ( PHPMD\AbstractNode $node ) : void
$node PHPMD\AbstractNode
return void
    public function apply(AbstractNode $node)
    {
        $this->images = array();
        $this->collectVariables($node);
        $this->removeParameters($node);
        foreach ($this->images as $nodes) {
            if (count($nodes) === 1) {
                $this->doCheckNodeImage($nodes[0]);
            }
        }
    }

Usage Example

 /**
  * testLocalVariableUsedInDoubleQuoteStringGetsNotReported
  *
  * @return void
  */
 public function testLocalVariableUsedInDoubleQuoteStringGetsNotReported()
 {
     $rule = new UnusedLocalVariable();
     $rule->setReport($this->getReportMock(0));
     $rule->apply($this->getMethod());
 }
All Usage Examples Of PHPMD\Rule\UnusedLocalVariable::apply