---
title: "lint/style"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

One consistent way to write the same thing.

**[add-param-type-from-phpdoc](/docs/rules/lint/style/add-param-type-from-phpdoc)**

Takes `@param` annotations of non-mixed types and adjusts accordingly the function signature.

Not in any set. Unsafe fix: it can change behaviour.

**[add-property-type-from-phpdoc](/docs/rules/lint/style/add-property-type-from-phpdoc)**

Takes `@var` annotation of non-mixed types and adjusts accordingly the property signature..

Not in any set. Unsafe fix: it can change behaviour.

**[add-return-type-from-phpdoc](/docs/rules/lint/style/add-return-type-from-phpdoc)**

Takes `@return` annotation of non-mixed types and adjusts accordingly the function signature.

Not in any set. Unsafe fix: it can change behaviour.

**[no-alias-function](/docs/rules/lint/style/no-alias-function)**

Master functions shall be used instead of aliases.

In the `coding-style` set. Unsafe fix: it can change behaviour.

**[no-ambiguous-constant](/docs/rules/lint/style/no-ambiguous-constant)**

Enforces that all constant references made from within a namespace are explicit.

Not in any set. Report only.

**[no-ambiguous-function](/docs/rules/lint/style/no-ambiguous-function)**

Enforces that all function calls made from within a namespace are explicit.

Not in any set. Report only.

**[no-array-accumulation-in-loop](/docs/rules/lint/style/no-array-accumulation-in-loop)**

Detects O(n²) array accumulation patterns inside loops.

In the `coding-style` set. Report only.

**[no-array-push](/docs/rules/lint/style/no-array-push)**

Converts simple usages of `array_push($x, $y);` to `$x[] = $y;`.

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

**[no-assign-in-ternary-branch](/docs/rules/lint/style/no-assign-in-ternary-branch)**

Assign outcome of ternary condition to variable, where applicable

In the `code-quality` set. Safe fix.

**[no-call-user-func](/docs/rules/lint/style/no-call-user-func)**

Call callables directly instead of through call_user_func().

In the `code-quality` and `coding-style` sets. Unsafe fix: it can change behaviour.

**[no-dynamic-method-call](/docs/rules/lint/style/no-dynamic-method-call)**

Disallows calling a method by a variable name (`$object->$method()`).

In the `coding-style` set. Report only. Upstream gates: `strictRules.noVariableVariables`.

**[no-dynamic-method-callable](/docs/rules/lint/style/no-dynamic-method-callable)**

Disallows a first-class callable of a method with a variable name (`$object->$method(...)`).

In the `coding-style` set. Report only. Upstream gates: `strictRules.noVariableVariables`.

**[no-dynamic-property](/docs/rules/lint/style/no-dynamic-property)**

Disallows accessing a property by a variable name (`$object->$property`).

In the `coding-style` set. Report only. Upstream gates: `strictRules.noVariableVariables`.

**[no-dynamic-static-call](/docs/rules/lint/style/no-dynamic-static-call)**

Disallows calling a static method by a variable name (`Foo::$method()`).

In the `coding-style` set. Report only. Upstream gates: `strictRules.noVariableVariables`.

**[no-dynamic-static-callable](/docs/rules/lint/style/no-dynamic-static-callable)**

Disallows a first-class callable of a static method with a variable name (`Foo::$method(...)`).

In the `coding-style` set. Report only. Upstream gates: `strictRules.noVariableVariables`.

**[no-dynamic-static-property](/docs/rules/lint/style/no-dynamic-static-property)**

Disallows accessing a static property by a variable name (`Foo::$$property`).

In the `coding-style` set. Report only. Upstream gates: `strictRules.noVariableVariables`.

**[no-empty](/docs/rules/lint/style/no-empty)**

Detects the use of the `empty()` construct.

In the `code-quality` set. Unsafe fix: it can change behaviour. Intent: suspicious. Upstream gates: `strictRules.disallowedEmpty`.

**[no-ereg](/docs/rules/lint/style/no-ereg)**

Replace deprecated `ereg` regular expression functions with `preg`.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[no-escaped-quotes](/docs/rules/lint/style/no-escaped-quotes)**

Prefer quote that are not inside the string

In the `coding-style` set. Safe fix.

**[no-hash-emoji](/docs/rules/lint/style/no-hash-emoji)**

