3v4l.org

run code in 300+ 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 8.0.19, 8.1.2 - 8.1.33, 8.2.9 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
array(2) { [0]=> string(25) "DocumentFieldCompanyTitle" [1]=> string(6) "string" }
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
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.

preferences:
138.61 ms | 408 KiB | 5 Q