Enable Discovery debug logging for production troubleshooting

- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
2025-08-11 20:13:26 +02:00
parent 59fd3dd3b1
commit 55a330b223
3683 changed files with 2956207 additions and 16948 deletions

View File

@@ -1,8 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
class AfterEmitResponse
final readonly class AfterEmitResponse
{
}

View File

@@ -1,8 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
class AfterHandleRequest
final readonly class AfterHandleRequest
{
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
@@ -10,5 +11,6 @@ final readonly class ApplicationBooted
public string $environment,
public string $version = 'dev',
public \DateTimeImmutable $occurredAt = new \DateTimeImmutable()
) {}
) {
}
}

View File

@@ -1,8 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
class BeforeEmitResponse
final readonly class BeforeEmitResponse
{
}

View File

@@ -1,8 +1,9 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
class BeforeHandleRequest
final readonly class BeforeHandleRequest
{
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
@@ -10,5 +11,6 @@ final readonly class ErrorOccurred
public string $context = '',
public ?string $requestId = null,
public \DateTimeImmutable $occurredAt = new \DateTimeImmutable()
) {}
) {
}
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
@@ -8,7 +9,7 @@ use App\Framework\DI\DefaultContainer;
/**
* Führt abschließende Konfigurationen für das Event-System durch
*/
final class EventCompilerPass
final readonly class EventCompilerPass
{
/**
* Richtet zusätzliche Event-Konfigurationen ein

View File

@@ -1,15 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
use App\Framework\DI\Container;
use App\Framework\DI\DefaultContainer;
/**
* Der EventDispatcher ist verantwortlich für die Verarbeitung von Events
* und das Aufrufen der entsprechenden Event-Handler
*/
final class EventDispatcher
final class EventDispatcher implements EventDispatcherInterface
{
/** @var array<string, array> Mapping von Event-Typen zu Handlern */
private array $handlers = [];
@@ -22,9 +24,10 @@ final class EventDispatcher
* @param array|null $eventHandlers Array mit Event-Handlern aus der Autodiscovery
*/
public function __construct(
private readonly DefaultContainer $container,
private readonly Container $container,
private readonly ?array $eventHandlers = null
) {}
) {
}
/**
* Initialisiert den EventDispatcher mit den Event-Handlern
@@ -149,8 +152,8 @@ final class EventDispatcher
'callable' => $handler,
'attribute_data' => [
'priority' => $priority ?? 0,
'stopPropagation' => $stopPropagation
]
'stopPropagation' => $stopPropagation,
],
];
@@ -177,12 +180,12 @@ final class EventDispatcher
{
$this->initialize();
if (isset($this->handlers[$eventClass]) && !empty($this->handlers[$eventClass])) {
if (isset($this->handlers[$eventClass]) && ! empty($this->handlers[$eventClass])) {
return true;
}
// Prüfen auf Handler für Basisklassen/Interfaces
return array_any(array_keys($this->handlers), fn($handledEventClass) => is_subclass_of($eventClass, $handledEventClass));
return array_any(array_keys($this->handlers), fn ($handledEventClass) => is_subclass_of($eventClass, $handledEventClass));
}
}

View File

@@ -1,21 +1,33 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
use App\Framework\DI\Container;
use App\Framework\DI\Initializer;
use App\Framework\Discovery\Results\DiscoveryResults;
use App\Framework\Discovery\Results\DiscoveryRegistry;
final readonly class EventDispatcherInitializer
{
public function __construct(
private Container $container,
private DiscoveryResults $results
){}
private DiscoveryRegistry $results
) {
}
#[Initializer]
public function __invoke(): EventDispatcher
{
return new EventDispatcher($this->container, $this->results->get(OnEvent::class));
$eventResults = $this->results->attributes->get(OnEvent::class);
$events = [];
foreach ($eventResults as $discoveredAttribute) {
if ($discoveredAttribute->additionalData) {
$events[] = $discoveredAttribute->additionalData;
}
}
return new EventDispatcher($this->container, $events);
}
}

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
/**
* Interface für Event Dispatcher
*/
interface EventDispatcherInterface
{
/**
* Dispatcht ein Event an alle registrierten Handler
*/
public function dispatch(object $event): array;
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;

View File

@@ -1,11 +1,12 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
use App\Framework\Core\AttributeMapper;
use ReflectionClass;
use ReflectionMethod;
use App\Framework\Reflection\WrappedReflectionClass;
use App\Framework\Reflection\WrappedReflectionMethod;
/**
* Mapper für das OnEvent-Attribut
@@ -22,14 +23,10 @@ final class EventHandlerMapper implements AttributeMapper
/**
* Implementiert die map-Methode aus dem AttributeMapper-Interface
*
* @param object $reflectionTarget Das Reflektionsobjekt (ReflectionClass|ReflectionMethod)
* @param object $attributeInstance Die Attributinstanz
* @return array|null Die Attributdaten oder null, wenn nicht verarbeitet werden kann
*/
public function map(object $reflectionTarget, object $attributeInstance): ?array
public function map(WrappedReflectionClass|WrappedReflectionMethod $reflectionTarget, object $attributeInstance): ?array
{
if (!($reflectionTarget instanceof ReflectionMethod)) {
if (! ($reflectionTarget instanceof WrappedReflectionMethod)) {
return null;
}
@@ -41,7 +38,7 @@ final class EventHandlerMapper implements AttributeMapper
}
$eventType = $parameters[0]->getType();
if (!$eventType || $eventType->isBuiltin()) {
if (! $eventType || $eventType->isBuiltin()) {
return null;
}
@@ -54,7 +51,7 @@ final class EventHandlerMapper implements AttributeMapper
#'reflection' => $reflectionTarget,
'attribute_data' => [
'priority' => $attributeInstance->priority ?? 0,
'stopPropagation' => $attributeInstance->stopPropagation ?? false
'stopPropagation' => $attributeInstance->stopPropagation ?? false,
],
];
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
@@ -20,5 +21,6 @@ final class OnEvent
public function __construct(
public readonly ?int $priority = null,
public readonly bool $stopPropagation = false
) {}
) {
}
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace App\Framework\Core\Events;
@@ -14,5 +15,6 @@ final readonly class UserRegistered
public string $username,
public \DateTimeImmutable $registeredAt = new \DateTimeImmutable(),
public \DateTimeImmutable $occurredAt = new \DateTimeImmutable()
) {}
) {
}
}