Set Callback variable for execute when route is matched

@param $args
342749
private function setCallable( $args ) {
		$route      = array_shift( $args );
		$RealParams = array();

		// Before Middleware
		if ( is_array( $args[0] ) && isset( $args[0][0] ) ) {
			$this->middleware['before'] = array_shift( $args );
		}

		if ( ! is_callable( $args[0] ) && ! is_string( $args[0] ) && ! is_array( $args[0] ) ) {
			$controller               = array_shift( $args );
			$RealParams['controller'] = $controller;
		}

		//if ($route == '/' && count( $this->route->_getParams() ) <= 0 ) {
		if ( preg_match(
			'/(^\\/$)|(^\\/(\\?(\\w|\\d|\\=|\\&|\\-|\\.|_|\\/){0,}){0,}$)/',
			$route . $this->route->getParamStr(),
			$matches, PREG_OFFSET_CAPTURE
		) ) {
			//$this->callable = array_pop($args);
			$callFunc = array_pop( $args );
			$params   = array();

			if ( is_array( $callFunc ) ) {
				$keys   = array_keys( $callFunc );
				$params = $callFunc[ $keys[0] ];

				if ( ! is_array( $params ) ) {
					$params = array( $params );
				}

				$callFunc = $keys[0];
			}

			$callFunc           = $this->createCallbackFromString( $callFunc, $params );
			$this->callable     = Closure::bind( $callFunc, $this, get_class() );
			$this->RoutedStatus = TRUE;
		} else {
			$RoutePattern = str_replace( '/', '\\/', $route );
			/**
			 * ID: Konversi route kedalam pattern parameter optional
			 * EN: Convert route in optional parameter pattern
			 */
			$RoutePattern = preg_replace( '/\\\\\\/\\(:\\w+\\)/', '(\\/\\\\w+){0,}', $RoutePattern, - 1 );
			/**
			 * ID: Konversi route kedalam pattern parameter wajib
			 * EN: Cover route in required parameter pattern
			 */
			$RoutePattern = preg_replace( '/:\\w+/', '([\\w+|\\=|\\-|\\_|\\.]){1,}', $RoutePattern, - 1 );
			$RoutePattern = str_replace( '\\/\\w++', '(((\/){0,}\\w+){0,})', $RoutePattern );

			if ( $route != '/' &&
			     preg_match(
				     '/(^' . $RoutePattern . '$)|((^' . $RoutePattern . ')+(\\?(\\w|\\d|\\=|\\&|\\-|\\.|_|\\/){0,}){0,}$)/',
				     $this->route->getParamStr(),
				     $matches,
				     PREG_OFFSET_CAPTURE
			     )
			) {
				$callFunc = array_shift( $args );
				$params   = array();

				if ( is_array( $callFunc ) ) {
					$keys   = array_keys( $callFunc );
					$params = $callFunc[ $keys[0] ];

					if ( ! is_array( $params ) ) {
						$params = array( $params );
					}

					$callFunc = $keys[0];
				}

				$callFunc = $this->createCallbackFromString( $callFunc, $params );
				//$this->callable = array_pop($args);
				$this->callable     = Closure::bind( $callFunc, $this, get_class() );
				$this->RoutedStatus = TRUE;
				$p                  = explode( '/', $route );

				while ( list( $key, $value ) = each( $p ) ) {

					if ( substr( trim( $value ), - 1 ) == '+' ) {

						if ( isset( $matches[2][0] ) && ! empty( $matches[2][0] ) ) {
							$RealParams[ $value ] = explode( '/', substr( $matches[2][0], 1 ) );
						} elseif ( isset( $matches[7][0] ) && ! empty( $matches[7][0] ) ) {
							$RealParams[ $value ] = explode( '/', substr( $matches[7][0] ), 1 );
						} else {
							$RealParams[ $value ] = array();
						}

					} elseif ( substr( trim( $value, '/' ), 0, 1 ) == ':' ) {
						$getpos               = ( strpos( $this->route->_getParams( $key ), '?' ) > 0 ) ? strpos( $this->route->_getParams( $key ), '?' ) : strlen( $this->route->_getParams( $key ) );
						$RealParams[ $value ] = substr( $this->route->_getParams( $key ), 0, $getpos );
					} elseif ( substr( trim( $value, '/' ), 0, 2 ) == '(:' && substr( trim( $value, '/' ), - 1, 1 ) == ')' ) {

						if ( $this->route->_getParams( $key ) != NULL ) {
							$getpos               = ( strpos( $this->route->_getParams( $key ), '?' ) > 0 ) ? strpos( $this->route->_getParams( $key ), '?' ) : strlen( $this->route->_getParams( $key ) );
							$RealParams[ $value ] = substr( $this->route->_getParams( $key ), 0, $getpos );
						}

					}

				}

			}

		}

		Route::$destination = $route;
		$this->route->setParams( $RealParams );

		//print_r($args);

		// After Middleware
		if ( count( $args ) > 0 && is_array( $args[0] ) ) {
			$this->middleware['after'] = array_shift( $args );
		}

	}
