Feature Request
getDependencies() currently returns an array of middleware name strings. The registry resolves them via MiddlewareManager::getMiddleware($name) which matches against the name passed to the constructor.
This means developers must remember arbitrary string names:
public function getDependencies(): array {
return ['audit-log', 'start-session']; // magic strings
}
Proposed
Support class name resolution so developers can use ::class:
public function getDependencies(): array {
return [AuditLogMiddleware::class, StartSessionMiddleware::class];
}
Suggested Implementation
In the dependency resolution step, if a dependency string is a valid class name (contains \\), instantiate or look up the registered instance by class instead of by name:
foreach ($current->getDependencies() as $dep) {
if (class_exists($dep)) {
// find registered middleware that is an instance of $dep
$mw = $this->findByClass($dep);
} else {
$mw = $this->getMiddleware($dep);
}
}
Benefits
- IDE autocompletion and refactoring support
- Compile-time checking (typos caught immediately)
- No need to remember arbitrary name strings
- Both approaches can coexist (string names still work)
Feature Request
getDependencies()currently returns an array of middleware name strings. The registry resolves them viaMiddlewareManager::getMiddleware($name)which matches against the name passed to the constructor.This means developers must remember arbitrary string names:
Proposed
Support class name resolution so developers can use
::class:Suggested Implementation
In the dependency resolution step, if a dependency string is a valid class name (contains
\\), instantiate or look up the registered instance by class instead of by name:Benefits