3v4l.org

run code in 500+ PHP versions simultaneously
<?php enum TestEnum: string { /** Description about Case. */ case ABC = 'abc'; case XYZ = 'xyz'; /** @var string */ public const QWERTY = 'qwerty'; } $reflectionClass = new ReflectionClass(TestEnum::class); var_dump($reflectionClass->getProperties()[0]->getDocComment()); var_dump($reflectionClass->getProperties()[1]->getDocComment()); var_dump($reflectionClass->getReflectionConstants()[0]->getDocComment()); var_dump($reflectionClass->getReflectionConstants()[1]->getDocComment()); var_dump($reflectionClass->getReflectionConstants()[2]->getDocComment());
Output for 8.0.1 - 8.0.14
Parse error: syntax error, unexpected identifier "TestEnum" in /in/s1Lru on line 3
Process exited with code 255.
Output for 7.4.0 - 7.4.27
Parse error: syntax error, unexpected 'TestEnum' (T_STRING) in /in/s1Lru on line 3
Process exited with code 255.
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
bool(false) bool(false) string(30) "/** Description about Case. */" bool(false) string(18) "/** @var string */"

preferences:
29.46 ms | 1146 KiB | 12 Q