#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
echo 'PHP syntaxe application & entrée HTTP & installateur'
while IFS= read -r -d '' f; do php -l "$f" >/dev/null; done < <(find application public/index.php public/router.php bin -name '*.php' -type f -print0)
echo 'Test du parseur SQL des migrations'
php tests/install_parser_check.php
php bin/install.php --validate-sql
echo 'Contrôle anti-reliques dans les ressources applicatives'
if grep -RniE 'Wishes|Moonprod|Moonprodisplay|Prodisplay|ws_session|ws_csrf|ws_slugify' application/controllers application/models application/views public/assets/admin public/assets/store/live.css; then
 echo 'ÉCHEC : chaîne héritée du précédent projet';exit 1
fi
if grep -Rni 'dermaroc-mix.zip' application/views public/assets; then echo 'ÉCHEC : lien ZIP ancien';exit 1; fi
if find public -iname '*.sql' -o -iname '*backup*' | grep .; then echo 'ÉCHEC : fichier sensible dans public';exit 1;fi
if [ -f storage/private/config.php ]; then echo 'AVERTISSEMENT : configuration privée locale, NE PAS INCLURE DANS LE ZIP';fi
echo 'OK : analyses statiques R1.1 terminées (pas de test MySQL).'