Discourages usage of the `#️⃣` emoji in place of the ASCII `#`.

In the `coding-style` set. Safe fix.

**[no-ini-set](/docs/rules/lint/style/no-ini-set)**

Enforces that ini_set is not used.

Not in any set. Report only.

**[no-inline-html](/docs/rules/lint/style/no-inline-html)**

Disallows inline content (text outside of PHP tags) in source files.

Not in any set. Report only.

**[no-invalid-phpdoc](/docs/rules/lint/style/no-invalid-phpdoc)**

Checks for syntax errors in docblock comments, such as malformed `{@see}` or

In the `coding-style` set. Report only.

**[no-is-null](/docs/rules/lint/style/no-is-null)**

Replaces `is_null($var)` expression with `null === $var`.

Not in any set. Unsafe fix: it can change behaviour.

**[no-isset](/docs/rules/lint/style/no-isset)**

Detects the use of the `isset()` construct.

Not in any set. Report only.

**[no-multi-assign](/docs/rules/lint/style/no-multi-assign)**

Split chained assignments (`$a = $b = 1`) into one assignment per statement.

In the `coding-style` set. Safe fix.

**[no-multiple-classes-per-file](/docs/rules/lint/style/no-multiple-classes-per-file)**

Ensures that each file contains at most one class-like definition (class, interface, enum, or trait).

Not in any set. Report only.

**[no-nested-ternary](/docs/rules/lint/style/no-nested-ternary)**

Nested ternary expressions are disallowed to improve code clarity and prevent potential bugs arising from confusion over operator associativity.

In the `coding-style` set. Report only.

**[no-parameter-shadowing](/docs/rules/lint/style/no-parameter-shadowing)**

Detects when a function or method parameter is shadowed by a loop variable,

In the `coding-style` set. Report only.

**[no-php4-constructor](/docs/rules/lint/style/no-php4-constructor)**

Convert PHP4-style constructors to `__construct`.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[no-redundant-final](/docs/rules/lint/style/no-redundant-final)**

Removes `final` from methods where possible.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[no-redundant-final-const](/docs/rules/lint/style/no-redundant-final-const)**

Remove final from constants in classes defined as final

In the `dead-code` set. Safe fix.

**[no-redundant-yield-from](/docs/rules/lint/style/no-redundant-yield-from)**

Yield from array must be unpacked to series of yields.

In the `coding-style` set. Unsafe fix: it can change behaviour.

**[no-short-ternary](/docs/rules/lint/style/no-short-ternary)**

Detects the use of the shorthand ternary and elvis operators.

In the `coding-style` set. Report only. Upstream gates: `strictRules.disallowedShortTernary`.

**[no-side-effects-with-declarations](/docs/rules/lint/style/no-side-effects-with-declarations)**

