3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Document { // Standard type public string $companyTitleStandard; // Union types public DocumentFieldCompanyTitle|string $companyTitleUnion; } $rp = new ReflectionProperty(Document::class, 'companyTitleUnion'); $unionTypes = array_map(function($type) { return $type->getName(); }, $rp->getType()->getTypes()); var_dump($unionTypes);
Output for 7.4.22
Parse error: syntax error, unexpected '|', expecting variable (T_VARIABLE) in /in/SlbXX on line 9
Process exited with code 255.
Output for 7.3.33
Parse error: syntax error, unexpected 'string' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /in/SlbXX on line 6
Process exited with code 255.
Output for 8.0.19 - 8.0.30, 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
array(2) { [0]=> string(25) "DocumentFieldCompanyTitle" [1]=> string(6) "string" }

preferences:
25.47 ms | 1143 KiB | 8 Q