Get the relation constraint closure.

@param  string $method
@param  \Sofa\Hookable\Contracts\ArgumentBag $args
@return \Closure
424686
protected function getMappedWhereConstraint($method, ArgumentBag $args)
    {
        return function ($query) use ($method, $args) {
            call_user_func_array([$query, $method], $args->all());
        };
    }
1194525
protected function getRelationshipFromMethod($method)
    {
        $relation = $this->$method();

        if (! $relation instanceof Relation) {
            throw new LogicException(sprintf(
                '%s::%s must return a relationship instance.', static::class, $method
            ));
        }

        return tap($relation->getResults(), function ($results) use ($method) {
            $this->setRelation($method, $results);
        });
    }
745336
public function createHelper($method, $argv)
    {
        $helper = null;
        $helperClass = 'BackBee\Renderer\Helper\\'.$method;
        if (true === class_exists($helperClass)) {
            $this->helpers->set($method, new $helperClass($this, $argv));
            $helper = $this->helpers->get($method);
        }

        return $helper;
    }
270930
public function injectionClass($controller, $method, $args)
    {
        $dependentService = $this->dependentService;
        $refClass = $dependentService->newClass($controller);
        return $refClass->injection($method, $args);
    }
1112762
protected function call($method, $args)
    {
        $method = str_replace("_", ".", $method);
        $request = new $this->requestClass($this->apiKey, $method, $args, $this->secure);
        return $request->execute();
    }
63989
protected function payloadExec($method, $args = []) {
        $this->getPayloadInstance();
        if (method_exists($this->instance, $method)) {
            return $this->di->call([$this->instance, $method], $args);
        }
        return null;
    }
1337756
public function resolveStatic(string $name, string $method, ...$args)
    {
        return $this->resolve($name . '::' . $method, ...$args);
    }
690000
public function form($method='request', ...$args){
        if(is_array($method)) {
            $args = $method;
            $method = $this->method;
            //$this->form(['name','pass']);
        }
        else if($args && is_array($args[0])) {
            $args = $args[0];
            //$this->form('get',['name','pass']);
        }

        //$this->form('get','name','pass');
        $method === null and $method = $this->method;

        $form = Request::form($method,$args);

        $va = Pool::get(Validate::class);

        if(!$va || $va->scene('_form_',$args)->check($form)) {
            return $form;
        }

        return  Pool::get('controller')->__error($va->error, $va->field);
    }
1344621
public function trigger(Color $color, $method, $args)
    {
        if (is_callable(array($this, $method))) {
            array_unshift($args, $color);
            
            return call_user_func_array(array($this, $method), $args);
        }
        
        return null;
    }
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;
    }
994923
public function cacheCallback($method, $args, Closure $callback, $time = null)
    {
        // Cache disabled, just execute query & return result
        if ($this->skippedCache() === true) {
            return call_user_func($callback);
        }

        // Use the called class name as the tag
        $tag = get_called_class();

        return self::getCacheInstance()->tags(['repositories', $tag])->remember(
            $this->getCacheKey($method, $args, $tag),
            $this->getCacheExpiresTime($time),
            $callback
        );
    }
736897
public static function callProtectedMethod($object, $method, ...$args)
    {
        $refObject = new \ReflectionObject($object);
        $refProp   = $refObject->getMethod($method);
        $refProp->setAccessible(true);

        return $refProp->invokeArgs($object, $args);
    }
1244536
public function apply($method, array $args = [])
    {
        $result = new Map;
        $this->walk(function ($object, $key) use ($method, $args, $result) {
            $result[$key] = call_user_func_array([$object, $method], $args);
        });
        return $result;
    }
1074852
public static function invokeStaticMethod($class, $method, $args)
    {
        switch (count($args)) {
            case 0:
                return $class::$method();
            case 1:
                return $class::$method($args[0]);
            case 2:
                return $class::$method($args[0], $args[1]);
            case 3:
                return $class::$method($args[0], $args[1], $args[2]);
            case 4:
                return $class::$method($args[0], $args[1], $args[2], $args[3]);
            default:
                $rMethod = new \ReflectionMethod($class, $method);
                return $rMethod->invokeArgs(null, $args);
        }
    }
