3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface IHookedDemo { public mixed $prop1 { get; } public mixed $prop2 { set; } public mixed $prop3 { get; set; } } abstract class HookedDemo { abstract public mixed $prop1 { get; } abstract public mixed $prop2 { set; } abstract public mixed $prop3 { get; set; } } class WithHooks { public mixed $prop1 { get => "always this string"; } public mixed $prop2 { set => strtolower($value); } public mixed $prop3 { get => $this->prop3; set => strtolower($value); } } class WithFinalHooks { public mixed $prop1 { final get => "always this string"; } public mixed $prop2 { final set => strtolower($value); } public mixed $prop3 { final get => $this->prop3; final set => strtolower($value); } } $classes = [ IHookedDemo::class, HookedDemo::class, WithHooks::class, WithFinalHooks::class, ]; foreach ( $classes as $clazz ) { echo "$clazz:\n"; $ref = new ReflectionClass( $clazz ); echo $ref; foreach ( [ 'prop1', 'prop2', 'prop3' ] as $prop ) { $propRef = new ReflectionProperty( $clazz, $prop ); echo $propRef; } echo "\n"; }
Output for 8.4.1 - 8.4.4
IHookedDemo: Interface [ <user> <iterateable> interface IHookedDemo ] { @@ /in/1fUfI 3-7 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [3] { Property [ public mixed $prop1 ] Property [ public mixed $prop2 ] Property [ public mixed $prop3 ] } - Methods [0] { } } Property [ public mixed $prop1 ] Property [ public mixed $prop2 ] Property [ public mixed $prop3 ] HookedDemo: Class [ <user> <iterateable> abstract class HookedDemo ] { @@ /in/1fUfI 8-12 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [3] { Property [ public mixed $prop1 ] Property [ public mixed $prop2 ] Property [ public mixed $prop3 ] } - Methods [0] { } } Property [ public mixed $prop1 ] Property [ public mixed $prop2 ] Property [ public mixed $prop3 ] WithHooks: Class [ <user> <iterateable> class WithHooks ] { @@ /in/1fUfI 13-24 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [3] { Property [ public mixed $prop1 ] Property [ public mixed $prop2 ] Property [ public mixed $prop3 ] } - Methods [0] { } } Property [ public mixed $prop1 ] Property [ public mixed $prop2 ] Property [ public mixed $prop3 ] WithFinalHooks: Class [ <user> <iterateable> class WithFinalHooks ] { @@ /in/1fUfI 25-36 - Constants [0] { } - Static properties [0] { } - Static methods [0] { } - Properties [3] { Property [ public mixed $prop1 ] Property [ public mixed $prop2 ] Property [ public mixed $prop3 ] } - Methods [0] { } } Property [ public mixed $prop1 ] Property [ public mixed $prop2 ] Property [ public mixed $prop3 ]
Output for 8.2.0 - 8.2.27, 8.3.0 - 8.3.17
Parse error: syntax error, unexpected token "{", expecting "," or ";" in /in/1fUfI on line 4
Process exited with code 255.

preferences:
157.35 ms | 1001 KiB | 7 Q