Skip to content

MiddlewareAttributeScanner

Reflects a list of candidate classes for #[Middleware] attributes and builds the MiddlewareDefinitions that MiddlewareOrderResolver sorts into a pipeline order.

Modeled on Quiote\Routing\Compiler\AttributeRouteScanner, but takes an explicit FQCN list rather than globbing directories: unlike actions (which always live under a module’s Actions/ tree), middleware has no established directory convention to scan, so candidates are whatever the framework’s own core list plus MiddlewareCatalog::getAttributedCandidates() supply.

A class is only a candidate for scanning if it’s already been supplied by the caller — this scanner never does its own class discovery. Classes without a #[Middleware] attribute, or that don’t implement MiddlewareInterface, are silently skipped (the same “presence is opt-in” rule AttributeRouteScanner uses for #[Route]).

final class MiddlewareAttributeScanner

Since1.0.0
SourceMiddleware/Compiler/MiddlewareAttributeScanner.php
ConstantValueDescription
CODE_CLASS_NOT_FOUND'CLASS_NOT_FOUND'
CODE_DUPLICATE_CANDIDATE'DUPLICATE_CANDIDATE'
CODE_NOT_A_MIDDLEWARE'NOT_A_MIDDLEWARE'
MethodDescription
getDiagnostics(): array<Diagnostic>
scan(iterable<string> $candidateFqcns): array<MiddlewareDefinition>

public function getDiagnostics(): array<Diagnostic>

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

public function scan(iterable<string> $candidateFqcns): array<MiddlewareDefinition>

ParameterTypeDescription
$candidateFqcnsiterable``<``string``>

Returns array``<MiddlewareDefinition>