Files
michaelschiemer/tests/debug/inspect-discovery-cache.php
2025-11-24 21:28:25 +01:00

81 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/../../vendor/autoload.php';
use App\Framework\DI\DefaultContainer;
use App\Framework\Core\PathProvider;
use App\Framework\Discovery\Storage\DiscoveryCacheManager;
use App\Framework\Discovery\ValueObjects\DiscoveryContext;
use App\Framework\Discovery\ValueObjects\ScanType;
use App\Framework\Discovery\ValueObjects\DiscoveryOptions;
use App\Framework\Core\ValueObjects\ExecutionContext;
use App\Framework\DateTime\SystemClock;
echo "=== Discovery Cache Inspector ===\n\n";
// Use console.php bootstrap instead
$container = require __DIR__ . '/../../bootstrap/container.php';
$pathProvider = $container->get(PathProvider::class);
$clock = new SystemClock();
$cacheManager = $container->get(DiscoveryCacheManager::class);
$context = new DiscoveryContext(
paths: [$pathProvider->getSourcePath()->toString()],
scanType: ScanType::FULL,
options: DiscoveryOptions::default(),
startTime: $clock->now(),
executionContext: ExecutionContext::detect()
);
echo "Cache Key: " . $context->getCacheKey()->toString() . "\n\n";
$registry = $cacheManager->get($context);
if ($registry) {
echo "✓ Cached registry found\n";
echo " Items: " . count($registry) . "\n";
echo " Empty: " . ($registry->isEmpty() ? 'yes' : 'no') . "\n\n";
// Check LiveComponents
$liveComponents = $registry->attributes()->get('App\Framework\LiveComponents\Attributes\LiveComponent');
echo "LiveComponents found: " . count($liveComponents) . "\n";
foreach ($liveComponents as $lc) {
if (str_contains($lc->className->toString(), 'Popover')) {
echo "\n [POPOVER LiveComponent]\n";
echo " Class: " . $lc->className->toString() . "\n";
echo " Arguments: " . json_encode($lc->arguments) . "\n";
echo " File: " . ($lc->filePath?->toString() ?? 'unknown') . "\n";
$attr = $lc->createAttributeInstance();
if ($attr) {
echo " Name: " . $attr->name . "\n";
}
}
}
// Check StaticComponents
$staticComponents = $registry->attributes()->get('App\Framework\View\Attributes\ComponentName');
echo "\nStaticComponents found: " . count($staticComponents) . "\n";
foreach ($staticComponents as $sc) {
if (str_contains($sc->className->toString(), 'Popover')) {
echo "\n [POPOVER StaticComponent]\n";
echo " Class: " . $sc->className->toString() . "\n";
echo " Arguments: " . json_encode($sc->arguments) . "\n";
echo " File: " . ($sc->filePath?->toString() ?? 'unknown') . "\n";
$attr = $sc->createAttributeInstance();
if ($attr) {
echo " Tag: " . $attr->tag . "\n";
}
}
}
} else {
echo "✗ No cached registry found\n";
}
echo "\n=== Done ===\n";