Create an Alias of a function check if it's exist
@param $aliasName
@param $callback
@return array
184574
public static function alias($aliasName, $callback)
    {
        $err = false;

        if (function_exists($aliasName)) {
            $err = 'This function already' . $aliasName . ' exists';
        }

        if (!is_callable($callback, false, $realfunc)) {
            $err = $callback.' is not callable';
        }

        if($err === false){
            try {
                $bodyFunc = 'function ' . $aliasName . '() {
                    $args = func_get_args();
                    return call_user_func_array("' . $realfunc . '", $args);
                }';

                eval($bodyFunc);

                return array('result' => true, 'msg' => "function $aliasName created from $callback");

            } catch (\Exception $e) {

                $trace = debug_backtrace();

                $msg = sprintf(
                    '%s(): %s in %s on line %d',
                    $trace[0]['function'],
                    $err,
                    $trace[0]['file'],
                    $trace[0]['line']
                );

                trigger_error($msg,
                    E_USER_WARNING
                );

                return array('result' => false, 'msg' => $err);
            }

        } else {
            return array('result' => false, 'msg' => $err);
        }
    }
56106
protected function makeAbilityCallback($callback)
    {
        return function ($component) use ($callback) {
            if (is_callable($callback)) {
                return $callback($component);
            }
            if (is_string($callback)) {
                list($class, $method) = Str::parseCallback($callback);

                return call_user_func([$this->app->make($class), $method], $component);
            }
        };
    }
729840
public function of(string $name, callable $callback = null): BuilderContract
    {
        if (! isset($this->names[$name])) {
            $this->names[$name] = $this->make($callback);
            $this->names[$name]->name = $name;
        }

        return $this->names[$name];
    }
584266
protected function doQuery($callback)
    {
        $previousMethod = debug_backtrace(null, 2)[1];
        $methodName = $previousMethod['function'];
        $arguments = $previousMethod['args'];

        $result = $this->doBeforeQuery($callback, $methodName, $arguments);

        return $this->doAfterQuery($result, $methodName, $arguments);
    }
148530
public function getJoinColumn(callable $callback = null)
    {
        $joinColumn = reset($this->joinColumns);

        if (is_callable($callback)) {
            $callback($joinColumn);
        }

        return $joinColumn;
    }
523349
protected function createClassesCallback($callback, array $parameters)
    {
        list($className, $method) = Str::parseCallback($callback, 'register');

        $instance = $this->container->make($className);

        $callable = array($instance, $method);

        return $this->createCallableCallback($callable, $parameters);
    }
297494
private function getArguments(callable $callback, array $callbackArguments)
    {
        $parameters = $this->getParameters($callback);
        $arguments = [];
        foreach ($parameters as $param) {
            if (array_key_exists($param->getName(), $callbackArguments)) {
                $arguments[] = $callbackArguments[$param->getName()];
            } elseif ($param->isDefaultValueAvailable()) {
                $arguments[] = $param->getDefaultValue();
            } else {
                $arguments[$param->getName()] = null;
            }
        }

        return $arguments;
    }
1110130
public function map(callable $callback = null)
	{
		return $callback ? array_map($callback, $this->list) : $this->list;
	}
971347
private function withOptionReference($name, $callback)
    {
        if (!$this->options) {
            $this->options = new ArrayObject();
        }

        return $this->withVariableReference($this->options, $name, $callback);
    }
1248341
public static function make($name, Closure $callback = null)
    {
        $menu = new self($name);
        if ( ! is_null($callback)) {
            call_user_func($callback, $menu);
        }

        return $menu;
    }
904176
public static function make(\Closure $callback = null)
    {
        if (is_null(static::$instance)) {
            static::$instance = new static();
        }

        if ($callback instanceof \Closure) {
            return $callback(static::$instance);
        }

        return static::$instance;
    }
1142576
public function run($name, $callback) {
        if (!is_callable($callback)) {
            throw new \InvalidArgumentException('$callback is not callable');
        }

        // Because, we need to remove exists Instance before fork
        $this->Storage->setup();

        $pid = pcntl_fork();
        if ($pid === -1) {
            return false;
        }
        if ($pid) {
            // main fork
            $this->pids[$name] = $pid;
            return true;
        } else {
            $result = call_user_func($callback);
            $this->Storage->set($this->getKey(), $name, $result);
            exit(0);
        }
    }
503934
protected function getCallback($callback, array $parameters)
    {
        if ($callback instanceof Closure) {
            return $this->createCallableCallback($callback, $parameters);
        } elseif (is_string($callback)) {
            return $this->createStringCallback($callback, $parameters);
        } else {
            return;
        }
    }
237315
private function aliasNameToArray($aliasName)
    {
        if (!empty($aliasName) && isset($this->alias[$aliasName])) {
            $aliasName = $this->aliasArrayToName($this->alias[$aliasName]);
        } elseif (is_array($aliasName)) {
            $aliasName = $this->aliasArrayToName($aliasName);
        }

        $aliasArray = array();

        $width = preg_replace('#^(\d*)x.*$#', '$1', $aliasName);
        $aliasArray['width'] = (!empty($width)) ? intval($width) : null;

        $height = preg_replace('#^\d*x(\d*)(_focus)?$#', '$1', $aliasName);
        $aliasArray['height'] = (!empty($height)) ? intval($height) : null;

        if ($aliasArray['width'] !== null && $aliasArray['height'] !== null) {
            $aliasArray['focus'] = (preg_match('#_focus$#', $aliasName)) ? true : false;
        } else {
            $aliasArray['focus'] = false;
        }

        return $aliasArray;
    }
1028573
public function exists(callable $callback): bool
    {
        $index = 0;
        foreach ($this->items as $key => $item) {
            if (true === $callback($item, $key, $index++)) {
                return true;
            }
        }

        return false;
    }
631205
final public function map(Callable $callback)
	{
		$arr = array_map(
			$callback,
			array_values($this->{self::MAGIC_PROPERTY}),
			array_keys($this->{self::MAGIC_PROPERTY})
		);
		return static::createFromArray($arr);
	}
391174
public function eachById(callable $callback, $count = 1000, $column = null, $alias = null)
    {
        return $this->chunkById($count, function ($results) use ($callback) {
            foreach ($results as $key => $value) {
                if ($callback($value, $key) === false) {
                    return false;
                }
            }
        }, $column, $alias);
    }