Run a registered function and return the result.

@param  string $function
@return mixed
@see \Foil\Kernel\Command::doRunIsolated()
@see \Foil\Kernel\Command::doRun()
171840
public function run($function)
    {
        $canEcho = ['stop', 'append', 'replace', 'section', 'block', 'endblock'];
        if (in_array($function, $canEcho, true)) {
            return call_user_func_array([$this, 'doRun'], func_get_args());
        }

        return call_user_func_array([$this, 'doRunIsolated'], func_get_args());
    }
987635
private function _run($command) 
	{
		if ($this->options['type'] === self::TYPE_PHP) {
			// Old Option: Run direct from terminal (doesn't like brackets too much).
			// $cmd = "php -r \"{$command}\"";

			// New Option: Save to temp file & run it.
			$this->savedFiles[] = $this->options['tmp-dir'] . 'async-tmp-' . time() . '.php';
			$result = file_put_contents(
				end($this->savedFiles),
				$this->_generateCode($command),
				LOCK_EX
			);

			if ($result !== false) {
				$cmd = "php " . end($this->savedFiles);
			}
			else {
				$cmd = "php --help";
			}
		}
		else {
			$cmd = $command;
		}

		if ($this->options['async']) {
			// This forks the process.
			// Helpful guide @ https://segment.com/blog/how-to-make-async-requests-in-php/
			$cmd .= ' > /dev/null 2>&1 &';
		}

		exec($cmd, $output, $exit);

		if ($this->options['debug']) {
			echo '<br />Command Run: ' . $cmd;
		}

		return $exit === 0;
	}
122020
private function run($callback)
    {
        $injects = [];
        $reflectionFunction = new \ReflectionFunction($callback);
        foreach ($reflectionFunction->getParameters() as $parameter) {
            if ($class = $parameter->getClass()) {
                $injects[] = app($class->name);
            }
        }

        return call_user_func_array($callback, $injects);
    }
369787
public function run()
    {
        return call_user_func(
            array_reduce(
                array_reverse($this->pipes),
                $this->createPipelineCallback(),
                function ($request) {
                    return ($this->callback === null) ? $request : call_user_func($this->callback, $request);
                }
            ),
            $this->request
        );
    }
1182158
public function processRequest($function = null)
    {
        if ($function) {
            $this->$function();
            $this->dispatchEvent(new AfterRequestProcessedEvent);
        } else {
            $sQAdd = $this->_getQuery();

            // formatting SQL queries
            $sQ = $this->_getDataQuery($sQAdd);
            $sCountQ = $this->_getCountQuery($sQAdd);

            $this->_outputResponse($this->_getData($sCountQ, $sQ));
        }
    }
1083311
public function registerPHPFunction($function)
    {
        if (is_array($function)) {
            $this->_registered_php_functions = array_unique(
              array_merge($this->_registered_php_functions, $function)
            );
        } else {
            $this->_registered_php_functions[] = $function;
        }
    }
91390
public static function call(string $function, Arguments $arguments)
    {
        $mocks = self::$mocks;

        $mocks = array_filter($mocks, function (MockedFunction $mock) use ($function) {
            return $mock->getFunctionName() === $function;
        });

        # First try functions that expect the exact arguments, and have expectations that haven't been called yet
        foreach ($mocks as $mock) {
            if ($mock->matchArguments($arguments)) {
                if ($mock->canCall()) {
                    return $mock->call($arguments);
                }
            }
        }

        # Then try functions that expect any arguments, and have expectations that haven't been called yet
        foreach ($mocks as $mock) {
            if ($mock->canAcceptArguments($arguments)) {
                if ($mock->canCall()) {
                    return $mock->call($arguments);
                }
            }
        }

        # Now try functions that expect the exact arguments (so we can give an accurate error message)
        foreach ($mocks as $mock) {
            if ($mock->matchArguments($arguments)) {
                return $mock->call($arguments);
            }
        }

        # Finally try functions that expect any arguments (just so we can throw an error as there are no expectations left)
        foreach ($mocks as $mock) {
            if ($mock->canAcceptArguments($arguments)) {
                return $mock->call($arguments);
            }
        }

        throw new ExpectationException("Unexpected argument list for {$function}({$arguments})");
    }
914533
public function aggregate($function, $columns = array('*'))
	{
		$this->aggregate = compact('function', 'columns');

		$previousColumns = $this->columns;

		$results = $this->get($columns);

		// Once we have executed the query, we will reset the aggregate property so
		// that more select queries can be executed against the database without
		// the aggregate value getting in the way when the grammar builds it.
		$this->aggregate = null;

		$this->columns = $previousColumns;

		if (isset($results[0]))
		{
			$result = array_change_key_case((array) $results[0]);

			return $result['aggregate'];
		}
	}
3679
public function run(array $args) {
		foreach($this->calls as $call) {
			if($call instanceof \SuperClosure\SerializableClosure)
				$call = $call->getClosure();
			$res = call_user_func_array($call, array_merge([$this], $args));
			$this->executed++;
			if($res !== null)
				return $res;
			if(!$this->continue)
				return;
		}
	}
891062
def run(
        self
        ):
        
        if self._function and not self._kwargs:
            return self._function()
        if self._function and self._kwargs:
            return self._function(**self._kwargs)
168958
public static function mapResult(callable $f)
    {
        return function (callable $handler) use ($f) {
            return function (
                CommandInterface $command,
                RequestInterface $request = null
            ) use ($handler, $f) {
                return $handler($command, $request)->then($f);
            };
        };
    }
831344
private function runIfNotCached($variableName, callable $function)
    {
        if (null === $this->{$variableName}) {
            // Only assign that don't returns
            if (null !== $result = $function()) {
                $this->{$variableName} = $result;
            }
        }
    }
44978
public function bind(callable $function)
    {
        // Theoretical here should be call like this:
        //  call_user_func($function, $this->run())
        // But this do not make things lazy, to cheat little bit
        // IO monad is returned and inside of it is little switch
        return static::of(function () use ($function) {
            $m = $function($this->run());

            return $m instanceof IO
                ? $m->run()
                : $m;
        });
    }
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);
    }
624998
protected function doRun($method, array $args=[]) {
		ob_start();
		$result = call_user_func_array($method, array_merge([$this], $args));
		$controllerBuffer =  ob_get_clean();

		if($result !== null)
			return $result;
		if($controllerBuffer)
			return $controllerBuffer;
		return null;
	}
604500
public static function run(string $function, array $args = [])
  {
    if (!class_exists(\App\Utils\Shortcuts::class)) {
      throw new ShortcutsClassNotFoundException;
    }

    $shortcuts = new \App\Utils\Shortcuts;

    if (method_exists($shortcuts, $function)) {
      return call_user_func_array([$shortcuts, $function], $args);
    }

    throw new UndefinedShortcutException("Shortcut '{$function}()' does not exist", $args);
  }
668513
public function executeFunction($string)
    {
        preg_match_all('/(.*)\((.*)\)/', $string, $matches);

        if (count($matches) > 0 && is_array($matches[0]) && count($matches[0]) > 0) {
            $function = $matches[1][0];

            return $function($this->removeQuotes($matches[2][0]));
        }

        return Constants::NOT_RESOLVED;
    }