#!/usr/bin/env bash # Pre-commit PHP syntax check for lint-staged # Called with staged .php files as arguments set -euo pipefail if ! command -v php &>/dev/null; then echo "❌ PHP not found. Install php-cli to commit PHP files." echo " Ubuntu/Debian: sudo apt-get install php-cli" exit 1 fi errors=0 for file in "$@"; do if ! php -l "$file" >/dev/null 2>&1; then echo "❌ Syntax error in $file" php -l "$file" errors=1 fi done if [ "$errors" -eq 1 ]; then echo "" echo "❌ PHP lint failed. Fix errors before committing." exit 1 fi echo "✅ PHP syntax OK"