diff --git a/src/site/rst/rules/cleancode.rst b/src/site/rst/rules/cleancode.rst index 5d1786dc0..27300f0a2 100644 --- a/src/site/rst/rules/cleancode.rst +++ b/src/site/rst/rules/cleancode.rst @@ -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 ====== diff --git a/src/site/rst/rules/index.rst b/src/site/rst/rules/index.rst index 28120b03a..f9a513f08 100644 --- a/src/site/rst/rules/index.rst +++ b/src/site/rst/rules/index.rst @@ -20,6 +20,7 @@ Clean Code Rules - `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 `_: 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 `_: Importing all external classes in a file through use statements makes them clearly visible. +- `UndefinedVariable `_: Detects when a variable is used that has not been defined before. Code Size Rules ===============