public static function invokePrivateMethod($object, $method, $args = [], $class = null)
    {
        if (is_null($class)) {
            $class = $object;
        }

        $method = new \ReflectionMethod($class, $method);
        $method->setAccessible(true);

        return $method->invokeArgs($object, $args);
    }
public static function invokePrivateMethod($object, $method, $args = [], $class = null)
    {
        if (is_null($class)) {
            $class = $object;
        }

        $method = new \ReflectionMethod($class, $method);
        $method->setAccessible(true);

        return $method->invokeArgs($object, $args);
    }
public static function invokePrivateMethod ( $ object , $ method , $ args = [ ] , $ class = null ) { if ( is_null ( $ class ) ) { $ class = $ object ; } $ method = new \ ReflectionMethod ( $ class , $ method ) ; $ method -> setAccessible ( true ) ; return $ method -> invokeArgs ( $ object , $ args ) ; }
Invoke a private method of an object.

@param object $object
@param string $method
@param array $args
@param string|null $class
@return mixed
Invoke a private method of an object .