Invoke a non-public method

@param object $object
@param string $name
@param array  $args
@return mixed
355616
public function invokeMethod($object, $name, array $args = [])
    {
        $method = new ReflectionMethod($object, $name);
        $method->setAccessible(true);

        if (empty($args)) {
            return $method->invoke($object);
        }

        return $method->invokeArgs($object, $args);
    }
941298
public Object invokeMethod(String name, Object args) {
        final Object[] argsArr = args instanceof Object[] ? (Object[]) args : new Object[]{args};
        MetaMethod metaMethod = myMetaClass.getMetaMethod(name, argsArr);
        if (metaMethod != null) {
            // we have to use doMethodInvoke here instead of simply invoke,
            // because getMetaMethod may provide a method that can not be called
            // without further argument transformation, which is done only in 
            // doMethodInvoke
            return metaMethod.doMethodInvoke(this, argsArr);
        }

        if (argsArr.length == 2 && argsArr[0] instanceof Class && argsArr[1] instanceof Closure) {
            if (argsArr[0] == theClass)
                registerInstanceMethod(name, (Closure) argsArr[1]);
            else {
                registerSubclassInstanceMethod(name, (Class) argsArr[0], (Closure) argsArr[1]);
            }
            return null;
        }

        if (argsArr.length == 1 && argsArr[0] instanceof Closure) {
            registerInstanceMethod(name, (Closure) argsArr[0]);
            return null;
        }

        throw new MissingMethodException(name, getClass(), argsArr);
    }
807167
protected function callNativeFunction($name, $args, &$returnValue)
    {
        // try a lib function
        $name = $this->normalizeName($name);

        if (isset($this->userFunctions[$name])) {
            // see if we can find a user function
            list($f, $prototype) = $this->userFunctions[$name];
        } elseif (($f = $this->getBuiltinFunction($name)) && is_callable($f)) {
            $libName   = $f[1];
            $prototype = isset(static::$$libName) ? static::$$libName : null;
        } else {
            return false;
        }

        @list($sorted, $kwargs) = $this->sortArgs($prototype, $args);

        if ($name !== 'if' && $name !== 'call') {
            foreach ($sorted as &$val) {
                $val = $this->reduce($val, true);
            }
        }

        $returnValue = call_user_func($f, $sorted, $kwargs);

        if (! isset($returnValue)) {
            return false;
        }

        $returnValue = $this->coerceValue($returnValue);

        return true;
    }
309302
public function triggerSubEvent($name, $event, $args = [])
    {
        return $this->getDispatcher($name)->triggerEvent($event, $args);
    }
982988
protected function getResults($name, $args)
    {
        if (method_exists($this->scope, $name)) {
            return call_user_func_array(array($this->scope, $name), $args);
        }

        return $this->scope->call($name, $args);
    }
333552
public static function ForceGetProperty ($object, $name) {
		$ro = new \ReflectionObject($object);
		$rp = $ro->getProperty($name);
		$rp->setAccessible(true);
		return $rp->getValue($object);
	}
818186
public Object invoke (Object object, String methodName, Object... args) {
		return invoke(object, getIndex(methodName, args == null ? 0 : args.length), args);
	}
257518
public function singleton($name, $object)
    {
        if (IOC::hasSingleton($name)) {
            return IOC::singleton($name);
        } else {
            IOC::singleton($name, $object);
            return $object;
        }
    }
1329645
public function _call($name, $arguments)
    {
        $object = $this->getObject();
    	try
    	{
			$method = new \ReflectionMethod($object, $name);
		} catch (\Exception $e)
		{
		    if (method_exists($object, '__call'))
		    {
		        return call_user_func_array(array($object, '__call'), (array) $arguments);
		    } else
		    {
                throw new \Exception('Unable to invoke method ' . $name . ' on object of class ' . get_class($object));
		    }
		    return null;
		}

		$method->setAccessible(true);
		return $method->invokeArgs($object, $arguments);
    }
