This ruleset centralizes a large number of classic trap and pitfalls when writing PHP.
Total : 501 analysis
Adding Zero
Ambiguous Array Index
Multiple Index Definition
Empty Classes
Forgotten Visibility
Non Static Methods Called In A Static
Old Style Constructor
Static Methods Called From Object
Empty Function
Redeclared PHP Functions
Methods Without Return
Empty Interfaces
Incompilable Files
error_reporting() With Integers
Eval() Usage
Exit() Usage
Forgotten Whitespace
Iffectations
Multiply By One
@ Operator
Not Not
include_once() Usage
Strpos()-like Comparison
Throws An Assignement
var_dump()… Usage
__toString() Throws Exception
Non Ascii Variables
Used Once Variables
Bad Constants Names
Empty Traits
Use With Fully Qualified Name
Useless Instructions
Abstract Static Methods
Invalid Constant Name
Multiple Constant Definition
Wrong Optional Parameter
Use === null
$this Is Not An Array
One Variable String
Static Methods Can’t Contain $this
While(List() = Each())
Several Instructions On The Same Line
Multiples Identical Case
Switch Without Default
$this Belongs To Classes Or Traits
Nested Ternary
Non-constant Index In Array
Undefined Constants
Instantiating Abstract Class
Class, Interface, Enum Or Trait With Identical Names
Empty Try Catch
Undefined Classes
Htmlentities Calls
Undefined Class Constants
Used Once Variables (In Scope)
Undefined Functions
Deprecated PHP Functions
Dangling Array References
Queries In Loops
Var Keyword
Native Alias Functions Usage
Uses Default Values
Wrong Number Of Arguments
Hardcoded Passwords
Unresolved Classes
Useless Constructor
Implements Is For Interface
Use const
Unresolved Use
Undefined Parent
Undefined static:: Or self::
Accessing Private
Access Protected Structures
Parent, Static Or Self Outside Class
list() May Omit Variables
Or Die
Written Only Variables
Must Return Methods
Empty Instructions
Overwritten Exceptions
Foreach Reference Is Not Modified
Don’t Change Incomings
Compared Comparison
Useless Return
Unused Classes
Unpreprocessed Values
Undefined Properties
Short Open Tags
Strict Comparison With Booleans
Lone Blocks
$this Is Not For Static Methods
Global Usage
Logical Should Use Symbolic Operators
Could Use self
Catch Overwrite Variable
Deep Definitions
Repeated print()
Avoid Parenthesis With Language Construct
Objects Don’t Need References
Lost References
Constants Created Outside Its Namespace
Fully Qualified Constants
Never Used Properties
No Real Comparison
Should Use Local Class
No Direct Call To Magic Method
String May Hold A Variable
Echo With Concat
Unused Global
Useless Global
Preprocessable
Useless Final
Use Constant Instead Of Function
Useless Unset
Buried Assignation
No array_merge() In Loops
Useless Parenthesis
Unresolved Instanceof
Use PHP Object API
Unthrown Exception
Old Style __autoload()
Altering Foreach Without Reference
Use Pathinfo
Should Use Existing Constants
Hash Algorithms
No Parenthesis For Language Construct
No Hardcoded Path
No Hardcoded Port
Use Constant As Arguments
Implied If
Overwritten Literals
Assign Default To Properties
No Public Access
Should Chain Exception
Useless Interfaces
Undefined Interfaces
Double Instructions
Should Use Prepared Statement
Print And Die
Unchecked Resources
No Hardcoded Ip
Else If Versus Elseif
Unset In Foreach
Could Be A Static Variable
Multiple Class Declarations
Empty Namespace
Could Use Short Assignation
Useless Abstract Class
Static Loop
Pre-increment
Only Variable Returned By Reference
Indices Are Int Or String
Should Typecast
No Self Referencing Constant
No Direct Usage
Break Outside Loop
Avoid Substr() One
Double Assignation
Empty List
Useless Brackets
preg_replace With Option e
eval() Without Try
func_get_arg() Modified
Avoid get_class()
Silently Cast Integer
Timestamp Difference
Unused Parameter
Switch To Switch
Wrong Parameter Type
Wrong fopen() Mode
Negative Power
Already Parents Interface
Use random_int()
Can’t Extend Final
Ternary In Concat
Using $this Outside A Class
Undefined Trait
No Hardcoded Hash
Identical Conditions
Unkown Regex Options
No Choice
Common Alternatives
Logical Mistakes
Uncaught Exceptions
Same Conditions In Condition
Return True False
Useless Switch
Could Use __DIR__
Should Use Coalesce
Make Global A Property
If With Same Conditions
Throw Functioncall
Use Instanceof
Results May Be Missing
Always Positive Comparison
Empty Blocks
Throw In Destruct
Use System Tmp
Dependant Trait
Hidden Use Expression
Should Make Alias
Multiple Identical Trait Or Interface
Multiple Alias Definitions
Nested Ifthen
Cast To Boolean
Failed Substr() Comparison
Should Use Ternary Operator
Unused Returned Value
Modernize Empty With Expression
Use Positive Condition
Drop Else After Return
Use ::Class Operator
Don’t Echo Error
Useless Type Casting
No isset() With empty()
Useless Check
Bail Out Early
Don’t Change The Blind Var
Avoid Using stdClass
Too Many Local Variables
Illegal Name For Method
Long Arguments
Assigned Twice
No Boolean As Default
Forgotten Thrown
Multiple Alias Definitions Per File
__DIR__ Then Slash
self, parent, static Outside Class
Used Once Property
Property Used In One Method Only
No Need For Else
Strange Name For Constants
Too Many Finds
Should Use SetCookie()
Check All Types
Missing Cases In Switch
Repeated Regex
No Class In Global
Crc32() Might Be Negative
Could Use str_repeat()
Suspicious Comparison
Strings With Strange Space
No Empty Regex
Alternative Syntax Consistence
Randomly Sorted Arrays
Only Variable Passed By Reference
No Return Used
No Reference On Left Side
Implemented Methods Must Be Public
Mixed Concat And Interpolation
Too Many Injections
Could Make A Function
Forgotten Interface
Avoid Optional Properties
Mismatched Ternary Alternatives
Mismatched Default Arguments
Mismatched Typehint
Scalar Or Object Property
Assign And Lettered Logical Operator Precedence
No Magic Method With Array
Logical To in_array
Pathinfo() Returns May Vary
Multiple Type Variable
Is Actually Zero
Unconditional Break In Loop
Could Be Else
Next Month Trap
Printf Number Of Arguments
Ambiguous Static
Don’t Send $this In Constructor
No get_class() With Null
Maybe Missing New
Unknown Pcre2 Option
Parent First
Invalid Regex
Use Named Boolean In Argument Definition
Same Variable Foreach
Never Called Parameter
Identical On Both Sides
Identical Consecutive Expression
No Reference For Ternary
Unused Inherited Variable In Closure
Inclusion Wrong Case
Missing Include
Useless Referenced Argument
Possible Infinite Loop
Test Then Cast
Foreach On Object
Property Could Be Local
Too Many Native Calls
Don’t Unset Properties
Strtr Arguments
Missing Parenthesis
Callback Function Needs Return
Wrong Range Check
Can’t Instantiate Class
strpos() Too Much
Class-typed References
Weak Typing
Method Signature Must Be Compatible
Mismatch Type And Default
Check JSON
Don’t Mix ++
Can’t Throw Throwable
Abstract Or Implements
Incompatible Signature Methods
Ambiguous Visibilities
Undefined ::class
Assert Function Is Reserved
Could Be Abstract Class
Continue Is For Loop
Must Call Parent Constructor
Undefined Variable
Undefined Insteadof
Method Collision Traits
Class Could Be Final
Only Variable For Reference
Wrong Access Style to Property
Invalid Pack Format
Repeated Interface
Don’t Read And Write In One Expression
Should Yield With Key
Useless Method Alias
Method Could Be Static
Possible Missing Subpattern
Assign And Compare
Variable Is Not A Condition
Insufficient Typehint
Type Must Be Returned
Clone With Non-Object
Check On __Call Usage
Avoid option arrays in constructors
Already Parents Trait
Trait Not Found
Casting Ternary
Concat Empty String
Concat And Addition
Useless Argument
No Append On Source
Memoize MagicCall
Unused Class Constant
Infinite Recursion
Null Or Boolean Arrays
Dependant Abstract Classes
Wrong Type Returned
Overwritten Source And Value
Avoid mb_dectect_encoding()
array_key_exists() Works On Arrays
Class Without Parent
Scalar Are Not Arrays
array_merge() And Variadic
Implode() Arguments Order
strip_tags() Skips Closed Tag
No Spread For Hash
Max Level Of Nesting
Should Use Explode Args
Use array_slice()
Too Many Array Dimensions
Coalesce And Concat
Comparison Is Always The Same
Incompatible Signature Methods With Covariance
Interfaces Is Not Implemented
No Literal For Reference
Interfaces Don’t Ensure Properties
Non Nullable Getters
Too Many Dereferencing
Can’t Implement Traversable
Is_A() With String
Mbstring Unknown Encoding
Mbstring Third Arg
Merge If Then
Wrong Type With Call
Not Equal Is Not !==
Don’t Collect Void
Wrong Typed Property Default
Implicit Nullable Type
Fn Argument Variable Confusion
Missing Abstract Method
Undefined Constant Name
Using Deprecated Method
Cyclic References
Double Object Assignation
Wrong Argument Type
Mismatch Properties Typehints
No Need For Triple Equal
Array_merge Needs Array Of Arrays
Wrong Type For Native PHP Function
Catch With Undefined Variable
Swapped Arguments
Different Argument Counts
Unknown Parameter Name
Missing Some Returntype
Don’t Pollute Global Space
Mismatch Parameter Name
Multiple Declaration Of Strict_types
Array_Fill() With Objects
Modified Typed Parameter
Assumptions
Unsupported Types With Operators
Wrong Attribute Configuration
Cancelled Parameter
Constant Typo Looks Like A Variable
Array_Map() Passes By Value
Missing __isset() Method
Modify Immutable
Cannot Use Static For Closure
Only First Byte
Inherited Property Type Must Match
No Object As Index
Htmlentities Using Default Flag
Wrong Argument Name With PHP Function
Duplicate Named Parameter
PHP Native Class Type Compatibility
Missing Attribute Attribute
No Null For Native PHP Functions
No Referenced Void
PHP Native Interfaces and Return Type
New Functions In PHP 8.1
Never Keyword
False To Array Conversion
Float Conversion As Index
Cannot Call Static Trait Method Directly
Overwritten Foreach Var
Recycled Variables
Check Division By Zero
Don’t Reuse Foreach Source
Unreachable Method
Unfinished Object
Undefined Enumcase
Don’t Add Seconds
Use Constants As Returns
Identical Variables In Foreach
Can’t Overwrite Final Constant
Unsupported Operand Types
version_compare Operator
Do Not Cast To Int
Could Be Spaceship
Unused Enumeration Case
Useless Null Coalesce
Throw Raw Exceptions
Implicit Conversion To Int
Use Same Types For Comparisons
Wrong Locale
Parent Is Not Static
No Magic Method For Enum
No Readonly Assignation In Global
Overload Existing Names
Retyped Reference
Wrong Type With Default
Sprintf Format Compilation
Invalid Date Scanning Format
Same Name For Property And Method
DateTimeImmutable Is Not Immutable
No Default For Referenced Parameter
Clone Constant
Could Inject Parameter
Unused Public Methods
Mbstring Unknown Encodings
Coalesce And Ternary Operators Order
Useless Assignation Of Promoted Property
Empty Loop
Useless Method
Weak Type With Array
No Empty String With explode()
Array Access On Literal Array
Double Checks
strpos() With Integers
Missing Assignation In Branches
No Valid Cast
Misused Yield
No Null For Index
Useless Try
Converted Exceptions
Method Is Not An If
Default Then Discard
Identical Case In Switch
StandaloneType True False Null
Could Use Yield From
Append And Assign Arrays
Static Methods Cannot Call Non-Static Methods
Trait Is Not A Type
Cannot Use Append For Reading
Void Is Not A Reference
Can’t Call Generator
Non Integer Nor String As Index
Cant Instantiate Non Class
Check After Null Safe Operator
No Null With Null Safe Operator
Invalid Cast
New Object Then Immediate Call
Wrong Precedence In Expression
Nested Match
Useless Short Ternary
Empty Json Error
Useless Coalesce
Count() Is Not Negative
Exit Without Argument
Strpos() Less Than One
Static Inclusions
Constant Used Only Once
Short name
Analyze
Available in
Entreprise Edition, Community Edition, Exakat Cloud
Reports
Ambassador, Diplomat
GETTING STARTED
USER GUIDE
REFERENCE GUIDE
ADMINISTRATOR GUIDE
OTHERS