3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types = 1); abstract class Object {} interface iObjectID { public function getId(); public function setId(int $id = NULL); } trait tObjectID { /** * @TF: {column => id, type => int} * integer $id */ protected $id; public function getId() { return $this->id; } public function setId(int $id = NULL) { $this->id = $id; } } trait tObjectName { /** * @TF: {column => name, type => string} * string $name */ protected $name; public function getName(): string { return $this->name; } public function setName(string $name = NULL) { $this->name = $name; } } trait tObjectCoolurl { /** * @TF: {column => coolurl, type => string} * string $coolurl */ protected $coolurl; public function getCoolurl(): string { return $this->coolurl; } public function setCoolurl(string $coolurl = NULL) { $this->coolurl = $coolurl; } } class Gallery extends Object implements iObjectID { use tObjectID; use tObjectName; use tObjectCoolurl; } //Instantiate the reflection object $reflector = new ReflectionClass('Gallery'); // Now get all the properties from class A in to $properties array $properties = $reflector->getProperties(); var_dump($properties);
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Cannot use 'Object' as class name as it is reserved in /in/AWRtc on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
array(3) { [0]=> object(ReflectionProperty)#2 (2) { ["name"]=> string(2) "id" ["class"]=> string(7) "Gallery" } [1]=> object(ReflectionProperty)#3 (2) { ["name"]=> string(4) "name" ["class"]=> string(7) "Gallery" } [2]=> object(ReflectionProperty)#4 (2) { ["name"]=> string(7) "coolurl" ["class"]=> string(7) "Gallery" } }
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.21
Warning: Unsupported declare 'strict_types' in /in/AWRtc on line 2 Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/AWRtc on line 43
Process exited with code 255.

preferences:
175.54 ms | 402 KiB | 197 Q