Run some code using the previous provided ini settings.

@param callable $callable $the code to run
@param mixed ...$params Any parameters to pass to the callable

@return mixed The result of the callable
331861
public function call(callable $callable, ...$params)
    {
        foreach ($this->settings as $key => $value) {
            $this->ini->set($key, $value);
        }

        $result = null;
        $exception = null;
        try {
            $result = $callable(...$params);
        } catch (\Throwable $e) {
            $exception = $e;
        }

        $this->ini->cleanup();

        if ($exception) {
            throw $exception;
        }

        return $result;
    }
269268
public static function run( Callable $callable ) {

		try {

			// catch fatal errors
			register_shutdown_function(['\\yolk\\exceptions\\Handler', 'checkFatal']);

			// use our error handler
			$error_handler = set_error_handler(static::$error_handler);

			$args = func_get_args();
			array_shift($args);

			$result = call_user_func_array($callable, $args);

			// restore the original error handler
			// if $error_handler is null then passing it to set_error_handler() will fail on PHP < v5.5
			// so we create an empty error handler thereby causing PHP to run it's own handler.
			set_error_handler($error_handler ?: function() { return false; });

			return $result;

		}
		catch( \Exception $e ) {
			static::exception($e);
		}

	}
342152
public function run()
    {
        $callable = $this->getCallable();
        if (is_callable($callable)) {
            return $callable($this->app, $this->output, $this->input, $this->parameter);
        }
        return false;
    }
776581
public function runWithParams($params)
    {
        $args = $this->controller->bindActionParams($this, $params);
        Log::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()' . __METHOD__);
        if (Zilf::$app->requestedParams === null) {
            Zilf::$app->requestedParams = $args;
        }

        return call_user_func_array([$this->controller, $this->actionMethod], $args);
    }
1251996
public function runWithBeforeAfterEvents(callable $callable)
    {
        $results = false;

        // Fire the task if the before event passes
        if ($this->fireEvent('before')) {
            $results = $this->timer->time($this, $callable);
            if ($results && !$this->wasHalted()) {
                $this->fireEvent('after');
            }
        }

        return $results;
    }
1064567
public static function fromCallable($callable)
    {
        if (!is_callable($callable))
        {
            throw new \InvalidArgumentException('You must provide a vaild PHP callable.');
        }
        elseif (is_string($callable) && strpos($callable, '::') > 0)
        {
            $callable = explode('::', $callable);
        }

        if (is_array($callable))
        {
            list($class, $method) = $callable;
            $reflection = new \ReflectionMethod($class, $method);
        }
        else
        {
            $reflection = new \ReflectionFunction($callable);
        }

        return new static($reflection);
    }
344195
static function resolveCallableWithArgs(callable $callable, $parameters)
    {
        if ($parameters instanceof \Traversable)
            $parameters = \Poirot\Std\cast($parameters)->toArray();


        $reflection       = self::makeReflectFromCallable($callable);
        $matchedArguments = self::resolveArgsForReflection($reflection, $parameters);

        if (!empty($parameters) && empty($matchedArguments))
            // In Case That Fun Has No Any Argument.
            // exp. func() { $args = func_get_args() ..
            $matchedArguments = $parameters;

        $callbackResolved = function() use ($callable, $matchedArguments) {
            return call_user_func_array($callable, $matchedArguments);
        };

        return $callbackResolved;
    }
927745
protected function executeCallable($callable, array $arguments = [])
    {
        // resolve a pseudo callable to real callable
        $call = $this->resolvePseudoCallable($callable);

        // execute the callable
        return call_user_func_array(
            $call,
            $this->resolveCallableArguments($call, $arguments)
        );
    }
1175910
public function _and(callable $callable = null)
    {
        $history = $this->whereNeedAddAndOrOr;
        $this->whereNeedAddAndOrOr = 1;

        if (is_callable($callable)) {
            $history === 0 && $this->whereNeedAddAndOrOr = 0;
            $this->lBrackets();
            call_user_func($callable, $this);
            $this->rBrackets();
        }

        return $this;
    }
284138
protected function callControllerCallable(callable $callable, array $parameters = [])
    {
        try {
            return $this->prepareResponse(
                $this->call($callable, $parameters)
            );
        } catch (HttpResponseException $e) {
            return $e->getResponse();
        }
    }
685889
public function setCallable($callable)
    {
        $matches = array();
        if (is_string($callable) && preg_match('!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!', $callable, $matches)) {
            $class = $matches[1];
            $method = $matches[2];
            $callable = function() use ($class, $method) {
                static $obj = null;
                if ($obj === null) {
                    $obj = new $class;
                }
                return call_user_func_array(array($obj, $method), func_get_args());
            };
        }

        if (!is_callable($callable)) {
            throw new \InvalidArgumentException('Route callable must be callable');
        }

        $this->callable = $callable;
    }
1247072
public function each($callable)
    {
        if ($this instanceof Iterator) {

            if (is_string($callable)) {
                foreach ($this as $obj) {
                    if ($obj->$callable() === false) {
                        break;
                    }
                }

                return $this;
            }

            foreach ($this as $obj) {
                if (call_user_func($callable, $obj) === false) {
                    break;
                }
            }

        } else {
            throw $this->exception('Calling each() on non-iterative object');
        }

        return $this;
    }
67583
public function invoke($callable, $arguments = []): self
    {
        // If one argument given for each iteration, create an array for it.
        if (!\is_array($arguments)) {
            $arguments = \array_fill(
                0,
                \count($this->getArray(), \COUNT_NORMAL),
                $arguments
            );
        }

        // If the callable has arguments, pass them.
        if ($arguments) {
            $array = \array_map($callable, $this->getArray(), $arguments);
        } else {
            $array = $this->map($callable);
        }

        return static::create(
            $array,
            $this->iteratorClass,
            false
        );
    }
266001
public function call(...$params)
    {
        $params = $params ?: $this->params;
        if(!$this->instanciated) {
            $this->instanciate();
        }

        return call_user_func_array($this->callable, $params);
    }
496815
protected function runCallable()
    {
        $parameters = $this->resolveMethodDependencies(
            $this->getParametersWithoutNulls(), new ReflectionFunction($this->action['uses'])
        );

        $callable = $this->action['uses'];

        return call_user_func_array($callable, $parameters);
    }
1198944
public static function create(iterable $iterable, $callable = null): ISeq
    {
        if ($callable !== null) {
            $callable = (new CallbackParser(InvalidArgumentException::class))->parseArrowFunction($callable);

            return new static(function () use ($iterable, $callable) {
                foreach ($iterable as $i) {
                    $item = $callable($i);

                    if (is_iterable($item)) {
                        yield from $item;
                    } else {
                        yield $item;
                    }
                }
            });
        }

        return new static($iterable);
    }
1112081
protected function performStringCallable($callable)
    {
        if ( ! preg_match('#^(?<class>[\\a-z0-9_]+)@(?<method>[a-z0-9_]+)$#i', $callable, $matches)) {
            throw new \UnexpectedValueException("Unable to process callable string '{$callable}'");
        }

        $instance = app($matches['class']);

        $result = $instance->{$matches['method']}($this);

        return $result === null ? true : (bool) $result;
    }