PHP Class PHPMD\Rule\UnusedLocalVariable

Author: Manuel Pichler ([email protected])
Inheritance: extends PHPMD\Rule\AbstractLocalVariable, implements FunctionAware, implements MethodAware
显示文件 Open project: horde/horde Class Usage Examples

Public Methods

Method Description
apply ( PHPMD\AbstractNode $node ) : void This method checks that all local variables within the given function or method are used at least one time.

Protected Methods

Method Description
doCheckNodeImage ( PHPMD\AbstractNode $node ) : void Template method that performs the real node image check.

Private Methods

Method Description
collectLiteral ( PHPMD\Node\ASTNode $node ) : void Stores the given literal node in an internal list of found variables.
collectVariable ( PHPMD\Node\ASTNode $node ) : void Stores the given variable node in an internal list of found variables.
collectVariables ( PHPMD\Node\AbstractCallableNode $node ) : void This method collects all local variable instances from the given method/function node and stores their image in the $_images property.
isChildOf ( PHPMD\AbstractNode $node, string $type ) : boolean Checks if the given node is a direct or indirect child of a node with the given type.
isNameAllowedInContext ( PHPMD\AbstractNode $node ) : boolean Checks if a short name is acceptable in the current context. For the moment these contexts are the init section of a for-loop and short variable names in catch-statements.
isUnusedForeachVariableAllowed ( PHPMD\Node\ASTNode $variable ) : boolean Checks if an unused foreach variable (key or variable) is allowed.
removeParameters ( PHPMD\Node\AbstractCallableNode $node ) : void This method removes all variables from the $_images property that are also found in the formal parameters of the given method or/and function node.

Method Details

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

doCheckNodeImage() protected method

Template method that performs the real node image check.
protected doCheckNodeImage ( PHPMD\AbstractNode $node ) : void
$node PHPMD\AbstractNode
return void