1.2.136. Class Could Be Readonly¶
When all properties are readonly, it is possible to set the option at the class. This feature was introduced in PHP 8.2.
<?php
// This class could be readonly
class x {
private readonly A $p;
private readonly A $p2;
}
?>
See also PHP 8.2: readonly Classes.
1.2.136.1. Connex PHP features¶
1.2.136.1.1. Suggestions¶
Remove readonly from the properties, and add it to the classes.
1.2.136.1.2. Specs¶
Short name |
Classes/CouldBeReadonly |
Rulesets |
|
Exakat since |
2.5.1 |
PHP Version |
With PHP 8.2 and more recent |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
Available in |