3v4l.org

run code in 300+ PHP versions simultaneously
<?php class PropTypeTest { public int $int; public string $string; public array $arr; public callable $callable; public stdClass $std; public OtherThing $other; public $mixed; } $reflector = new ReflectionClass(PropTypeTest::class); foreach ($reflector->getProperties() as $name => $property) { if ($property->hasType()) { printf("public %s $%s;\n", $property->getType(), $property->getName()); } else printf("public $%s;\n", $property->getName()); }
Output for 5.5.0 - 5.5.33, 5.6.0 - 5.6.19, 7.0.0 - 7.0.4
Parse error: syntax error, unexpected 'int' (T_STRING), expecting variable (T_VARIABLE) in /in/RepdN on line 4
Process exited with code 255.

preferences:
189.26 ms | 1395 KiB | 65 Q