#!/usr/bin/env php
<?php
declare(strict_types=1);

require_once __DIR__ . '/vendor/autoload.php';

use App\Framework\Console\ConsoleCommandMapper;
use App\Framework\Console\ConsoleCommand;
use App\Framework\Console\DemoCommand;
use App\Framework\Reflection\WrappedReflectionMethod;

echo "Testing ConsoleCommandMapper..." . PHP_EOL;

try {
    $mapper = new ConsoleCommandMapper();
    
    // Test the mapper configuration
    echo "Mapper attribute class: " . $mapper->getAttributeClass() . PHP_EOL;
    echo "ConsoleCommand class: " . ConsoleCommand::class . PHP_EOL;
    echo "Classes match: " . ($mapper->getAttributeClass() === ConsoleCommand::class ? 'YES' : 'NO') . PHP_EOL;
    
    // Test with a real method
    $reflector = new ReflectionClass(DemoCommand::class);
    $method = $reflector->getMethod('hello');
    $attributes = $method->getAttributes(ConsoleCommand::class);
    
    if (!empty($attributes)) {
        $attribute = $attributes[0]->newInstance();
        echo "Attribute found: " . $attribute->name . PHP_EOL;
        
        // This would require complex setup, just test the basic mapping
        echo "Basic mapper test passed!" . PHP_EOL;
    } else {
        echo "No attributes found on hello method!" . PHP_EOL;
    }
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . PHP_EOL;
    echo "Trace: " . $e->getTraceAsString() . PHP_EOL;
}