BlueSpice MediaWiki master
 All Classes Namespaces Files Functions Variables Groups Pages
PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis Namespace Reference

Classes

class  AssignmentInConditionSniff
 
class  EmptyStatementSniff
 
class  ForLoopShouldBeWhileLoopSniff
 
class  ForLoopWithTestFunctionCallSniff
 
class  JumbledIncrementerSniff
 
class  UnconditionalIfStatementSniff
 
class  UnnecessaryFinalModifierSniff
 
class  UnusedFunctionParameterSniff
 
class  UselessOverridingMethodSniff
 

Detailed Description

Detects variable assignments being made within conditions.

This is a typical code smell and more often than not a comparison was intended.

Note: this sniff does not detect variable assignments in the conditional part of ternaries!

Author
Juliette Reinders Folmer phpcs.nosp@m._nos.nosp@m.pam@a.nosp@m.dvie.nosp@m.senzo.nosp@m..nl

This sniff class detected empty statement.

This sniff implements the common algorithm for empty statement body detection. A body is considered as empty if it is completely empty or it only contains whitespace characters and/or comments.

stmt { // foo } stmt (conditions) { // foo }

Author
Manuel Pichler mapi@.nosp@m.manu.nosp@m.el-pi.nosp@m.chle.nosp@m.r.de
Greg Sherwood gsher.nosp@m.wood.nosp@m.@squi.nosp@m.z.ne.nosp@m.t

Detects for-loops that can be simplified to a while-loop.

This rule is based on the PMD rule catalog. Detects for-loops that can be simplified as a while-loop.

class Foo { public function bar($x) { for (;true;) true; // No Init or Update part, may as well be: while (true) } }

Author
Manuel Pichler mapi@.nosp@m.manu.nosp@m.el-pi.nosp@m.chle.nosp@m.r.de

Detects for-loops that use a function call in the test expression.

This rule is based on the PMD rule catalog. Detects for-loops that use a function call in the test expression.

class Foo { public function bar($x) { $a = array(1, 2, 3, 4); for ($i = 0; $i < count($a); $i++) { $a[$i] *= $i; } } }

Author
Greg Sherwood gsher.nosp@m.wood.nosp@m.@squi.nosp@m.z.ne.nosp@m.t
Manuel Pichler mapi@.nosp@m.manu.nosp@m.el-pi.nosp@m.chle.nosp@m.r.de

Detects incrementer jumbling in for loops.

This rule is based on the PMD rule catalog. The jumbling incrementer sniff detects the usage of one and the same incrementer into an outer and an inner loop. Even it is intended this is confusing code.

class Foo { public function bar($x) { for ($i = 0; $i < 10; $i++) { for ($k = 0; $k < 20; $i++) { echo 'Hello'; } } } }

Author
Manuel Pichler mapi@.nosp@m.manu.nosp@m.el-pi.nosp@m.chle.nosp@m.r.de

Detects unconditional if- and elseif-statements.

This rule is based on the PMD rule catalog. The Unconditional If Statement sniff detects statement conditions that are only set to one of the constant values true or false

class Foo { public function close() { if (true) { // ... } } }

Author
Manuel Pichler mapi@.nosp@m.manu.nosp@m.el-pi.nosp@m.chle.nosp@m.r.de

Detects unnecessary final modifiers inside of final classes.

This rule is based on the PMD rule catalog. The Unnecessary Final Modifier sniff detects the use of the final modifier inside of a final class which is unnecessary.

final class Foo { public final function bar() { } }

Author
Manuel Pichler mapi@.nosp@m.manu.nosp@m.el-pi.nosp@m.chle.nosp@m.r.de

Checks the for unused function parameters.

This sniff checks that all function parameters are used in the function body. One exception is made for empty function bodies or function bodies that only contain comments. This could be useful for the classes that implement an interface that defines multiple methods but the implementation only needs some of them.

Author
Manuel Pichler mapi@.nosp@m.manu.nosp@m.el-pi.nosp@m.chle.nosp@m.r.de
Greg Sherwood gsher.nosp@m.wood.nosp@m.@squi.nosp@m.z.ne.nosp@m.t

Detects unnecessary overridden methods that simply call their parent.

This rule is based on the PMD rule catalog. The Useless Overriding Method sniff detects the use of methods that only call their parent classes's method with the same name and arguments. These methods are not required.

class FooBar { public function __construct($a, $b) { parent::__construct($a, $b); } }

Author
Manuel Pichler mapi@.nosp@m.manu.nosp@m.el-pi.nosp@m.chle.nosp@m.r.de