<?php
$workspace = dirname(__DIR__);

function scan_dir($dir, &$results = []) {
    $files = scandir($dir);
    foreach ($files as $f) {
        if ($f === '.' || $f === '..') continue;
        $path = $dir . DIRECTORY_SEPARATOR . $f;
        if (is_dir($path)) {
            // Exclude common directories
            if ($f === '.git' || $f === '.gemini' || $f === 'scratch' || $f === 'uploads') continue;
            scan_dir($path, $results);
        } else {
            if (pathinfo($path, PATHINFO_EXTENSION) === 'php') {
                $content = file_get_contents($path);
                if (strpos($content, 'product_details') !== false) {
                    $results[] = $path;
                }
            }
        }
    }
    return $results;
}

$found = scan_dir($workspace);
echo "Files referencing 'product_details':\n";
foreach ($found as $file) {
    echo "- " . str_replace($workspace . DIRECTORY_SEPARATOR, '', $file) . "\n";
}
