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

lint/classes

Class, interface, trait and enum declarations and their members. Also in format (8) and analyse (64).

add-stringable

A class that implements the __toString() method must explicitly implement the Stringable interface.

In the modernize set. Safe fix.

no-explicit-constructor-call

Disallows calling __construct() on an existing object outside a constructor.

In the code-quality set. Report only. Intent: suspicious. Upstream gates: strictRules.illegalConstructorMethodCall.

no-null-property-default

Properties MUST not be explicitly initialised with null except when they have a type declaration (PHP 7.4).

In the dead-code set. Safe fix.

no-protected-constant-in-final

Change protected constant to private if possible

In the privatization set. Safe fix.

no-protected-in-final

Converts protected variables and methods to private where possible.

In the privatization set. Safe fix.

no-protected-method-in-final

Change protected class method to private if possible

In the privatization set. Safe fix.

no-protected-property-in-final

Change property to private if possible

In the privatization set. Safe fix.

no-redundant-readonly

Removes redundant readonly from properties in readonly classes.

In the dead-code set. Safe fix.

no-static-constructor-call

Disallows calling a constructor statically (Foo::__construct()) outside a child class’s constructor.

In the code-quality set. Report only. Intent: suspicious. Upstream gates: strictRules.illegalConstructorMethodCall.

no-underscore-class

Detects class, interface, trait, or enum declarations named _.

In the modernize set. Report only.

no-unset-on-property

Properties should be set to null instead of using unset.

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

prefer-new-self

Change new static() to new self() in a final class

In the code-quality set. Safe fix.

prefer-self-in-final

Inside an enum or final/anonymous class, self should be preferred over static.

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

require-class-matches-file

Classes must be in a path that matches their namespace, be at least one namespace deep and the class name should match the file name.

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

require-member-order

Orders the elements of classes/interfaces/traits/enums.

In the coding-style set. Safe fix.

Last updated on

Was this page helpful?