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 语法检查
run: |
echo "=== 开始 PHP 语法检查 ==="
echo "=== PHP 语法检查 ==="
ERRORS=0
# 保存所有 php -l 输出到文件
> /tmp/lint_output.txt
# 检查每个文件,把错误的文件名记录下来
for file in $(find . -name "*.php" -not -path "./vendor/*"); do
echo ">>> 检查文件: $file" >> /tmp/lint_output.txt
php -l "$file" >> /tmp/lint_output.txt 2>&1
echo "" >> /tmp/lint_output.txt
if ! php -l "$file" > /dev/null 2>&1; then
echo "❌ 错误文件: $file"
ERRORS=$((ERRORS + 1))
fi
done
# 显示输出
cat /tmp/lint_output.txt
# 检查是否有错误
if grep -q "Parse error\|Fatal error\|Syntax error" /tmp/lint_output.txt; then
echo "=== 发现语法错误,CI 失败 ==="
if [ $ERRORS -gt 0 ]; then
echo "=== 发现 $ERRORS 个语法错误 ==="
exit 1
else
echo "=== 所有 PHP 文件语法正确 ==="