src/Di/ClassInspector.php
public function inspect($class, $method = '__construct')
    {
        if (is_string($class) && !class_exists($class)) {
            throw new ClassNotFoundException($class);
        }
        $dependencies = [];

        $r = new ReflectionClass($class);

        if (!$r->hasMethod($method)) {
            if ($method === '__construct') {
                return $dependencies;
            }
            throw new MethodNotFoundException($r->getName(), $method);
        }

        $rp = $r->getMethod($method)->getParameters();

        foreach ($rp as $p) {
            $prop = $p->name;

            $dependencies[$prop] = [];
            $dependencies[$prop]['optional'] = $p->isOptional();

            try {
                $class = $p->getClass();
                if (isset($class)) {
                    $dependencies[$prop]['class'] = $class->name;
                }
            } catch (\Exception $e) {
                $dependencies[$prop]['error'] = $e->getMessage();
            }
        }

        return $dependencies;
    }
public function inspect($class, $method = '__construct')
    {
        if (is_string($class) && !class_exists($class)) {
            throw new ClassNotFoundException($class);
        }
        $dependencies = [];

        $r = new ReflectionClass($class);

        if (!$r->hasMethod($method)) {
            if ($method === '__construct') {
                return $dependencies;
            }
            throw new MethodNotFoundException($r->getName(), $method);
        }

        $rp = $r->getMethod($method)->getParameters();

        foreach ($rp as $p) {
            $prop = $p->name;

            $dependencies[$prop] = [];
            $dependencies[$prop]['optional'] = $p->isOptional();

            try {
                $class = $p->getClass();
                if (isset($class)) {
                    $dependencies[$prop]['class'] = $class->name;
                }
            } catch (\Exception $e) {
                $dependencies[$prop]['error'] = $e->getMessage();
            }
        }

        return $dependencies;
    }
public function inspect ( $ class , $ method = '__construct' ) { if ( is_string ( $ class ) && ! class_exists ( $ class ) ) { throw new ClassNotFoundException ( $ class ) ; } $ dependencies = [ ] ; $ r = new ReflectionClass ( $ class ) ; if ( ! $ r -> hasMethod ( $ method ) ) { if ( $ method === '__construct' ) { return $ dependencies ; } throw new MethodNotFoundException ( $ r -> getName ( ) , $ method ) ; } $ rp = $ r -> getMethod ( $ method ) -> getParameters ( ) ; foreach ( $ rp as $ p ) { $ prop = $ p -> name ; $ dependencies [ $ prop ] = [ ] ; $ dependencies [ $ prop ] [ 'optional' ] = $ p -> isOptional ( ) ; try { $ class = $ p -> getClass ( ) ; if ( isset ( $ class ) ) { $ dependencies [ $ prop ] [ 'class' ] = $ class -> name ; } } catch ( \ Exception $ e ) { $ dependencies [ $ prop ] [ 'error' ] = $ e -> getMessage ( ) ; } } return $ dependencies ; }
Get class dependencies method.
By default, method is the constructor itself

@param mixed $class
@param string $method
@return array
@throws Exception
Get class dependencies method . By default method is the constructor itself