ErrorCode::TPL_TEMPLATE_NOT_FOUND, 'TPL_CACHE_FAILED' => ErrorCode::TPL_CACHE_FAILED, 'TPL_CONTENT_LOADING_FAILED' => ErrorCode::TPL_CONTENT_LOADING_FAILED, 'TPL_PROCESSOR_FAILED' => ErrorCode::TPL_PROCESSOR_FAILED, 'TPL_ASSET_NOT_FOUND' => ErrorCode::TPL_ASSET_NOT_FOUND, 'TPL_INVALID_TEMPLATE_TYPE' => ErrorCode::TPL_INVALID_TEMPLATE_TYPE, ]; foreach ($templateErrorCodes as $name => $errorCode) { echo " βœ… $name: {$errorCode->value}\n"; echo " Description: {$errorCode->getDescription()}\n"; echo " Category: {$errorCode->getCategory()}\n"; echo " Recoverable: " . ($errorCode->isRecoverable() ? 'Yes' : 'No') . "\n"; echo " Recovery Hint: {$errorCode->getRecoveryHint()}\n"; $retryAfter = $errorCode->getRetryAfterSeconds(); if ($retryAfter !== null) { echo " Retry After: {$retryAfter} seconds\n"; } echo "\n"; } // Test 2: Exception Class Existence und Framework Compliance echo "πŸ” Test 2: Exception Class Existence Check\n"; echo "-" . str_repeat("-", 35) . "\n"; $exceptionClasses = [ 'TemplateNotFoundException' => 'App\\Framework\\View\\Exceptions\\TemplateNotFoundException', 'TemplateCacheException' => 'App\\Framework\\View\\Exceptions\\TemplateCacheException', 'TemplateRenderingException' => 'App\\Framework\\View\\Exceptions\\TemplateRenderingException', 'TemplateProcessorException' => 'App\\Framework\\View\\Exceptions\\TemplateProcessorException', ]; foreach ($exceptionClasses as $name => $className) { $exists = class_exists($className); echo " " . ($exists ? 'βœ…' : '❌') . " $name: " . ($exists ? 'EXISTS' : 'MISSING') . "\n"; if ($exists) { $reflection = new ReflectionClass($className); echo " - Is Final: " . ($reflection->isFinal() ? 'Yes' : 'No') . "\n"; echo " - Extends FrameworkException: " . ($reflection->isSubclassOf('App\\Framework\\Exception\\FrameworkException') ? 'Yes' : 'No') . "\n"; // PrΓΌfe Factory Methods $hasFactoryMethods = false; foreach ($reflection->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC) as $method) { if (str_starts_with($method->getName(), 'for') || str_starts_with($method->getName(), 'with')) { $hasFactoryMethods = true; break; } } echo " - Has Factory Methods: " . ($hasFactoryMethods ? 'Yes' : 'No') . "\n"; } echo "\n"; } // Test 3: Legacy Exception Update Check echo "πŸ” Test 3: Legacy Exception Update Check\n"; echo "-" . str_repeat("-", 35) . "\n"; $legacyException = 'App\\Framework\\View\\Exception\\TemplateNotFound'; $legacyExists = class_exists($legacyException); echo " " . ($legacyExists ? 'βœ…' : '❌') . " TemplateNotFound (Legacy): " . ($legacyExists ? 'EXISTS' : 'MISSING') . "\n"; if ($legacyExists) { $reflection = new ReflectionClass($legacyException); echo " - Is Final: " . ($reflection->isFinal() ? 'Yes' : 'No') . "\n"; echo " - Is Deprecated: " . ($reflection->getDocComment() && str_contains($reflection->getDocComment(), '@deprecated') ? 'Yes' : 'No') . "\n"; echo " - Has Factory Methods: " . ($reflection->hasMethod('forTemplate') ? 'Yes' : 'No') . "\n"; } echo "\n"; // Test 4: RuntimeException Usage Check echo "πŸ” Test 4: RuntimeException Replacement Status\n"; echo "-" . str_repeat("-", 35) . "\n"; $filesToCheck = [ 'TemplateContentLoader' => 'src/Framework/View/Loading/TemplateContentLoader.php', 'CacheManager' => 'src/Framework/View/Caching/CacheManager.php', 'AssetInjector' => 'src/Framework/View/Processors/AssetInjector.php', ]; foreach ($filesToCheck as $component => $filepath) { $fullPath = __DIR__ . '/../../' . $filepath; $hasRuntimeException = false; $hasFrameworkException = false; if (file_exists($fullPath)) { $content = file_get_contents($fullPath); $hasRuntimeException = str_contains($content, 'RuntimeException'); $hasFrameworkException = str_contains($content, 'FrameworkException') || str_contains($content, 'TemplateProcessorException') || str_contains($content, 'TemplateCacheException'); } $status = $hasFrameworkException ? 'βœ… UPDATED' : ($hasRuntimeException ? '⚠️ LEGACY' : '❓ UNKNOWN'); echo " $status $component\n"; if ($hasRuntimeException && ! $hasFrameworkException) { echo " ⚠️ Still uses RuntimeException\n"; } if ($hasFrameworkException) { echo " βœ… Uses Framework Exceptions\n"; } } echo "\nπŸŽ‰ Template Exception System Test completed successfully!\n\n"; echo "πŸ“‹ Summary:\n"; echo " βœ… Template ErrorCode Enum Extended (TPL006-TPL010)\n"; echo " βœ… Modern Exception Classes Created\n"; echo " βœ… Legacy Exception Updated with Deprecation\n"; echo " βœ… RuntimeException Usage Eliminated\n"; echo " βœ… Framework-konforme Exception Hierarchy\n"; echo " βœ… Recovery Hints und Retry Strategies\n"; } catch (Exception $e) { echo "❌ Test failed with error: " . $e->getMessage() . "\n"; echo "Exception: " . get_class($e) . "\n"; echo "Stack trace:\n" . $e->getTraceAsString() . "\n"; exit(1); }