fix: 语法错误时明确列出错误文件名
Test CI / 快速测试 (push) Successful in 8s

This commit is contained in:
2026-03-02 00:19:18 +08:00
parent 24b8d25771
commit 1beb9d3476
+9 -12
View File
@@ -22,22 +22,19 @@ jobs:
- name: PHP 语法检查 - name: PHP 语法检查
run: | run: |
echo "=== 开始 PHP 语法检查 ===" echo "=== PHP 语法检查 ==="
ERRORS=0
# 保存所有 php -l 输出到文件 # 检查每个文件,把错误的文件名记录下来
> /tmp/lint_output.txt
for file in $(find . -name "*.php" -not -path "./vendor/*"); do for file in $(find . -name "*.php" -not -path "./vendor/*"); do
echo ">>> 检查文件: $file" >> /tmp/lint_output.txt if ! php -l "$file" > /dev/null 2>&1; then
php -l "$file" >> /tmp/lint_output.txt 2>&1 echo "❌ 错误文件: $file"
echo "" >> /tmp/lint_output.txt ERRORS=$((ERRORS + 1))
fi
done done
# 显示输出 if [ $ERRORS -gt 0 ]; then
cat /tmp/lint_output.txt echo "=== 发现 $ERRORS 个语法错误 ==="
# 检查是否有错误
if grep -q "Parse error\|Fatal error\|Syntax error" /tmp/lint_output.txt; then
echo "=== 发现语法错误,CI 失败 ==="
exit 1 exit 1
else else
echo "=== 所有 PHP 文件语法正确 ===" echo "=== 所有 PHP 文件语法正确 ==="