getMethods(); foreach ($methods as $method) { $attributes = $method->getAttributes(\App\Framework\Console\ConsoleCommand::class); echo "Method: " . $method->getName() . "\n"; echo "Attributes found: " . count($attributes) . "\n"; foreach ($attributes as $attribute) { echo " Attribute: " . $attribute->getName() . "\n"; $instance = $attribute->newInstance(); echo " Instance: " . get_class($instance) . "\n"; // Test the mapper $mappedResult = $consoleMapper->map($method, $instance); if ($mappedResult) { echo " ✅ Mapper result: " . json_encode($mappedResult, JSON_PRETTY_PRINT) . "\n"; } else { echo " ❌ Mapper returned null\n"; } } echo "\n"; } echo "Now testing full discovery on just this one file...\n"; // Create a minimal discovery service to test just this file $discoveryService = new \App\Framework\Discovery\UnifiedDiscoveryService( pathProvider: $pathProvider, cache: $cache, clock: $clock, reflectionProvider: $reflectionProvider, configuration: $config, attributeMappers: [$consoleMapper], targetInterfaces: [] ); // Test discovery on specific file $filePath = \App\Framework\Filesystem\FilePath::fromString('/var/www/html/src/Framework/Mcp/Console/McpServerCommand.php'); try { echo "Attempting to discover attributes in: " . $filePath->getPath() . "\n"; // Try to get the discovery to process this specific file $result = $discoveryService->discover(); if ($result instanceof \App\Framework\Discovery\Results\DiscoveryRegistry) { $consoleCommands = $result->attributes->get(\App\Framework\Console\ConsoleCommand::class); echo "Console commands found: " . count($consoleCommands) . "\n"; foreach ($consoleCommands as $command) { echo " - Command: " . json_encode($command->getArguments(), JSON_PRETTY_PRINT) . "\n"; } } } catch (Exception $e) { echo "Discovery failed: " . $e->getMessage() . "\n"; echo "File: " . $e->getFile() . ":" . $e->getLine() . "\n"; }