@param  object $classInstance
@param  string $method
@param  array  $args          [optional]

@return mixed
556726
protected function callBeforeMethodHooks($classInstance, $method, array $args = [])
    {
        $method = self::getCalledMethod($method);

        $beforeMethodCallableName = 'before'.ucfirst($method);

        $hooks = isset($this->hooks[$beforeMethodCallableName]) ? $this->hooks[$beforeMethodCallableName] : [];

        $staticHooks = isset(self::$staticHooks['global'][$beforeMethodCallableName]) ?
            self::$staticHooks['global'][$beforeMethodCallableName] : [];

        $hooks = array_merge($hooks, $staticHooks);

        if ( ! empty($hooks)) {
            foreach ($hooks as $callable) {
                try {
                    $return = $this->callCallable($classInstance, $callable, $args, $method, false);
                } catch (CancelPropagationException $e) {
                    break;
                }

                if ($return !== null) {
                    return $return;
                }
            }
        }
    }
1055899
public function getMethodRequiredArgCount($class, string $method): int
    {
        $instance = new \ReflectionMethod($class, $method);
        $count = 0;
        // calculate method defined arguments count
        foreach ($instance->getParameters() as $arg) {
            if (!$arg->isOptional()) {
                $count++;
            }
        }

        return $count;
    }
316705
public static function fromMethod(
        string $method,
        string $class = null,
        bool $withParents = false
    ): array
    {
        if ($class) {

            try {

                $refMethod = new \ReflectionMethod($class, $method);
            }
            catch (\ReflectionException $e) {

                throw new Exception(
                    "Method '{$class}::{$method}' not found.",
                    Exception::METHOD_NOT_FOUND
                );
            }
        }
        else {

            try {

                $refMethod = new \ReflectionMethod($method);
            }
            catch (\ReflectionException $e) {

                throw new Exception(
                    "Method '{$method}' not found.",
                    Exception::METHOD_NOT_FOUND
                );
            }
        }

        $docComment = $refMethod->getDocComment();

        if ($withParents) {

            $refClass = $refMethod->getDeclaringClass();

            while (1) {

                if ($refClass = $refClass->getParentClass()) {

                    try {

                        $refMethod = $refClass->getMethod($method);
                    }
                    catch (\ReflectionException $e) {

                        break;
                    }

                    if (!$refMethod) {

                        continue;
                    }

                    if ($parentDoc = $refMethod->getDocComment()) {

                        $docComment = $docComment === false ?
                            $parentDoc :
                            "{$parentDoc}{$docComment}";
                    }
                }
                else {

                    break;
                }
            }
        }

        unset($refMethod, $refClass);

        if ($docComment === false) {

            return [];
        }

        return Parser::parseDocComment($docComment);
    }
329239
public function getMethod($classname, $method)
    {
        return $this->hasMethod($classname, $method)
            ? $this->methods[$classname . '::' . $method]
            : [];
    }
886287
public function callClassMethod($class, $method, ...$arguments)
	{
		$resolvedParameters = [];
		$reflectedClass = new ReflectionCLass($class);
		if (!$reflectedClass->hasMethod($method)) {
			throw new ReflectionException('Call to undefined method ' . $method);
		}

		$methodName = $method;
		$method = $reflectedClass->getMethod($method);
		$methodParameters = $method->getParameters();

		if (count($methodParameters) < 1) {
			return $method;
		}

		$resolvedParameters = array_map(function($param) use ($reflectedClass) {
			$type = $param->getType();

			if (preg_match("/(.*?)\\\/", $type)) {
				$type = (String) $type;
				return new $type;
			}

			if (!$param->isDefaultValueAvailable()) {
				return $param = '';
			}

			return $param->getDefaultValue();
			
		}, $methodParameters);

		$resolvedParameters = array_filter($resolvedParameters);
		$resolvedParameters = array_merge($resolvedParameters, $arguments);

		if ($methodName == '__construct') {
			return $reflectedClass->newInstanceArgs($resolvedParameters);
		}

		return $method->invokeArgs($class, $resolvedParameters);
	}
1343483
public function instanciate(string $class_name, ...$args): Interfaces\JavaObject
    {
        try {
            $java = new Java($class_name, ...$args);
        } catch (Pjb62BrokenConnectionException | Exception\InvalidUsageException $e) {
            PjbProxyClient::unregisterInstance();
            throw new BrokenConnectionException($e->getMessage(), $e->getCode(), $e);
        }

        return $java;
    }
