Finds the first object that the given method returns the given value
@param string $method
@param mixed $value
@param array $methodArgs
@return mixed
178112
public function findObjectByMethod($method, $value, array $methodArgs = array()) {
        foreach ($this as $object) {
            if (method_exists($object, $method)) {
                if ($value === call_user_func_array(array($object, $method), $methodArgs))
                    return $object;
            }
        }
    }
1330829
protected function saveParameter($method, $value)
    {
        if (!isset(static::$parameters[$method])) {
            static::$parameters[$method] = [];
        }

        if ($value instanceof Closure) {
            static::$parameters[$method]['callback'] = $value;
        } elseif (is_array($value)) {
            foreach ($value as $key => $attr) {
                static::$parameters[$method][$key] = $attr;
            }
        }else{
            static::$parameters[$method][] = $value;
        }

        return $this;
    }
687777
public function walk($method, $firstArg = null, $secondArg = null)
    {
        if ($method === 'purge') {
            $method = 'ban';
        }

        if ($firstArg === null && $secondArg === null) {
            $this->getVarnishPool()->$method();
        } elseif ($secondArg === null) {
            $this->getVarnishPool()->$method($firstArg);
        } else {
            $this->getVarnishPool()->$method($firstArg, $secondArg);
        }

        return $this;
    }
1322987
private function _checkAndReturnHasOne($method, $value)
    {
        $cls = get_called_class();
        if (array_key_exists($cls, self::$_has_one)
            && array_key_exists($method, self::$_has_one[$cls])
        ) {
            return $this->_resolveHasOne($method, $value);
        }
    }
1317229
function getMethod($methodName)
    {
        if (!$this->hasMethod($methodName))
            throw new \Exception(sprintf(
                'Method (%s) not found.'
                , $methodName
            ));

        if (isset($this->_t__methods[$methodName])) {
            ## from bind closure
            $methodCallable = $this->_t__methods[$methodName];
        } else {
            $bindTo = $this->getBindTo();
            $methodCallable = function() use($methodName, $bindTo) {
                return call_user_func_array([$bindTo, $methodName], func_get_args());
            };
        }

        ## bind it into latest bind object
        $methodCallable = \Closure::bind(
            $methodCallable
            , $this->getBindTo()
            , get_class($this->getBindTo())
        );

        return $methodCallable;
    }
87734
public function setMethod($method, $field = null)
    {
        $param = $this->buildParam('facet.method', $field);
        return $this->set($param, $method);
    }
684962
public function findMethod($methodName)
    {
        if (isset($this->knownMethodCache[$methodName])) {
            return $this->knownMethodCache[$methodName];
        }

        // Tokenize the source
        $tokens = token_get_all($this->code);
        $methodCode = '';

        // Some flags and counters
        $isInFunction = false;
        $functionBracketBalance = 0;
        $buffer = '';

        // Iterate over all tokens
        foreach ($tokens as $token) {
            // Single-character tokens.
            if (is_string($token)) {
                if (!$isInFunction) {
                    if ($token == '{' || $token == ';') {
                        // class-opening bracket or end of line
                        $buffer = '';
                    } else {
                        // comment or public|protected|private
                        $buffer .= $token;
                    }
                    continue;
                }
                $methodCode .= $token;
                if ($token == '{') {
                    // Increase the bracket-counter (not the class-brackets: `$isInFunction` must be true!)
                    $functionBracketBalance++;
                }
                if ($token == '}') {
                    // Decrease the bracket-counter (not the class-brackets: `$isInFunction` must be true!)
                    $functionBracketBalance--;
                    if ($functionBracketBalance == 0) {
                        if (strpos($methodCode, 'function ' . $methodName . '(') !== false) {
                            $this->knownMethodCache[$methodName] = $methodCode;

                            return $methodCode;
                        } else {
                            // If it's the closing bracket of the function, reset `$isInFunction`
                            $isInFunction = false;
                            $methodCode = '';
                            $buffer = '';
                        }
                    }
                }
            } else {
                // Tokens consisting of (possibly) more than one character.
                list($id, $text) = $token;
                switch ($id) {
                    case T_FUNCTION:
                        // If we encounter the keyword 'function', flip the `isInFunction` flag to
                        // true and reset the `buffer`
                        $isInFunction = true;
                        $methodCode .= $buffer . $text;
                        $buffer = '';
                        break;
                    default:
                        if ($isInFunction) {
                            $methodCode .= $text;
                        } else {
                            $buffer .= $text;
                        }
                        break;
                }
            }
        }

        // method not found
        $this->knownMethodCache[$methodName] = false;
        return false;
    }