Enforces that a PHP file either declares symbols (classes, functions,

Not in any set. Report only.

**[no-sleep-wakeup](/docs/rules/lint/style/no-sleep-wakeup)**

Replace __sleep()/__wakeup() with __serialize()/__unserialize().

In the `modernize` set. Unsafe fix: it can change behaviour. Gated by php-version.

**[no-sprintf-concat](/docs/rules/lint/style/no-sprintf-concat)**

Disallows string concatenation with the result of an `sprintf` call.

Not in any set. Report only.

**[no-unreachable-loop](/docs/rules/lint/style/no-unreachable-loop)**

Detects loops (for, foreach, while, do-while) that unconditionally break or return

In the `coding-style` set. Report only.

**[no-useless-printf](/docs/rules/lint/style/no-useless-printf)**

There must be no `printf` calls with only the first argument.

In the `coding-style` set. Unsafe fix: it can change behaviour.

**[no-useless-sprintf](/docs/rules/lint/style/no-useless-sprintf)**

Remove sprintf() calls with only the format argument.

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

**[no-variable-variable](/docs/rules/lint/style/no-variable-variable)**

Disallows variable variables (`$$name`).

In the `coding-style` set. Report only. Upstream gates: `strictRules.noVariableVariables`.

**[prefer-arrow-function](/docs/rules/lint/style/prefer-arrow-function)**

Anonymous functions with return as the only statement must use arrow functions.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[prefer-cast-over-intval](/docs/rules/lint/style/prefer-cast-over-intval)**

Replaces `intval`, `floatval`, `doubleval`, `strval` and `boolval` function calls with according type casting operator.

Not in any set. Unsafe fix: it can change behaviour.

**[prefer-cast-over-settype](/docs/rules/lint/style/prefer-cast-over-settype)**

Cast shall be used, not `settype`.

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

**[prefer-catch-name-from-type](/docs/rules/lint/style/prefer-catch-name-from-type)**

Type and name of catch exception should match

In the `coding-style` set. Safe fix.

**[prefer-class-constant](/docs/rules/lint/style/prefer-class-constant)**

Use `Foo::class` instead of class-name strings.

In the `modernize` and `coding-style` sets. Unsafe fix: it can change behaviour.

**[prefer-class-keyword-on-object](/docs/rules/lint/style/prefer-class-keyword-on-object)**

Replace `get_class` calls on object variables with class keyword syntax.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[prefer-compound-assignment](/docs/rules/lint/style/prefer-compound-assignment)**

Shorthand notation for operators should be used if possible.

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

**[prefer-create-from-timestamp](/docs/rules/lint/style/prefer-create-from-timestamp)**

Suggests `DateTimeImmutable::createFromTimestamp()` when a Unix timestamp is converted

Not in any set. Report only.

**[prefer-date-time-immutable](/docs/rules/lint/style/prefer-date-time-immutable)**

Class `DateTimeImmutable` should be used instead of `DateTime`.

Not in any set. Unsafe fix: it can change behaviour. Intent: suspicious.

**[prefer-dir-constant](/docs/rules/lint/style/prefer-dir-constant)**

Replaces `dirname(__FILE__)` expression with equivalent `__DIR__` constant.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[prefer-dirname-levels](/docs/rules/lint/style/prefer-dirname-levels)**

Replace nested dirname() calls with one call and a `$levels` argument.

In the `modernize` set. Unsafe fix: it can change behaviour. Gated by php-version.

**[prefer-early-continue](/docs/rules/lint/style/prefer-early-continue)**

Continue early instead of nesting the loop body in an if.

In the `early-return` set. Safe fix.

**[prefer-early-return](/docs/rules/lint/style/prefer-early-return)**

Return early instead of nesting the rest of the function in an if or else.

In the `code-quality` set. Safe fix.

**[prefer-early-return-over-prepared-value](/docs/rules/lint/style/prefer-early-return-over-prepared-value)**

Return early from each if instead of preparing a variable that is returned at the end.

In the `code-quality` set. Safe fix.

**[prefer-empty-string-compare](/docs/rules/lint/style/prefer-empty-string-compare)**

Compare with `''` instead of strlen() === 0.

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

**[prefer-generic-array-phpdoc](/docs/rules/lint/style/prefer-generic-array-phpdoc)**

PHPDoc `array<T>` type must be used instead of `T[]`.

Not in any set. Unsafe fix: it can change behaviour.

**[prefer-instanceof-stringable](/docs/rules/lint/style/prefer-instanceof-stringable)**

Detects the legacy pattern `is_object($x) && method_exists($x, '__toString')` and suggests

In the `coding-style` set. Report only.

**[prefer-list-phpdoc](/docs/rules/lint/style/prefer-list-phpdoc)**

PHPDoc `list` type must be used instead of `array` without a key.

Not in any set. Unsafe fix: it can change behaviour.

**[prefer-php-version-id](/docs/rules/lint/style/prefer-php-version-id)**

Changes use of call to version compare function to use of PHP version constant

In the `coding-style` set. Safe fix.

**[prefer-phpdoc-comment](/docs/rules/lint/style/prefer-phpdoc-comment)**

Comments with annotation should be docblock when used on structural elements.

Not in any set. Unsafe fix: it can change behaviour.

**[prefer-pow-operator](/docs/rules/lint/style/prefer-pow-operator)**

Converts `pow` to the `**` operator.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[prefer-property-over-local-getter](/docs/rules/lint/style/prefer-property-over-local-getter)**

Privatize getter of local property to property

In the `privatization` set. Unsafe fix: it can change behaviour.

**[prefer-random-int](/docs/rules/lint/style/prefer-random-int)**

Replaces `rand`, `srand`, `getrandmax` functions calls with their `mt_*` analogs or `random_int`.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[prefer-readonly-keyword](/docs/rules/lint/style/prefer-readonly-keyword)**

Converts readonly comment on classes to the readonly keyword.

In the `coding-style` set. Unsafe fix: it can change behaviour.

**[prefer-self-reference](/docs/rules/lint/style/prefer-self-reference)**

Inside class or interface element `self` should be preferred to the class name itself.

Not in any set. Unsafe fix: it can change behaviour.

**[prefer-short-ternary](/docs/rules/lint/style/prefer-short-ternary)**

Use the Elvis operator `?:` where possible.

Not in any set. Unsafe fix: it can change behaviour.

**[prefer-spread](/docs/rules/lint/style/prefer-spread)**

Replace `call_user_func_array()` with variadic

In the `coding-style` set. Safe fix.

**[prefer-static-private-method](/docs/rules/lint/style/prefer-static-private-method)**

Converts private methods to `static` where possible.

Not in any set. Unsafe fix: it can change behaviour.

**[prefer-str-contains](/docs/rules/lint/style/prefer-str-contains)**

Replace `strpos()` and `stripos()` calls with `str_starts_with()` or `str_contains()` if possible.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[prefer-variadic-param](/docs/rules/lint/style/prefer-variadic-param)**

Refactor `func_get_args()` in to a variadic param

In the `coding-style` set. Safe fix.

**[prefer-while-loop](/docs/rules/lint/style/prefer-while-loop)**

Suggests using a `while` loop instead of a `for` loop when the `for` loop does not have any

Not in any set. Report only.

**[require-assign-set-padding](/docs/rules/lint/style/require-assign-set-padding)**

Add extra space before new assign set

In the `coding-style` set. Safe fix.

**[require-create-from-format-bang](/docs/rules/lint/style/require-create-from-format-bang)**

The first argument of `DateTime::createFromFormat` method must start with `!`.

Not in any set. Unsafe fix: it can change behaviour.

**[require-final-class](/docs/rules/lint/style/require-final-class)**

All classes must be final, except abstract ones and Doctrine entities.

Not in any set. Unsafe fix: it can change behaviour.

**[require-final-internal-class](/docs/rules/lint/style/require-final-internal-class)**

Internal classes should be `final`.

Not in any set. Unsafe fix: it can change behaviour.

**[require-final-public-method](/docs/rules/lint/style/require-final-public-method)**

All `public` methods of `abstract` classes should be `final`.

Not in any set. Unsafe fix: it can change behaviour.

**[require-fopen-binary-flag](/docs/rules/lint/style/require-fopen-binary-flag)**

The flags in `fopen` calls must omit `t`, and `b` must be omitted or included consistently.

Not in any set. Unsafe fix: it can change behaviour.

**[require-fopen-flag-order](/docs/rules/lint/style/require-fopen-flag-order)**

Order the flags in `fopen` calls, `b` and `t` must be last.

Not in any set. Unsafe fix: it can change behaviour.

**[require-implode-separator](/docs/rules/lint/style/require-implode-separator)**

Function `implode` must be called with 2 arguments in the documented order.

In the `modernize` set. Unsafe fix: it can change behaviour.

**[require-namespace](/docs/rules/lint/style/require-namespace)**

Detects files that contain definitions (classes, interfaces, enums, traits, functions, or constants)

Not in any set. Report only.

**[require-naming-convention](/docs/rules/lint/style/require-naming-convention)**

Enforce naming conventions for classes, interfaces, traits, enums, functions, methods, properties, constants and variables (options per kind).

Not in any set. Report only.

**[require-ordered-traits](/docs/rules/lint/style/require-ordered-traits)**

Trait `use` statements must be sorted alphabetically.

Not in any set. Unsafe fix: it can change behaviour.

**[require-parent-visibility](/docs/rules/lint/style/require-parent-visibility)**

Make method visibility same as parent one

In the `coding-style` set. Safe fix.

**[require-phpdoc](/docs/rules/lint/style/require-phpdoc)**

Detects declarations that are missing a docblock.

Not in any set. Report only.

**[require-sorted-integer-keys](/docs/rules/lint/style/require-sorted-integer-keys)**

Detects array literals with integer keys that are not in ascending order.

Not in any set. Report only.

**[require-statement-padding](/docs/rules/lint/style/require-statement-padding)**

Add empty new line after different-type statements to improve code readability

In the `coding-style` set. Safe fix.

**[require-todo-reference](/docs/rules/lint/style/require-todo-reference)**

Require TODO and FIXME comments to reference a user or issue.

Not in any set. Report only.
