Skip to content

MiddlewareOrderResolver

Turns scanned MiddlewareDefinitions into a single pipeline order.

phase (see MiddlewarePhase::ORDER) is the primary grouping; within/across phases, explicit before/after edges are hard constraints (a Kahn topological sort), and priority (higher runs earlier) plus scan order break remaining ties. before/after may name either a short class name (e.g. “RoutingMiddleware”, matching how the framework’s own attributes are written today) or a fully-qualified class name.

final class MiddlewareOrderResolver

Since1.0.0
SourceMiddleware/Compiler/MiddlewareOrderResolver.php
ConstantValueDescription
CODE_AMBIGUOUS_REFERENCE'AMBIGUOUS_REFERENCE'
CODE_UNRESOLVED_REFERENCE'UNRESOLVED_REFERENCE'

public function __construct(?list<string> $guardedClasses = null): mixed

Defaults to the framework’s own guarded set; pass an explicit list (including []) to override, e.g. in unit tests that exercise the lenient path.

ParameterTypeDescription
$guardedClasses?``list``<``string``>Defaults to the framework’s own guarded set; pass an explicit list (including []) to override, e.g. in unit tests that exercise the lenient path.

Returns mixed

MethodDescription
getDiagnostics(): array<Diagnostic>
resolve(array<MiddlewareDefinition> $definitions): array<MiddlewareDefinition>

public function getDiagnostics(): array<Diagnostic>

Returns array``<Diagnostic> — Diagnostics recorded during the last resolve().

public function resolve(array<MiddlewareDefinition> $definitions): array<MiddlewareDefinition>

ParameterTypeDescription
$definitionsarray``<MiddlewareDefinition>

Returns array``<MiddlewareDefinition> — Same definitions, reordered.

ThrowsWhen
MiddlewareOrderExceptionif before/after constraints cycle, or if a guarded (framework) middleware’s constraint cannot be resolved.