1071651
function call($func,$args=NULL,$hooks='') {
		if (!is_array($args))
			$args=array($args);
		// Grab the real handler behind the string representation
		if (is_string($func))
			$func=$this->grab($func,$args);
		// Execute function; abort if callback/hook returns FALSE
		if (!is_callable($func))
			// No route handler
			if ($hooks=='beforeroute,afterroute') {
				$allowed=array();
				if (is_array($func))
					$allowed=array_intersect(
						array_map('strtoupper',get_class_methods($func[0])),
						explode('|',self::VERBS)
					);
				header('Allow: '.implode(',',$allowed));
				$this->error(405);
			}
			else
				user_error(sprintf(self::E_Method,
					is_string($func)?$func:$this->stringify($func)),
					E_USER_ERROR);
		$obj=FALSE;
		if (is_array($func)) {
			$hooks=$this->split($hooks);
			$obj=TRUE;
		}
		// Execute pre-route hook if any
		if ($obj && $hooks && in_array($hook='beforeroute',$hooks) &&
			method_exists($func[0],$hook) &&
			call_user_func_array(array($func[0],$hook),$args)===FALSE)
			return FALSE;
		// Execute callback
		$out=call_user_func_array($func,$args?:array());
		if ($out===FALSE)
			return FALSE;
		// Execute post-route hook if any
		if ($obj && $hooks && in_array($hook='afterroute',$hooks) &&
			method_exists($func[0],$hook) &&
			call_user_func_array(array($func[0],$hook),$args)===FALSE)
			return FALSE;
		return $out;
	}
592182
public function setCallArgument($arg)
    {
        $this->call_argument = $arg;
        $this->args =[
            $this->call_function,
            $this->call_argument
        ];
    }
785165
protected static function runCallback($callback, $args)
    {
        if (!is_array($args)) {
            $args = isset($args) ? array($args) : array();
        }
        return call_user_func_array($callback, $args);
    }
604000
def execute_callback(callback, *args)
      (callback.arity == 2 ? callback.call(*args[0, 2]) : callback.call(*args)) if callback
    end
375461
public function run(array $args, $method='get'){
      $method = strtolower($method);
      $append_echoed_text = Options::get('core.route.append_echoed_text',true);
      static::trigger('start', $this, $args, $method);

      // Call direct befores
      if ( $this->befores ) {
        // Reverse befores order
        foreach (array_reverse($this->befores) as $mw) {
          static::trigger('before', $this, $mw);
          Event::trigger('core.route.before', $this, $mw);
          ob_start();
          $mw_result  = call_user_func($mw);
          $raw_echoed = ob_get_clean();
          if ($append_echoed_text) Response::add($raw_echoed);
          if ( false  === $mw_result ) {
            return [''];
          } else {
            Response::add($mw_result);
          }
        }
      }

      $callback = (is_array($this->callback) && isset($this->callback[$method]))
                  ? $this->callback[$method]
                  : $this->callback;

      if (is_callable($callback) || is_a($callback, "View") ) {
        Response::type( Options::get('core.route.response_default_type', Response::TYPE_HTML) );

        ob_start();
        if (is_a($callback, "View")) {
          // Get the rendered view
          $view_results = (string)$callback;
        } else {
          $view_results = call_user_func_array($callback, $args);
        }
        $raw_echoed   = ob_get_clean();

        if ($append_echoed_text) Response::add($raw_echoed);
        Response::add($view_results);
      }

      // Apply afters
      if ( $this->afters ) {
        foreach ($this->afters as $mw) {
          static::trigger('after', $this, $mw);
          Event::trigger('core.route.after', $this, $mw);
          ob_start();
          $mw_result  = call_user_func($mw);
          $raw_echoed = ob_get_clean();
          if ($append_echoed_text) Response::add($raw_echoed);
          if ( false  === $mw_result ) {
            return [''];
          } else {
            Response::add($mw_result);
          }
        }
      }

      static::trigger('end', $this, $args, $method);
      Event::trigger('core.route.end', $this);

      return [Filter::with('core.route.response', Response::body())];
     }
530855
public function where(...$args): AliasDecorator
    {
        if ($args[0] instanceof \Closure) {
            call_user_func($args[0], $this);

            return $this;
        }

        //We have to prepare only first argument
        $args[0] = $this->prepare($args[0]);

        //Routing where
        call_user_func_array([$this->query, $this->target], $args);

        return $this;
    }
1017063
public function set($callback, $args = [])
    {
        if ($this->postTrigger) {
            if (isset($_POST[$this->postTrigger])) {
                $this->app->catch_runaway_callbacks = false;
                $this->triggered = $_POST[$this->postTrigger];

                $t = $this->app->run_called;
                $this->app->run_called = true;
                $ret = call_user_func_array($callback, $args);
                $this->app->run_called = $t;

                return $ret;
            }
        } else {
            if (isset($_GET[$this->urlTrigger])) {
                $this->app->catch_runaway_callbacks = false;
                $this->triggered = $_GET[$this->urlTrigger];

                $t = $this->app->run_called;
                $this->app->run_called = true;
                $this->owner->stickyGet($this->urlTrigger);
                $ret = call_user_func_array($callback, $args);
                //$this->app->stickyForget($this->name);
                $this->app->run_called = $t;

                return $ret;
            }
        }
    }
