src/PhpToZephir/Converter/Dispatcher.php
private function dynamicConstruct($className)
    {
        $reflectionClass = new \ReflectionClass($className);

        if ($reflectionClass->getConstructor() === null) {
            return new $className();
        }
        $dependencies = array();

        foreach ($reflectionClass->getConstructor()->getParameters() as $nmb => $param) {
            $name = $param->getClass()->name;

            if ($name === 'PhpToZephir\Converter\Dispatcher') {
                $dependencies[] = $this;
            } elseif ($name === 'PhpToZephir\Logger') {
                $dependencies[] = $this->logger;
            } elseif ($name === 'PhpToZephir\ClassCollector') {
                $dependencies[] = $this->classCollector;
            } else {
                $dependencies[] = $this->dynamicConstruct($name);
            }
        }

        return $reflectionClass->newInstanceArgs($dependencies);
    }
private function dynamicConstruct($className)
    {
        $reflectionClass = new \ReflectionClass($className);

        if ($reflectionClass->getConstructor() === null) {
            return new $className();
        }
        $dependencies = array();

        foreach ($reflectionClass->getConstructor()->getParameters() as $nmb => $param) {
            $name = $param->getClass()->name;

            if ($name === 'PhpToZephir\Converter\Dispatcher') {
                $dependencies[] = $this;
            } elseif ($name === 'PhpToZephir\Logger') {
                $dependencies[] = $this->logger;
            } elseif ($name === 'PhpToZephir\ClassCollector') {
                $dependencies[] = $this->classCollector;
            } else {
                $dependencies[] = $this->dynamicConstruct($name);
            }
        }

        return $reflectionClass->newInstanceArgs($dependencies);
    }
@param string $className

@return object