refactor: add circular dependency detection and error handling in DI container

- Introduce `InitializerCycleException` for detailed cycle reporting
- Enhance `InitializerProcessor` fallback with explicit discovery order handling and logging
- Implement proactive cycle detection in `InitializerDependencyGraph`
- Improve `ClassName` and `MethodName` with `Stringable` support
This commit is contained in:
2025-11-03 15:37:40 +01:00
parent 376fcd5fc1
commit 0ca382f80b
6 changed files with 173 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace App\Framework\Http;
use App\Framework\Core\ValueObjects\ClassName;
use App\Framework\Core\ValueObjects\MethodName;
use App\Framework\DI\Container;
use App\Framework\Logging\Logger;
use App\Framework\Reflection\ReflectionProvider;
@@ -168,7 +169,7 @@ final readonly class MiddlewareDependencyResolver
private function getMiddlewareDependencies(ClassName $middlewareClass): array
{
try {
if (! $middlewareClass->exists()) {
if (! $middlewareClass->exists() || MethodName::construct()->existsIn($middlewareClass)) {
return [];
}