UnusedLocalVariable

Detects when a local variable is declared and/or assigned, but not used.

Example:

class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}

This rule has the following properties:

Name

Default Value

Description

allow-unused-foreach-variables

false

Allow unused variables in foreach language constructs.

UnusedPrivateMethod

Since: PHPMD 0.2

Unused Private Method detects when a private method is declared but is unused.

Example:

class Something
{
private function foo() {} // unused
}

UnusedFormalParameter

Since: PHPMD 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example:

class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}

Remark

This document is based on a ruleset xml-file, that was taken from the original source of the PMD project. This means that most parts of the content on this page are the intellectual work of the PMD community and its contributors and not of the PHPMD project.