3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Controller { public function __construct(B $b) { $this->b = $b; } } class B { public function __construct(C $c) { $this->c = $c; } } class C { public function __construct(Guzzle $guzzle) { $this->guzzle = $guzzle; } } class Guzzle { } $getReflectedConstructorParams = function($className) { return (new \ReflectionClass($className))->getConstructor()->getParameters(); }; $className = 'Controller'; $graph = [$className]; // I hate recursion, there's much better ways while (!empty($getReflectedConstructorParams($className))) { $className = $getReflectedConstructorParams($className); $graph[] = $className; } var_dump($className);
Output for 7.0.0 - 7.2.0
Notice: Array to string conversion in /in/Oa9Wk on line 9 Fatal error: Uncaught ReflectionException: Class Array does not exist in /in/Oa9Wk:9 Stack trace: #0 /in/Oa9Wk(9): ReflectionClass->__construct('Array') #1 /in/Oa9Wk(16): {closure}(Array) #2 {main} thrown in /in/Oa9Wk on line 9
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Notice: Array to string conversion in /in/Oa9Wk on line 9 Fatal error: Uncaught exception 'ReflectionException' with message 'Class Array does not exist' in /in/Oa9Wk:9 Stack trace: #0 /in/Oa9Wk(9): ReflectionClass->__construct('Array') #1 /in/Oa9Wk(16): {closure}(Array) #2 {main} thrown in /in/Oa9Wk on line 9
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Fatal error: Can't use function return value in write context in /in/Oa9Wk on line 16
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/Oa9Wk on line 9
Process exited with code 255.