1.2.814. No Magic Method For Enum¶
Enumeration cannot have magic methods, nor a constructor. Enumeration cases are created as needed, and magic methods are interfering with the default behavior of enumerations.
<?php
enum a {
function __construct($a) {}
}
?>
See also Enumeration Methods.
1.2.814.2. Connex PHP features¶
1.2.814.2.1. Suggestions¶
Remove the method
1.2.814.2.2. Specs¶
Short name |
Enums/NoMagicMethod |
Rulesets |
All, Analyze, Changed Behavior, Class Review, LintButWontExec |
Exakat since |
2.4.2 |
PHP Version |
With PHP 8.1 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Note |
This issue may lint but will not run |
Available in |