536046
public static function callMethod(
        string $name,
        ?object $object,
        array $arguments = [],
        ?string $classOverride = null
    ) {
        $method = self::getReflectionMethod($name, $object, $classOverride);
        $method->setAccessible(true);
        if (count($arguments) > 0) {
            return $method->invokeArgs($object, $arguments);
        }
        return $method->invoke($object);
    }
287001
public static function _callStatic($object, $name, $arguments)
    {
		if (is_object($object))
		{
			$object = ($object instanceof AltrEgo) ? $object->getObject() : $object;
		} elseif (!class_exists($object))
		{
			throw new \Exception('Static call (callStatic) to AltrEgo must be passed either an object or an accessible class name');
		}

        try
    	{
			$method = new \ReflectionMethod($object, $name);
			if ($method->isStatic())
			{
        		$method->setAccessible(true);
        		return $method->invokeArgs($object, (array) $arguments);
			}
		} catch (\Exception $e)
		{
		}
		throw new \Exception('Unable to call static method "' . $name . '" on class ' . get_class($object));
    }
1109805
public function helper($name, $args = [])
    {
        $args = func_get_args();
        $name = array_shift($args);
        if (isset($this->helpers[$name]) && is_callable($this->helpers[$name])) {
            return call_user_func_array($this->helpers[$name], $args);
        } elseif (($helper = [Helper::class, $name]) && is_callable($helper)) {
            return call_user_func_array($helper, $args);
        }

        throw new \RuntimeException(sprintf('undefined helper "%s" in %s line %d', $name, static::NAME, $this->getLineTrace()));
    }
26307
protected function invokeMethod($object, $method, array $arguments = array())
    {
        return $this->getReflectionMethod($object, $method)->invokeArgs($object, $arguments);
    }
1128292
protected function invokeMethod(&$object, $methodName, array $parameters = [])
    {
        return $this->getMethodInstance($object, $methodName)->invokeArgs($object, $parameters);
    }
610118
public function getCommand($name, array $args = [])
    {
        if (!$this->description->hasOperation($name)) {
            $name = ucfirst($name);
            if (!$this->description->hasOperation($name)) {
                throw new \InvalidArgumentException(
                    "No operation found named {$name}"
                );
            }
        }

        // Merge in default command options
        $args += $this->getConfig('defaults');

        return parent::getCommand($name, $args);
    }
1124428
public function callMacro(string $name, array $args)
    {
        if (isset($this->macros[$name])) {
            return call_user_func_array($this->macros[$name], $args);
        }
        throw new RuntimeException('There is no macro with the given name "'.$name.'" to call');
    }
967411
protected function _preCall(&$name, array &$args) {
        if (!method_exists($this, $name)) {
            $settings = $this->getCachedSettings($name);
            if (array_key_exists('reference', $settings['attrs']) || $settings['type'] == 'ReferenceMany') {
                $modelTable = array_key_exists('model', $settings['attrs']) ?
                        $settings['attrs']['model'] :
                        $settings['attrs']['reference']['model'];
                $columnValue = is_object($this->$name) ? $this->$name->getArrayCopy() : $this->$name;
                $nam = !is_array($columnValue) ? explode('__:DS:__', $columnValue) : $columnValue;
                $column = array_key_exists('column', $settings['attrs']) ?
                        $settings['attrs']['column'] :
                        $settings['attrs']['reference']['column'];
                $args['relateWhere'] = array();
                foreach ($nam as $val) {
                        $args['relateWhere'][] = array($column => $val);
                }
            }
            if ($modelTable || (!$modelTable && $modelTable = self::getModelTable(Util::camelTo_($name)))) {
                $model = is_array($modelTable) ?
                        new $modelTable[count($modelTable) - 1] :
                        new $modelTable;

                $name = $model->getTableName();
                if (!isset($args[0]['returnType']) || $args[0]['returnType'] == Table::RETURN_MODEL){
                    $relTable = $this->getConnection()->table($name);

                    $model->setConnection($this->getConnection());
                    $model->init($relTable);
                    $args['model'] = $model;
                }
            }
        }
    }