@param RuleInterface|null $next

@return RuleInterface
433286
public static function roleRelationship(RuleInterface $next = null): RuleInterface
    {
        return self::toOneRelationship(RoleSchema::TYPE, static::roleId($next));
    }
826884
public static function exists(string $tableName, string $primaryName, RuleInterface $next = null): RuleInterface
    {
        $primary = new ExistInDbTableSingleWithDoctrineRule($tableName, $primaryName);

        return $next === null ? $primary : new AndOperator($primary, $next);
    }
1040832
private function next(QueryBuilder $nextQuery)
    {
        $now = new \DateTime('now');

        $qb = clone $nextQuery;
        $qb->setParameter(':currentTime', $now->format('Y-m-d H:i:s'));

        return $qb->execute()->fetch();
    }
1133018
protected function get(ServerRequestInterface $request, bool $next = false): ?MiddlewareInterface
    {
        $index = $next ? ++$this->index : $this->index;

        if (!isset($this->middleware[$index])) {
            return null;
        }

        $middleware = $this->middleware[$index];

        if (\is_array($middleware)) {
            $conditions = $middleware;
            $middleware = \array_pop($conditions);

            if (!Matcher\Factory::matches($conditions, $request)) {
                return $this->get($request, true);
            }
        }

        if (\is_callable($middleware)) {
            return new Middleware\CallableWrapper($middleware);
        }

        if (\is_string($middleware)) {
            if ($this->container === null) {
                throw new \RuntimeException("No valid middleware provided: $middleware");
            }

            $middleware = $this->container->get($middleware);
        }

        if (!$middleware instanceof MiddlewareInterface) {
            throw new \RuntimeException('The middleware must be an instance of MiddlewareInterface');
        }

        return $middleware;
    }
913075
public static function validator(RuleInterface $rule, ContainerInterface $container = null): ValidatorInterface
    {
        $validator = new static($rule, $container);

        return $validator;
    }
352974
public function execute($command, callable $next)
    {
        if ($command->switchTo) {
            $command = $command->switchTo;
        }

        return $next($command);
    }
463485
public function handle($request, \Closure $next)
    {
        $route = $request->route();

        if ($route->hasCondition()) {
            $this->router->addWordPressBindings($route);
        }

        return $next($request);
    }
689615
protected static function moreOrEquals($value, RuleInterface $next = null): RuleInterface
    {
        return $next === null ?
            ($value instanceof DateTimeInterface ?
                new DateTimeMoreOrEquals($value) : new NumericMoreOrEqualsThan($value)) :
            new AndOperator(static::moreOrEquals($value), $next);
    }
1311928
public function handle($request, Closure $next)
    {
        // TODO: Get theme from user settings or system setting, or env or default....
        \Plugin::init();
        \Plugin::do_action('init');

        return $next($request);
    }
256258
public function executeMiddlewares(
        ServerRequestInterface $request,
        ResponseInterface $response,
        callable $next = null
    ) : ResponseInterface {
        return $this->getMiddlewares()->__invoke($request, $response, $next);
    }
1127493
public function execute($command, callable $next)
    {
        if (!$command->validate()) {
            throw new ValidationException(implode(', ', $command->getFirstErrors()));
        }

        return $next($command);
    }
2697
protected function dispatchRoute(
        RouteHandlerInterface $handler,
        ServerRequestInterface $request,
        Closure $next = null
    ): ResponseInterface {
        // callback that will be passed to the route handler call, as last argument.
        $handlerNext = $next ? function ($newRequest = null) use ($next, $request) {
            return $next($newRequest instanceof ServerRequestInterface ? $newRequest : $request);
        } :
            function () {
                // noop
            };
        return $handler($handlerNext);
    }
462506
public function handle($request, HandlerInterface $next)
    {
        if ($this->isEmpty()) {
            return $request;
        }
        if ($this->shadow == false) {
            $bundle = clone $this;
            $bundle->store->setIteratorMode(SplDoublyLinkedList::IT_MODE_FIFO | SplDoublyLinkedList::IT_MODE_DELETE);
            $this->shadow = true;

            return $next->handle($request, $bundle);
        }
        $handler = $this->frontPop();

        return $handler->handle($request, $this);
    }
859467
public static function readable(string $apiClass, RuleInterface $next = null): RuleInterface
    {
        $primary = new IsReadableViaApiRule($apiClass);

        return $next === null ? $primary : new AndOperator($primary, $next);
    }
373268
public static function userRelationship(RuleInterface $next = null): RuleInterface
    {
        return self::toOneRelationship(UserSchema::TYPE, static::userId($next));
    }
327141
protected static function enum(array $values, RuleInterface $next = null): RuleInterface
    {
        return $next === null ? new Enum($values) : new AndOperator(static::enum($values), $next);
    }
1171439
protected static function isDateTime(RuleInterface $next = null): RuleInterface
    {
        return $next === null ? new AsDateTime() : new AndOperator(new AsDateTime(), $next);
    }