doc/examples/node/example.php
Avoid unused parameters such as '$type'. Open
Open
public function errorHandler($type, $message, $file, $line)
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 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
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused local variables such as '$digits'. Open
Open
$digits = '';
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
The method signalHandler() contains an exit expression. Open
Open
exit(0);
- Read upRead up
- Exclude checks
ExitExpression
Since: 0.2
An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
Example
class Foo {
public function bar($param) {
if ($param === 42) {
exit(23);
}
}
}
Source https://phpmd.org/rules/design.html#exitexpression
Each class must be in a namespace of at least one level (a top-level vendor name) Open
Open
class MyPagiApplication extends PAGIApplication
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
function(Node $node) {
- Exclude checks
Expected 1 blank line at end of file; 2 found Open
Open
}
- Exclude checks