Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

lint/dead-code

Code that never runs, or whose result is never used. Also in analyse (42).

no-always-false-condition

Reduce always false in a if (a || b) condition

In the dead-code set. Safe fix.

no-always-true-if

Remove if condition that is always true

In the dead-code set. Safe fix.

no-always-true-instanceof

Remove instanceof checks and assert(instanceof) calls that are always true for the known type.

In the dead-code set. Safe fix.

no-and-true

Remove and true that has no added value

In the dead-code set. Safe fix.

no-cast-in-concat

Remove (string) casting when it comes to concat, that does this by default

In the dead-code set. Safe fix.

no-condition-exact-return

Remove an if that returns the value it compares when the next statement returns the compared expression.

In the dead-code set. Safe fix.

no-dead-catch

Remove dead catches

In the dead-code set. Safe fix.

no-dead-php-version-check

Remove PHP_VERSION_ID / version_compare() checks that are always true for the configured PHP version.

In the dead-code set. Safe fix.

no-double-self-assignment

Remove duplicated self assign of the same variable

In the dead-code set. Safe fix. Intent: correctness.

no-duplicate-array-key

Remove duplicated key in defined arrays

In the dead-code set. Safe fix.

no-duplicate-case-body

2 following switch keys with identical will be reduced to one result

In the dead-code set. Safe fix.

no-empty-block

Remove or report if/for/foreach/while statements with an empty body.

In the dead-code set. Safe fix.

no-empty-method

Remove empty class methods not required by parents

In the dead-code set. Safe fix.

no-false-ternary

Change ternary of bool : false to && bool

In the dead-code set. Safe fix.

no-future-php-version-check

Unwrap if checks on a PHP version that the configured PHP version always meets.

In the dead-code set. Safe fix.

no-identical-branches

Remove if/else if they have same content

In the dead-code set. Safe fix.

no-implode-ternary

Drop an empty-array ternary around implode()

In the code-quality set. Safe fix.

no-invalid-return-tag

Remove @return docblock that contradicts the declared native return type

In the dead-code set. Safe fix.

no-invalid-var-tag

Removes non-existing @var annotations above the code

In the dead-code set. Safe fix.

no-null-tag-value

Remove @var/@param/@return null docblock

In the dead-code set. Safe fix.

no-overridden-assign-before-if

Remove assign before if/else that overrides the variable in both branches

In the dead-code set. Unsafe fix: it can change behaviour.

no-parent-call-without-parent

Remove unused parent call with no parent class

In the dead-code set. Safe fix.

no-redundant-condition

Merge an if into the if before it when both check the same condition.

In the dead-code set. Safe fix.

no-redundant-default-argument

Remove arguments that equal the parameter default value.

In the dead-code set. Safe fix.

no-redundant-foreach-guard

Remove unused if check to non-empty array before foreach of the array

In the dead-code set. Safe fix.

no-redundant-promoted-assign

Remove useless re-assign from property promotion

In the dead-code set. Safe fix.

no-redundant-property-default

Remove redundant default value from property that is always assigned in the constructor

In the dead-code set. Safe fix.

no-redundant-type-check

Remove is_<type>() check that can never fail on already known type

In the dead-code set. Unsafe fix: it can change behaviour.

no-return-in-constructor

Remove useless return Expr in __construct()

In the dead-code set. Safe fix.

no-self-assignment

Detects and removes self-assignments where a variable or property is assigned to itself.

In the dead-code set. Safe fix. Intent: correctness.

no-typed-property-instanceof

Remove dead instanceof check on type hinted property

In the dead-code set. Safe fix.

no-unreachable-code

Remove unreachable statements

In the dead-code set. Safe fix.

no-unused-assignment

Remove assignments whose value is never read, including stores overwritten before use.

In the dead-code set. Safe fix.

no-unused-constructor-param

Remove unused parameter in constructor

In the dead-code set. Safe fix.

no-unused-expression

Remove dead code statements

In the dead-code set. Safe fix.

no-unused-foreach-key

Remove unused key in foreach

In the dead-code set. Safe fix.

no-unused-global

Flags global $x; declarations whose name is never read or written

In the code-quality set. Report only. Intent: correctness.

no-unused-private-constant

Remove unused class constants

In the dead-code set. Safe fix.

no-unused-private-method

Remove unused private method

In the dead-code set. Safe fix.

no-unused-private-method-param

Remove unused parameters of private methods, including test-method parameters overwritten before use.

In the dead-code set. Safe fix.

no-unused-private-property

Remove unused private properties

In the dead-code set. Safe fix.

no-unused-promoted-property

Remove unused promoted property

In the dead-code set. Safe fix.

no-unused-public-method-param

Remove unused parameter in public method on final class without extends and interface

In the dead-code set. Safe fix.

no-unused-return-type

Narrow overly wide union return type declaration if possible

In the dead-code set. Safe fix.

no-unused-return-value

Detects private methods whose return value is thrown away at every call site.

In the dead-code set. Report only.

no-unused-static

Flags static $x; declarations whose name is never read or written

In the code-quality set. Report only. Intent: correctness.

no-useless-cast

Remove casts to the type the value already has, including (string) inside concatenation.

In the dead-code set. Safe fix. Upstream gates: strictRules.uselessCast.

no-useless-catch

Remove dead try/catch

In the dead-code set. Safe fix.

no-useless-condition

Remove if conditions whose branches return the same value.

In the dead-code set. Safe fix.

no-useless-continue

Remove continue as the last statement of a loop.

In the dead-code set. Safe fix.

no-useless-filter-var

Removes filter_var() calls with exact type

In the dead-code set. Safe fix.

no-useless-math

Remove arithmetic that does not change the value (+ 0, * 1, …).

In the dead-code set. Safe fix.

no-useless-override

Remove methods and constructors that only call the parent with the same arguments.

In the dead-code set. Safe fix.

no-useless-phpdoc-type

Remove PHPDoc types that add nothing over the native type (@var null, unions wider than the native return type).

In the dead-code set. Safe fix.

no-useless-ternary

Simplify ternaries whose result does not depend on the condition, or that equal a boolean expression.

In the dead-code and code-quality sets. Safe fix.

Last updated on

Was this page helpful?