<?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);
Fatal error: Uncaught TypeError: ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given 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.
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 7.3.32 - 7.3.33
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.5.35, 5.6.8 - 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.