createForDevelopment([$srcPath]); echo "Running discovery...\n"; $registry = $discoveryService->discover(); echo "Total items discovered: " . count($registry) . "\n"; echo "Total Initializers found: " . $registry->attributes->getCount(Initializer::class) . "\n\n"; // Get all initializers $initializers = $registry->attributes->get(Initializer::class); echo "=== Analyzing Each Initializer ===\n"; $counter = 0; foreach ($initializers as $mapping) { $counter++; $className = $mapping->class->getFullyQualified(); $methodName = $mapping->method ? $mapping->method->toString() : '(class)'; echo "\n[$counter] $className::$methodName\n"; // Check mapped data if ($mapping->mappedData) { echo " Mapped Data:\n"; foreach ($mapping->mappedData as $key => $value) { if ($key === 'contexts') { if ($value === null) { echo " - contexts: NULL ⚠️ (will be skipped!)\n"; } elseif (is_array($value)) { echo " - contexts: [" . implode(', ', array_map(fn ($c) => $c?->value ?? 'null', $value)) . "]\n"; } else { echo " - contexts: " . json_encode($value) . "\n"; } } else { echo " - $key: " . (is_string($value) ? $value : json_encode($value)) . "\n"; } } } else { echo " ❌ No mapped data!\n"; } // Check attributes if ($mapping->attributes) { echo " Raw Attributes:\n"; foreach ($mapping->attributes as $attr) { if ($attr instanceof Initializer) { $reflection = new ReflectionObject($attr); $props = $reflection->getProperties(); foreach ($props as $prop) { $prop->setAccessible(true); $val = $prop->getValue($attr); if ($prop->getName() === 'contexts') { if ($val === null) { echo " - contexts (raw): NULL\n"; } elseif (is_array($val)) { echo " - contexts (raw): [" . implode(', ', array_map(fn ($c) => $c?->value ?? 'null', $val)) . "]\n"; } else { echo " - contexts (raw): " . json_encode($val) . "\n"; } } } } } } } echo "\n=== Summary ===\n"; echo "Total Initializers analyzed: $counter\n"; // Count how many have null contexts $nullContexts = 0; $withContexts = 0; foreach ($initializers as $mapping) { if ($mapping->mappedData && isset($mapping->mappedData['contexts'])) { if ($mapping->mappedData['contexts'] === null) { $nullContexts++; } else { $withContexts++; } } } echo "Initializers with NULL contexts: $nullContexts (will be skipped)\n"; echo "Initializers with valid contexts: $withContexts\n"; } catch (Exception $e) { echo "❌ Error: " . $e->getMessage() . "\n"; echo "Stack trace:\n" . $e->getTraceAsString() . "\n"; }