524944
public function notifyObjects($method, array $args = []) {
        if ($this->_classes) {
            foreach ($this->_classes as $options) {
                if (!$options['callback'] || in_array($options['alias'], $this->_restricted)) {
                    continue;
                }

                $object = $this->getObject($options['alias']);

                if ($object && method_exists($object, $method)) {
                    call_user_func_array([$object, $method], $args);
                }
            }
        }

        return $this;
    }
1209451
protected function callAfterAllHooks($classInstance, $method)
    {
        // check $classInstance is the valid type of the class using the trait
        $method = self::getCalledMethod($method);

        $hooks = array_merge($this->hooks['afterAll'], self::$staticHooks['global']['afterAll']);

        if ( ! empty($hooks)) {
            $return = $this->callAllHookCallables($classInstance, $method, $hooks);

            if ($return !== null) {
                return $return;
            }
        }
    }
597078
public static function before($method, $self, &$args)
    {
        if (!Suite::registered()) {
            return false;
        }

        list($class, $name) = explode('::', $method);

        $lsb = is_object($self) ? get_class($self) : $self;

        if (!Suite::registered($lsb) && !Suite::registered($class)) {
            return false;
        }

        if ($name === '__call' || $name === '__callStatic') {
            $name = array_shift($args);
            $args = array_shift($args);
        }

        return static::_stubbedMethod($lsb, $self, $class, $name, $args);
    }
107526
public function setOptionsObject($method, $args)
    {
        // All options are stored as a child namespace so the below is possible
        $class = get_class($this->client) . "\\" . ucfirst($method);

        // If there is no array passed to the function just return the object
        if (!is_array($args[0]) || count($args[0]) === 0) {
            return new $class;
        }

        $optionClass = new $class;

        foreach ($args[0] as $key => $val) {
            $setterMethod = str_replace(' ', '', ucwords(str_replace('_', ' ', $key)));
            if (method_exists($optionClass, 'set' . $setterMethod)) {
                $optionClass->{'set' . $setterMethod}($val);
            }
        }

        $this->_options[$method] = $optionClass;

        return $optionClass;
    }
357057
public static function getInstance(...$args)
    {
        if(static::isChildClassSingleton())
        {
            $className = static::class;
            if(!isset(static::$instances[$className]))
            {
                static::$instances[$className] = new static(...$args);
            }
            return static::$instances[$className];
        }
        else
        {
            if(null === static::$instance)
            {
                static::$instance = new static(...$args);
            }
            return static::$instance;
        }
    }
841820
function filter_call ($instance, $method, ...$args)
  {
    if (is_object ($instance)) {
      if (is_object ($instance) && method_exists ($instance, $method)) return $instance->$method (...$args);
      if (isset($instance[$method]) && is_callable ($instance[$method])) {
        $m = $instance[$method];
        return $m(...$args);
      }
    }
    return null;
  }
236657
public function resolveMethod($class, $method, array $args = [])
    {
        if ( ! is_object($class)) {
            throw new Exception('Container::makeMethod except a object as the first parameter!');
        }

        $reflectionMethod = new ReflectionMethod($class, $method);
        $dependencies = $this->getMethodDependencies($reflectionMethod, $args);

        return $reflectionMethod->invokeArgs($class, $dependencies);
    }
666365
protected function _methodInjection(
        $instance, MethodInjection $method, ReflectionClass $classReflection)
    {

        $methodReflection = $classReflection->getMethod($method->getMethodName());
        $args = $this->_getMethodParameters($method, $methodReflection);
        $methodReflection->invokeArgs($instance, $args);
    }
922120
public function _call($instance, $method, $arguments = [])
    {
        if (method_exists($instance, $method)) {
            return call_user_func_array([$instance, $method], $arguments);
        }
    }
349472
public static function getInstance($name, ...$args)
    {
        if (empty(static::$instances[$name])) {
            static::$instances[$name] = new static(...$args);
        }

        return static::$instances[$name];
    }
600173
public function invoke(Interfaces\JavaType $javaObject = null, string $method, array $args = [])
    {
        try {
            return $this->pjbProxyClient->invokeMethod($javaObject, $method, $args);
        } catch (Pjb62BrokenConnectionException | Exception\InvalidUsageException $e) {
            PjbProxyClient::unregisterInstance();
            throw new BrokenConnectionException($e->getMessage(), $e->getCode(), $e);
        }
    }