3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Demo { final public string $v; public function __construct( string $v ) { $this->v = $v; } } $d = new Demo( "FOO" ); var_dump( $d ); $r = new ReflectionProperty( Demo::class, 'v' ); var_dump( $r->isFinal() );
Output for 8.4.1 - 8.4.4
object(Demo)#1 (1) { ["v"]=> string(3) "FOO" } bool(true)
Output for 8.3.0 - 8.3.17
Fatal error: Cannot use the final modifier on a property in /in/Zus4v on line 4
Process exited with code 255.
Output for 8.2.0 - 8.2.27
Fatal error: Cannot declare property Demo::$v final, the final modifier is allowed only for methods, classes, and class constants in /in/Zus4v on line 4
Process exited with code 255.

preferences:
159.33 ms | 1002 KiB | 7 Q