Final Promoted Properties¶
Promoted properties could not be final until PHP 8.5.
PHP code¶
<?php
class x {
function __construct(
public final int $i
) {}
}
var_dump(new x(1));
?>
Before¶
PHP Fatal error: Cannot use the final modifier on a parameter
Fatal error: Cannot use the final modifier on a parameter
After¶
object(x)#1 (1) {
["i"]=>
int(1)
}
PHP version change¶
This behavior changed in 8.5