446296
public final function getMethodArguments(string $method = null): ?array
    {
        return $method ? $this->methodArguments[$method] ?? null : $this->methodArguments;
    }
1355761
public function getMethod ($method)
	{
		
		// Get methods
		
		$this->getMethods ();
		
		// Loop through the methods
		
		foreach ($this->methods as $obj)
		{
			
			// If the method names match return 
			
			if (strtolower ($obj->get ('name')) == strtolower ($method))
			{
				return $obj;
			}
			
		}
		
		// Return FALSE
		
		return FALSE;
		
	}
604527
public function callArray($method, array $args = array())
    {
        //argument 1 must be a string
        Argument::i()->test(1, 'string');
        
        return call_user_func_array(array($this, $method), $args);
    }
933613
public function getArgsMethod(&$class, $method) {
        $params = [];

        $method = new \ReflectionMethod($class, $method);
        $parameters = $method->getParameters();

        foreach ($parameters as $parameter) {
            $object = $parameter->getClass();

            if ($object != null) {
                if (array_key_exists($object->name, $this->_alias)) {
                    $name = $this->_alias[$object->name];
                    array_push($params, self::$name());
                }
                else if (preg_match('#(Controller\\\Request\\\)#isU', $object->name)) {
                    array_push($params, Form::instance()->get($object));
                }
                else if (preg_match('#(Orm\\\Entity\\\)#isU', $object->name)) {
                    array_push($params, Orm::instance()->get($object));
                }
                else {
                    array_push($params, null);
                }
            }
            else {
                if (isset($_GET[$parameter->getName()])) {
                    array_push($params, $_GET[$parameter->getName()]);
                }
                else if (isset($_POST[$parameter->getName()])) {
                    array_push($params, $_POST[$parameter->getName()]);
                }
                else {
                    if (!$parameter->isOptional()) {
                        array_push($params, null);
                    }
                }
            }
        }

        return $params;
    }
465550
protected function findReturningTrue($method)
    {
        $args = func_get_args();

        $method = array_shift($args);

        foreach ($this->candidates as $candidate) {
            if (call_user_func_array([$candidate, $method], $args)) {
                return $candidate;
            }
        }

        return null;
    }
1367886
private function getFunctionArguments(\ReflectionFunctionAbstract $reflection, $value, $fields)
    {
        $arguments = [];
        if ($reflection->getNumberOfParameters() == 1) {
            $arguments[] = $value;
        } elseif ($reflection->getNumberOfParameters() == 2) {
            $arguments[] = $value;
            $arguments[] = $fields;
        }
        return $arguments;
    }
1200242
public static function callMethod($objectOrClass, string $methodName, ...$args)
    {
        $objectOrClass = self::getObject($objectOrClass);
        $closure =
            /**
             * @param string $methodName
             * @param array $args
             * @return mixed
             */
            function (string $methodName, ...$args) {
                if (\method_exists($this, $methodName)) {
                    return $this->$methodName(...$args);
                }
                throw new \RuntimeException(
                    Picklock::errorMessage($this, $methodName, true)
                );
            };
        return
            $closure->call($objectOrClass, $methodName, ...$args);
    }
1233481
public static function byObjectMethod($values, $method)
    {
        if (isset($values) && Inspector::isTraversable($values)) {
            if (is_array($values)) {
                $flat_values = array();
                $setter = 'setArrayValue';
            } else {
                $flat_values = new \stdClass();
                $setter = 'setObjectValue';
            }

            foreach ($values as $key => $value) {
                if (is_object($value) && method_exists($value, $method)) {
                    $flat_value = $value->{$method}();
                    static::$setter($flat_values, $key, $flat_value);
                } else {
                    static::$setter($flat_values, $key, $value);
                }
            }

            return $flat_values;
        }

        return $values;
    }
228308
public function method($methodName, $arg1/*, $arg2, $arg3, ...*/)
    {
        $args = array_slice(func_get_args(), 1);

        return $this->func(function($object) use ($methodName, $args) {
            return call_user_func_array([$object, $methodName], $args);
        });
    }
945109
protected function resolveArgs($methodCallArgs) {
		if (! isset($methodCallArgs[1])) {
			if ($this->arguments === null) {
				return $this->normalizeArgs([]);
			}
			
			return $this->normalizeArgs($this->arguments);
		}
		
		if (isset($methodCallArgs[2])) {
			array_shift($methodCallArgs);
			return $this->normalizeArgs($methodCallArgs);
		}
		
		return $this->normalizeArgs($methodCallArgs[1]);
	}