Code Rules

Block constructs you don't want. Require what you do want. Set limits. Enforce naming conventions.

Code rules
The code rules editor. Select a rule on the left, configure it, and see the explanation on the right.

Rule types

There are three rule types:

Rule usage

A number of rules are almost always recommended.

However, there are also many arbitrary rules that make one wonder why they might be useful, for example: "Block throw exception".

These can be used when refactoring code where programmers have made unnecessary or incorrect use of a specific construct.

By blocking this construct, an overview can be shown of where it has been used.

After refactoring, a rule can also be turned off again; not all detected "errors" are actually errors.

All available rules

Description
File
Require name format
Require "declare(strict_types=1)"
Require file name and type name check
Block PHP close tag - ?>
Block functions declarations
Block anonymous function
Require keywords in short form
Namespace
Require name format
Block namespace declarations
Max segment count
Constant
Require name format
Require class const visibility declaration
Var
Require name format
Require object var naming based on class
Block use of globals
Block multi dimensional array
Class
Require name format
Require "abstract" prefix when abstract
Block anonymous class
Block use of constantes in class
Block use of interfaces
Block use of traits
Require parent class is abstract
Block use of stdClass
Require parentheses instantiating a class
Block new $class() statements
Max public method count
Max method count
Max public property count
Max property count
Max direct dependency count
Enum
Require name format
Require "enum" postfix
Interface
Require name format
Block interface declarations
Require "interface" postfix
Max method count
Trait
Require name format
Block trait declarations
Require "trait" postfix
Block use of other traits in trait
Max method count
Max property count
Max direct dependency count
Method
Require name format
Require visibility declaration
Block property get and set methods
Block static methods
Block magic __get
Block magic __set
Block magic __call
Block magic __isset
Block magic __unset
Block magic __invoke
Block magic __callStatic
Max var count
Max nesting depth
Max token count
Max line count
Function call
Block method chaining
Block null save operator a()?->b;
Block use of regexp functions
Block anonymous function as argument
Block function call as argument
Function argument
Require name format
Require argument naming based on class
Require argument type declaration in code
Block doccomment argument type declarations
Block anonymous argument types for public method
Max argument count
Function result
Require function result type declaration
Block doccomment result type declarations
Require $result as only name for return variabele
Block expression as return statement
Block anonymous result types for public method
Property
Require name format
Require property type declaration
Block promoted properties
Block doccomment property type declaration
Block anonymous type for property
Block static properties
Block var property declaration
String
Block multiline string
Block heredoc, nowdoc multiline string
Loop statement
Require brackets
Max loop condition complexity
If statement
Require brackets
Block assign in condition
Block arithmetic operator in condition
Block string operator in condition
Block ternary operator
Max if condition complexity
Error handling
Block throw exception
Block extended exception
Block try catch
Block trigger_error
Other
Block debug statements
Block print and echo statements
Block command execute statements