3v4l.org

run code in 300+ PHP versions simultaneously
<?php use App; use Logger; class App { } class Logger { } class MyClass { public function __construct(App $app, Logger $log) { } } $method = new ReflectionMethod(MyClass::class, '__construct'); $parameters = $method->getParameters(); var_dump($parameters); foreach($parameters as $param) { try{ var_dump($param->getClass()); } catch (Exception $e) { var_dump($e->getMessage()); } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: The use statement with non-compound name 'App' has no effect in /in/46J8U on line 3 Warning: The use statement with non-compound name 'Logger' has no effect in /in/46J8U on line 4 array(2) { [0]=> object(ReflectionParameter)#2 (1) { ["name"]=> string(3) "app" } [1]=> object(ReflectionParameter)#3 (1) { ["name"]=> string(3) "log" } } Deprecated: Method ReflectionParameter::getClass() is deprecated in /in/46J8U on line 29 object(ReflectionClass)#4 (1) { ["name"]=> string(3) "App" } Deprecated: Method ReflectionParameter::getClass() is deprecated in /in/46J8U on line 29 object(ReflectionClass)#4 (1) { ["name"]=> string(6) "Logger" }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: The use statement with non-compound name 'App' has no effect in /in/46J8U on line 3 Warning: The use statement with non-compound name 'Logger' has no effect in /in/46J8U on line 4 array(2) { [0]=> object(ReflectionParameter)#2 (1) { ["name"]=> string(3) "app" } [1]=> object(ReflectionParameter)#3 (1) { ["name"]=> string(3) "log" } } Deprecated: Method ReflectionParameter::getClass() is deprecated in /in/46J8U on line 29 object(ReflectionClass)#4 (1) { ["name"]=> string(3) "App" } Deprecated: Method ReflectionParameter::getClass() is deprecated in /in/46J8U on line 29 object(ReflectionClass)#4 (1) { ["name"]=> string(6) "Logger" }
Output for 7.1.7, 7.3.24 - 7.3.33, 7.4.12 - 7.4.33
Warning: The use statement with non-compound name 'App' has no effect in /in/46J8U on line 3 Warning: The use statement with non-compound name 'Logger' has no effect in /in/46J8U on line 4 array(2) { [0]=> object(ReflectionParameter)#2 (1) { ["name"]=> string(3) "app" } [1]=> object(ReflectionParameter)#3 (1) { ["name"]=> string(3) "log" } } object(ReflectionClass)#4 (1) { ["name"]=> string(3) "App" } object(ReflectionClass)#4 (1) { ["name"]=> string(6) "Logger" }

preferences:
116.54 ms | 403 KiB | 119 Q