3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function foo(PDO $foo = null, array $bar, int $x = 0) { } } $method = new ReflectionMethod(A::class, "foo"); $params = $method->getParameters(); foreach ($params as $param) { $type = $param->getType(); var_dump($type->isBuiltin(), $type->allowsNull(), (empty($type) ? "" : $type . " ") . $param->name); print PHP_EOL . PHP_EOL; }
Output for 8.4.1 - 8.4.14, 8.5.0
Deprecated: A::foo(): Implicitly marking parameter $foo as nullable is deprecated, the explicit nullable type must be used instead in /in/int0g on line 4 bool(false) bool(true) string(8) "?PDO foo" bool(true) bool(false) string(9) "array bar" bool(true) bool(false) string(5) "int x"
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 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28
bool(false) bool(true) string(8) "?PDO foo" bool(true) bool(false) string(9) "array bar" bool(true) bool(false) string(5) "int x"
Output for 7.4.0 - 7.4.33
Deprecated: Function ReflectionType::__toString() is deprecated in /in/int0g on line 14 bool(false) bool(true) string(7) "PDO foo" Deprecated: Function ReflectionType::__toString() is deprecated in /in/int0g on line 14 bool(true) bool(false) string(9) "array bar" Deprecated: Function ReflectionType::__toString() is deprecated in /in/int0g on line 14 bool(true) bool(false) string(5) "int x"
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
bool(false) bool(true) string(7) "PDO foo" bool(true) bool(false) string(9) "array bar" bool(true) bool(false) string(5) "int x"
Output for 5.5.0 - 5.5.36, 5.6.0 - 5.6.28
Fatal error: Default value for parameters with a class type hint can only be NULL in /in/int0g on line 4
Process exited with code 255.

preferences:
182.64 ms | 414 KiB | 5 Q