src/Scope.php
public function middleware()
    {
        foreach ($this->_middleware as $middleware) {
            yield $middleware;
        }
        if ($this->_parent) {
            foreach ($this->_parent->middleware() as $middleware) {
                yield $middleware;
            }
        }
    }
public function middleware()
    {
        foreach ($this->_middleware as $middleware) {
            yield $middleware;
        }
        if ($this->_parent) {
            foreach ($this->_parent->middleware() as $middleware) {
                yield $middleware;
            }
        }
    }
Middleware generator.

@return callable