Cannot use the final modifier on a parameter¶
Description¶
The final option is not available for promoted properties, until PHP 8.5. Until then, the property shall be final but not promoted, or it has to be declared the traditional way.
Example¶
<?php
class X {
function __construct(
public final int $i
) {}
}
?>
Solutions¶
Upgrade to PHP 8.5 or more recent.
Remove the final property from the promoted property.
Create the property in the class body.
Changed Behavior¶
This error may appear following an evolution in behavior, in previous versions. See ` <https://php-changed-behaviors.readthedocs.io/en/latest/behavior/.html>`_.