src/mako/http/routing/Dispatcher.php
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);
	}
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);
	}
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 ) ; }
Orders resolved middleware by priority.

@param  array $middleware Array of middleware
@return array
Orders resolved middleware by priority .