Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Final Promoted Properties

Promoted properties could not be final. Since PHP 8.5, it is possible to use final in promoted properties definition.

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.

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat