<?php

declare(strict_types=1);

// Bootstrap file for PHPStan and tests
require_once __DIR__ . '/../vendor/autoload.php';

use App\Framework\Core\AppBootstrapper;
use App\Framework\DateTime\SystemClock;
use App\Framework\DateTime\SystemHighResolutionClock;
use App\Framework\DI\Container;
use App\Framework\Performance\EnhancedPerformanceCollector;
use App\Framework\Performance\MemoryMonitor;

require_once __DIR__ . '/../src/Framework/Debug/helpers.php';

// Funktion zum Erstellen eines Test-Containers
function createTestContainer(): Container
{
    // Konfiguration für Tests
    $config = [
        'debug' => true,
        'async_discovery' => false, // Für Tests deaktiviert
    ];

    // Test-spezifische Anwendung initialisierung (ohne run())
    $basePath = dirname(__DIR__);
    $clock = new SystemClock();
    $highResClock = new SystemHighResolutionClock();
    $memoryMonitor = new MemoryMonitor();
    $collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: false);
    $bootstrapper = new AppBootstrapper($basePath, $collector, $memoryMonitor);

    try {
        $app = $bootstrapper->bootstrapWeb();

        return $app->getContainer();

    } catch (Exception $e) {
        echo "Bootstrap failed: " . $e->getMessage() . "\n";
        echo $e->getTraceAsString() . "\n";
        exit(1);
    }
}