797626
public function show(...$args)
    {
        // We need to do this in order to support multiple parameter resource routes. For example,
        // if we map route /user/{user}/comments/{comment} to a controller, Laravel will pass `user`
        // as first argument and `comment` as last argument. So, id object that we want to fetch
        // is the last argument.
        $id = last(func_get_args());

        $this->validate();

        $results = $this->parseRequest()
            ->addIncludes()
            ->addKeyConstraint($id)
            ->modify()
            ->getResults(true)
            ->first()
            ->toArray();

        $meta = $this->getMetaData(true);

        return ApiResponse::make(null, $results, $meta);
    }
244129
protected function handleCallback($callback, array $args = [])
    {
        $response = null;

        // Check if $callback is a closure.
        if ($callback instanceof \Closure || is_array($callback)) {
            $response = call_user_func($callback, $args);
        } elseif (is_string($callback)) {
            if (false !== strpos($callback, '@') || class_exists($callback)) {
                // We use a "ClassName@method" syntax.
                // Let's get a class instance and call its method.
                $callbackArray = $this->handleClassCallback($callback);
                $response = call_user_func($callbackArray, $args);
            } else {
                // Used as a classic callback function.
                $response = call_user_func($callback, $args);
            }
        }

        return $response;
    }
296654
public function andWhere(...$args): AliasDecorator
    {
        if ($args[0] instanceof \Closure) {
            call_user_func($args[0], $this);

            return $this;
        }

        //We have to prepare only first argument
        $args[0] = $this->prepare($args[0]);

        //Routing where
        call_user_func_array([$this->query, 'and' . ucfirst($this->target)], $args);

        return $this;
    }
994375
public function setRoute($method, $args)
    {
        $pattern = array_shift($args);
        $callable = array_pop($args);

        //包含额外的参数
        if (count($args) > 0) {
            //额外的参数为单独的调用中间件
            foreach ($args as $call) {
                if (!is_callable($call)) {
                    continue;
                }
                $this->invoke($pattern, $call);
            }
        }
        $this->route->register($method, $pattern, $callable);
    }
982513
public static function redirect($url, $args = null) {
        if (strpos($url, '\\') !== false) {
            $url = self::action($url);
        } else {
            $url = self::url($url);
        }
        if (!empty($args)) {
            $url .= '?' . http_build_query($args);
        }
        Response::redirect($url, '');
    }
1068838
public function handleCli($argv)
    {
        if (!$this->run) {
            if (!(count($argv) >= 2)) {
                return;
            }

            $route = str_replace(':', '/', $argv[1]);
            unset($argv[0]);

            $this->getRouter()->handle($route);
            $this->callCli(array_values($argv));
            $this->run = true;
        } else {
            throw new BaseException('Application is run.');
        }
    }
138512
protected function callback($callback, array $args = [])
    {
        if (isset($callback)) {
            if (is_callable($callback) && $callback instanceof \Closure) {
                // Set new object and append the callback with some data.
                $o = new \ArrayObject($args);
                $o->app = App::instance();
                $callback = $callback->bindTo($o);
            } elseif (is_string($callback) && strpos($callback, '@') !== false) {
                $fixcallback = explode('@', $callback, 2);
                $this->Controller = $fixcallback[0];

                if (is_callable(
                    $callback = [$fixcallback[0], (isset($fixcallback[1]) ? $fixcallback[1] : 'index')]
                )) {
                    $this->Method = $callback[1];
                } else {
                    throw new \Exception("Callable error on {$callback[0]} -> {$callback[1]} !");
                }
            }

            if (is_array($callback) && !is_object($callback[0])) {
                $callback[0] = new $callback[0];
            }

            if (isset($args[0]) && $args[0] == $this->fullArg) {
                array_shift($args);
            }

            // Finally, call the method.
            return call_user_func_array($callback, $args);
        }
        return false;
    }
53457
function callbackOnce(err, arg) {
            var cb = callback;
            callback = null;
            if (cb) { cb(err, arg); }
        }
731015
static function executeCallback($callback, array $params = array()) {
    // If callback has @
    if (is_string($callback) && strpos($callback, '@') !== false) {
      // Split
      $arrCallback = explode('@', $callback);
      // Set object
      $object = class_exists($arrCallback[0]) ? (new $arrCallback[0]()) : null;
      // Set method
      $method = isset($arrCallback[0]) ? $arrCallback[0] : null;
      // Set callback
      $callback = array($object, $method);
    }
    // If not callable
    if ( ! is_callable($callback)) {
      // Throw error
      throw new InvalidCallback('Callback must be callable');
    }
    // Execute and return
    return call_user_func_array($callback, $params);
  }