toArray(), JSON_PRETTY_PRINT) . "\n"; echo "Attribute mappers count: " . count($devConfig->attributeMappers) . "\n"; echo "Target interfaces count: " . count($devConfig->targetInterfaces) . "\n\n"; // Test 2: Check factory echo "=== Factory Analysis ===\n"; $factory = new DiscoveryServiceFactory($container, $pathProvider, $cache, $clock); // Create service and debug $devConfigWithPaths = $devConfig->withPaths([$srcPath]); echo "Config with paths - Paths count: " . count($devConfigWithPaths->paths) . "\n"; echo "Config with paths - Mappers count: " . count($devConfigWithPaths->attributeMappers) . "\n\n"; // Test 3: Direct reflection on the factory's buildAttributeMappers method echo "=== Reflecting Factory's buildAttributeMappers ===\n"; $reflection = new ReflectionClass($factory); $buildMappersMethod = $reflection->getMethod('buildAttributeMappers'); $buildMappersMethod->setAccessible(true); // Call with empty array (what happens in development config) $emptyMappers = $buildMappersMethod->invoke($factory, []); echo "buildAttributeMappers([]) returns " . count($emptyMappers) . " mappers:\n"; foreach ($emptyMappers as $mapper) { echo "- " . get_class($mapper) . "\n"; } echo "\n"; // Test 4: Test discovery with this factory echo "=== Testing Discovery with Factory ===\n"; $discoveryService = $factory->createForDevelopment([$srcPath]); // Get the actual configuration used $reflectionService = new ReflectionClass($discoveryService); $configProperty = $reflectionService->getProperty('configuration'); $configProperty->setAccessible(true); $actualConfig = $configProperty->getValue($discoveryService); $mappersProperty = $reflectionService->getProperty('attributeMappers'); $mappersProperty->setAccessible(true); $actualMappers = $mappersProperty->getValue($discoveryService); echo "UnifiedDiscoveryService configuration:\n"; echo "- Config paths: " . count($actualConfig->paths) . "\n"; echo "- Config mappers: " . count($actualConfig->attributeMappers) . "\n"; echo "- Service mappers: " . count($actualMappers) . "\n"; echo "\nService mappers:\n"; foreach ($actualMappers as $mapper) { echo "- " . get_class($mapper) . "\n"; } echo "\n=== Running Discovery ===\n"; $registry = $discoveryService->discover(); echo "Results:\n"; echo "- Total: " . count($registry) . "\n"; echo "- Initializers: " . $registry->attributes->getCount('App\\Framework\\DI\\Initializer') . "\n"; } catch (Exception $e) { echo "❌ Error: " . $e->getMessage() . "\n"; echo "Stack trace:\n" . $e->getTraceAsString() . "\n"; }