[middleware description]
@param  array  $middleware [description]
@return [type]             [description]
770052
public static function middleware( $laravelMiddleware, $middleware = array() ) {
		$packageMiddleware = array();
		$path = base_path('config/packages.json');
		if( file_exists( $path ) ) {
			$data = json_decode( file_get_contents( $path ) );
			if( isset( $data->middleware ) ) {
				$packageMiddleware = (array)$data->middleware;
			}
		}
		return array_merge( $laravelMiddleware, $middleware, $packageMiddleware );
	}
91285
protected function orderMiddlewareByPriority(array $middleware): array
	{
		if(empty($this->middlewarePriority))
		{
			return $middleware;
		}

		$priority = array_intersect_key($this->middlewarePriority, $middleware) + array_fill_keys(array_keys(array_diff_key($middleware, $this->middlewarePriority)), static::MIDDLEWARE_DEFAULT_PRIORITY);

		// Sort the priority map using stable sorting

		$position = 0;

		foreach($priority as $key => $value)
		{
			$priority[$key] = [$position++, $value];
		}

		uasort($priority, function($a, $b)
		{
			return $a[1] === $b[1] ? ($a[0] > $b[0] ? 1 : -1) : ($a[1] > $b[1] ? 1 : -1);
		});

		foreach($priority as $key => $value)
		{
			$priority[$key] = $value[1];
		}

		// Return sorted middleware list

		return array_merge($priority, $middleware);
	}
451304
private function decorate($middleware): MiddlewareInterface
    {
        if ($middleware instanceof MiddlewareInterface) {
            return $middleware;
        } elseif ($middleware instanceof RequestHandlerInterface) {
            return new RequestHandlerMiddleware($middleware);
        } elseif ($middleware instanceof ResponseInterface) {
            return new FixedResponseMiddleware($middleware);
        } elseif (is_callable($middleware)) {
            return new CallableMiddleware($middleware);
        } elseif (is_string($middleware)) {
            return new LazyLoadingMiddleware($middleware, $this->container);
        } else {
            throw new InvalidArgumentException(sprintf(
                'Middleware "%s" is neither a string service name, an autoloadable class name, a PHP callable, or an instance of %s/%s/%s',
                is_object($middleware) ? get_class($middleware) : gettype($middleware),
                MiddlewareInterface::class, ResponseInterface::class, RequestHandlerInterface::class
            ));
        }
    }
1281242
public function prepend($middleware)
    {
        if (is_array($middleware)) {
            $this->queue = array_merge($middleware, $this->queue);

            return $this;
        }
        array_unshift($this->queue, $middleware);

        return $this;
    }
1299728
public function expandMiddlewareAtom( $middleware ) {
		if ( isset( $this->middleware[ $middleware ] ) ) {
			return $this->middleware[ $middleware ];
		}

		if ( class_exists( $middleware ) ) {
			return $middleware;
		}

		throw new ConfigurationException( 'Unknown middleware "' . $middleware . '" used.' );
	}
294208
public function getMiddlewares()
    {
        $middlewares = $this->middlewares();

        foreach ($middlewares as $key => $middleware) {
            $this->middlewares[$key] = $middleware;
        }

        return $this->middlewares;
    }
221864
public function middleware($middleware): Route
	{
		$this->middleware = array_merge($this->middleware, (array) $middleware);

		return $this;
	}
1361704
public function expandMiddleware( $middleware ) {
		$classes = [];

		foreach ( $middleware as $item ) {
			$classes = array_merge(
				$classes,
				$this->expandMiddlewareMolecule( $item )
			);
		}

		return $classes;
	}
682443
private function getGroupMiddleware() : array
    {
        $middleware = [];

        foreach ($this->groupOptionsStack as $groupOptions) {
            if (isset($groupOptions['middleware'])) {
                if (!is_array($groupOptions['middleware'])) {
                    $groupOptions['middleware'] = [$groupOptions['middleware']];
                }

                $middleware = array_merge($middleware, $groupOptions['middleware']);
            }
        }

        return $middleware;
    }
278724
protected function parseMiddleware($middleware)
    {
        list($name, $parameters) = array_pad(explode(':', $middleware, 2), 2, array());

        if (is_string($parameters)) {
            $parameters = explode(',', $parameters);
        }

        return array($name, $parameters);
    }
323631
protected function resolveMiddleware(string $middleware): array
	{
		[$name, $parameters] = $this->parseFunction($middleware);

		if(!isset($this->middleware[$name]))
		{
			throw new RuntimeException(vsprintf('No middleware named [ %s ] has been registered.', [$middleware]));
		}

		return ['name' => $name, 'middleware' => $this->middleware[$name], 'parameters' => $parameters];
	}
481018
protected function mergeMiddlewareGroup(array $action, $middleware = null)
    {
        if (isset($middleware)) {
            if (isset($action['middleware'])) {
                $action['middleware'] = array_merge($middleware, $action['middleware']);
            } else {
                $action['middleware'] = $middleware;
            }
        }

        return $action;
    }
1111705
public function expandMiddlewareMolecule( $middleware ) {
		$pieces = explode( ':', $middleware, 2 );

		if ( count( $pieces ) > 1 ) {
			return [array_merge( [$this->expandMiddlewareAtom( $pieces[0] )], explode( ',', $pieces[1] ) )];
		}

		if ( isset( $this->middleware_groups[ $middleware ] ) ) {
			return $this->expandMiddlewareGroup( $middleware );
		}

		return [[$this->expandMiddlewareAtom( $middleware )]];
	}
781005
public function add($middleware)
    {
        if (is_array($middleware)) {
            $this->queue = array_merge($this->queue, $middleware);

            return $this;
        }
        $this->queue[] = $middleware;

        return $this;
    }
930423
protected static function newInstances(string $namespace, array $middleware)
    {
        $instances = [];
        foreach ($middleware as $key => $name) {
            $class  = "{$namespace}\\{$name}Middleware";
            $object = new $class();
            if (!($object instanceof MiddlewareInterface)) {
                throw new \RuntimeException("{$class} type is not 'Mix\Core\Middleware\MiddlewareInterface'");
            }
            $instances[$key] = $object;
        }
        return $instances;
    }
950944
protected function marshalMiddleware($middleware)
    {
        if (is_string($middleware) && class_exists($middleware)) {
            $reflection = new \ReflectionClass($middleware);

            if (!$reflection->isInstantiable()) {
                throw new \LogicException(
                    sprintf('Element %s should be an instantiable class name.', $reflection->getName())
                );
            }

            $args = func_get_args();

            array_shift($args);

            $object = $reflection->newInstanceArgs($args);
        } elseif ($middleware instanceof MiddlewareInterface) {
            $object = $middleware;
        } elseif (is_callable($middleware)) {
            $object = new CallbackMiddleware($middleware);
        } else {
            throw new \InvalidArgumentException('Not valid MiddleChaining element.');
        }

        return $object;
    }
936693
public function middleware($middleware, $param = null)
    {
        if (is_null($param) && is_array($middleware)) {
            $this->option['middleware'] = $middleware;
        } else {
            foreach ((array)$middleware as $item) {
                $this->option['middleware'][] = [$item, $param];
            }
        }

        return $this;
    }