1082288
public function callWith($method, $args, $object, $returnRelation = false)
    {
        if (is_string($object)) {
            $object = Reflect::create($object);
        }

        /**
         * Check if $method prefix is listed in autocallPrefixes.
         */
        foreach ($this->autocallPrefixes as $prefix) {
            if (substr($method, 0, strlen($prefix)) === $prefix
                && strtoupper(substr($method, strlen($prefix), 1)) == substr($method, strlen($prefix), 1)
            ) {
                /**
                 * We are calling relation function without arguments: $entity->something();.
                 */
                $relationMethod = lcfirst(substr($method, strlen($prefix)));
                $relation = Reflect::method($object, $relationMethod, $args);
                // $relation = $object->{$relationMethod}();

                if (isset($args[0]) && ($args[0] instanceof Closure || is_only_callable($args[0]))) {
                    /**
                     * If callback was added, we run it.
                     * Now, this is a problem if we're making join because query was already merged.
                     * So, we'll call this magically and provide both - relation and query.
                     *
                     * @T00D00
                     */
                    if (in_array($prefix, ['join', 'leftJoin', 'innerJoin'])) {
                        $rightEntity = $relation->getRightEntity();
                        $oldEntityQuery = $rightEntity->getQuery();
                        $rightEntity->setQuery($relation->getQuery());
                        Reflect::call($args[0], [$relation, $relation->getQuery()]);
                        $rightEntity->setQuery($oldEntityQuery);
                    } else {
                        Reflect::call($args[0], [$relation, $relation->getQuery()]);
                    }
                }

                if ($prefix == 'leftJoin') {
                    $relation->leftJoin();
                }
                /**
                 * We'll call $entity->with($relation), $entity->join($relation) or $entity->required($relation), and return Relation;
                 */
                $return = $object->{$prefix == 'leftJoin' ? 'join' : $prefix}($relation);

                /**
                 * Then we return relation.
                 */
                return $returnRelation
                    ? $relation
                    : $return;
            }
        }

        if (!method_exists($object, $method)) {
            throw new Exception('Method ' . $method . ' does not exist in ' . get_class($object));
        }

        /**
         * Autoprefixes failed, return relation, probably?
         */
        $relation = Reflect::method($object, $method, $args);

        if (isset($args[0]) && ($args[0] instanceof Closure || is_only_callable($args[0]))) {
            Reflect::call($args[0], [$relation, $relation->getQuery()]);
        }

        return $relation;
    }
99609
private function getMethodArguments(\ReflectionMethod $method)
    {
        // ignore all query params
        $params = $this->paramReader->getParamsFromMethod($method);

        // check if a parameter is coming from the request body
        $ignoreParameters = [];
        if (class_exists(ParamConverter::class)) {
            $ignoreParameters = array_map(function ($annotation) {
                return
                    $annotation instanceof ParamConverter &&
                    'fos_rest.request_body' === $annotation->getConverter()
                        ? $annotation->getName() : null;
            }, $this->annotationReader->getMethodAnnotations($method));
        }

        // ignore several type hinted arguments
        $ignoreClasses = [
            Request::class,
            ParamFetcherInterface::class,
            ConstraintViolationListInterface::class,
            ParamConverter::class,
            MessageInterface::class,
        ];

        $arguments = [];
        foreach ($method->getParameters() as $argument) {
            if (isset($params[$argument->getName()])) {
                continue;
            }

            $argumentClass = $argument->getClass();
            if ($argumentClass) {
                $className = $argumentClass->getName();
                foreach ($ignoreClasses as $class) {
                    if ($className === $class || is_subclass_of($className, $class)) {
                        continue 2;
                    }
                }
            }

            if (in_array($argument->getName(), $ignoreParameters, true)) {
                continue;
            }

            $arguments[] = $argument;
        }

        return $arguments;
    }
1102049
protected function getMethodPartAndVerb($method)
    {
        preg_match($this->methodRule, $method, $matches);

        return empty($matches) ? false : array_slice($matches, 1);
    }