|
|
@@ -17,7 +17,7 @@ declare(strict_types=1);
|
|
|
namespace Cake\Http;
|
|
|
|
|
|
use Cake\Core\App;
|
|
|
-use Cake\Http\Middleware\CallableDecoratorMiddleware;
|
|
|
+use Cake\Http\Middleware\ClosureDecoratorMiddleware;
|
|
|
use Cake\Http\Middleware\DoublePassDecoratorMiddleware;
|
|
|
use Closure;
|
|
|
use Countable;
|
|
|
@@ -29,7 +29,7 @@ use RuntimeException;
|
|
|
use SeekableIterator;
|
|
|
|
|
|
/**
|
|
|
- * Provides methods for creating and manipulating a "queue" of middleware callables.
|
|
|
+ * Provides methods for creating and manipulating a "queue" of middlewares.
|
|
|
* This queue is used to process a request and generate response via \Cake\Http\Runner.
|
|
|
*/
|
|
|
class MiddlewareQueue implements Countable, SeekableIterator
|
|
|
@@ -62,7 +62,7 @@ class MiddlewareQueue implements Countable, SeekableIterator
|
|
|
/**
|
|
|
* Resolve middleware name to a PSR 15 compliant middleware instance.
|
|
|
*
|
|
|
- * @param string|callable|\Psr\Http\Server\MiddlewareInterface $middleware The middleware to resolve.
|
|
|
+ * @param string|\Closure|\Psr\Http\Server\MiddlewareInterface $middleware The middleware to resolve.
|
|
|
* @return \Psr\Http\Server\MiddlewareInterface
|
|
|
* @throws \RuntimeException If Middleware not found.
|
|
|
*/
|
|
|
@@ -92,13 +92,13 @@ class MiddlewareQueue implements Countable, SeekableIterator
|
|
|
return new DoublePassDecoratorMiddleware($middleware);
|
|
|
}
|
|
|
|
|
|
- return new CallableDecoratorMiddleware($middleware);
|
|
|
+ return new ClosureDecoratorMiddleware($middleware);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Append a middleware to the end of the queue.
|
|
|
*
|
|
|
- * @param callable|string|array|\Psr\Http\Server\MiddlewareInterface $middleware The middleware(s) to append.
|
|
|
+ * @param string|array|\Closure|\Psr\Http\Server\MiddlewareInterface $middleware The middleware(s) to append.
|
|
|
* @return $this
|
|
|
*/
|
|
|
public function add($middleware)
|
|
|
@@ -116,7 +116,7 @@ class MiddlewareQueue implements Countable, SeekableIterator
|
|
|
/**
|
|
|
* Alias for MiddlewareQueue::add().
|
|
|
*
|
|
|
- * @param callable|string|array|\Psr\Http\Server\MiddlewareInterface $middleware The middleware(s) to append.
|
|
|
+ * @param string|array|\Closure|\Psr\Http\Server\MiddlewareInterface $middleware The middleware(s) to append.
|
|
|
* @return $this
|
|
|
* @see MiddlewareQueue::add()
|
|
|
*/
|
|
|
@@ -128,7 +128,7 @@ class MiddlewareQueue implements Countable, SeekableIterator
|
|
|
/**
|
|
|
* Prepend a middleware to the start of the queue.
|
|
|
*
|
|
|
- * @param callable|string|array|\Psr\Http\Server\MiddlewareInterface $middleware The middleware(s) to prepend.
|
|
|
+ * @param string|array|\Closure|\Psr\Http\Server\MiddlewareInterface $middleware The middleware(s) to prepend.
|
|
|
* @return $this
|
|
|
*/
|
|
|
public function prepend($middleware)
|
|
|
@@ -144,13 +144,13 @@ class MiddlewareQueue implements Countable, SeekableIterator
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Insert a middleware callable at a specific index.
|
|
|
+ * Insert a middleware at a specific index.
|
|
|
*
|
|
|
- * If the index already exists, the new callable will be inserted,
|
|
|
+ * If the index already exists, the new middleware will be inserted,
|
|
|
* and the existing element will be shifted one index greater.
|
|
|
*
|
|
|
* @param int $index The index to insert at.
|
|
|
- * @param callable|string|\Psr\Http\Server\MiddlewareInterface $middleware The middleware to insert.
|
|
|
+ * @param string|\Closure|\Psr\Http\Server\MiddlewareInterface $middleware The middleware to insert.
|
|
|
* @return $this
|
|
|
*/
|
|
|
public function insertAt(int $index, $middleware)
|
|
|
@@ -161,13 +161,13 @@ class MiddlewareQueue implements Countable, SeekableIterator
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Insert a middleware object before the first matching class.
|
|
|
+ * Insert a middleware before the first matching class.
|
|
|
*
|
|
|
* Finds the index of the first middleware that matches the provided class,
|
|
|
- * and inserts the supplied callable before it.
|
|
|
+ * and inserts the supplied middleware before it.
|
|
|
*
|
|
|
* @param string $class The classname to insert the middleware before.
|
|
|
- * @param callable|string|\Psr\Http\Server\MiddlewareInterface $middleware The middleware to insert.
|
|
|
+ * @param string|\Closure|\Psr\Http\Server\MiddlewareInterface $middleware The middleware to insert.
|
|
|
* @return $this
|
|
|
* @throws \LogicException If middleware to insert before is not found.
|
|
|
*/
|
|
|
@@ -197,11 +197,11 @@ class MiddlewareQueue implements Countable, SeekableIterator
|
|
|
* Insert a middleware object after the first matching class.
|
|
|
*
|
|
|
* Finds the index of the first middleware that matches the provided class,
|
|
|
- * and inserts the supplied callable after it. If the class is not found,
|
|
|
+ * and inserts the supplied middleware after it. If the class is not found,
|
|
|
* this method will behave like add().
|
|
|
*
|
|
|
* @param string $class The classname to insert the middleware before.
|
|
|
- * @param callable|string|\Psr\Http\Server\MiddlewareInterface $middleware The middleware to insert.
|
|
|
+ * @param string|\Closure|\Psr\Http\Server\MiddlewareInterface $middleware The middleware to insert.
|
|
|
* @return $this
|
|
|
*/
|
|
|
public function insertAfter(string $class, $middleware)
|