Skip to content

Commit

Permalink
Add the documentation for the UndefinedVariable rule (Resolves #693 ) (
Browse files Browse the repository at this point in the history
…#698)

* Add the documentation for the UndefinedVariable rule (Resolves #693 )

* Handle feedback from @kylekatarnls about the text.
  • Loading branch information
tvbeek authored and kylekatarnls committed Nov 11, 2019
1 parent b2434fe commit 44385f1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/site/rst/rules/cleancode.rst
Expand Up @@ -118,6 +118,20 @@ Example: ::
return new \stdClass();
}

UndefinedVariable
=================

Since: PHPMD 2.8.0

Detects when a variable that is used has not been defined before.

Example: ::

function printX() {
echo $x;
}


Remark
======

Expand Down
1 change: 1 addition & 0 deletions src/site/rst/rules/index.rst
Expand Up @@ -20,6 +20,7 @@ Clean Code Rules
- `IfStatementAssignment <cleancode.html#ifstatementassignment>`_: Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string.
- `DuplicateArrayKey <cleancode.html#duplicatearraykey>`_: Defining another value for the same key in an array literal overrides the previous key/value, which makes it effectively an unused code. If it's known from the beginning that the key will have different value, there is usually no point in defining first one.
- `MissingImport <cleancode.html#missingimport>`_: Importing all external classes in a file through use statements makes them clearly visible.
- `UndefinedVariable <cleancode.html#undefinedvariable>`_: Detects when a variable is used that has not been defined before.

Code Size Rules
===============
Expand Down

0 comments on commit 44385f1

Please sign in to comment.