mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-04-13 08:28:32 +00:00
- Add tools/php_syntax_check.sh (supports full scan + single-file mode) - CI workflow now calls the shared script - All 6 agents updated to reference the script - CONTRIBUTING.md: add Pre-Commit Checks section - Exclude src/bin/* (third-party stubs) from lint
35 lines
983 B
Bash
35 lines
983 B
Bash
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# PHP syntax checker for the XC_VM project.
|
|
# Scans all .php files under src/, excluding src/bin/* (third-party stubs).
|
|
# Exit code: 0 if no errors, 1 if any file has syntax errors.
|
|
#
|
|
# Usage:
|
|
# ./tools/php_syntax_check.sh # check all src/*.php
|
|
# ./tools/php_syntax_check.sh src/domain/Device/EnigmaService.php # check one file
|
|
|
|
ERRORS=0
|
|
CHECKED=0
|
|
|
|
if [[ $# -gt 0 ]]; then
|
|
for file in "$@"; do
|
|
if ! php -l "$file" 2>&1 | grep -q "No syntax errors"; then
|
|
php -l "$file"
|
|
ERRORS=$((ERRORS + 1))
|
|
fi
|
|
CHECKED=$((CHECKED + 1))
|
|
done
|
|
else
|
|
while IFS= read -r -d '' file; do
|
|
if ! php -l "$file" 2>&1 | grep -q "No syntax errors"; then
|
|
php -l "$file"
|
|
ERRORS=$((ERRORS + 1))
|
|
fi
|
|
CHECKED=$((CHECKED + 1))
|
|
done < <(find src -name '*.php' -not -path 'src/bin/*' -print0)
|
|
fi
|
|
|
|
echo "Checked $CHECKED files, $ERRORS errors"
|
|
[[ "$ERRORS" -eq 0 ]]
|