fix: 改进 PHP 语法检查输出
Test CI / 快速测试 (push) Failing after 2s

This commit is contained in:
2026-03-01 23:47:29 +08:00
parent 4e964c8a18
commit bbcd2eb80f
+12 -12
View File
@@ -23,19 +23,19 @@ jobs:
- name: PHP 语法检查
run: |
echo "📝 PHP 语法检查..."
errors=0
for file in $(find . -name "*.php" -not -path "./vendor/*"); do
if ! php -l "$file" > /dev/null 2>&1; then
echo "❌ 语法错误: $file"
php -l "$file" || true
errors=$((errors + 1))
fi
done
if [ $errors -eq 0 ]; then
echo "✅ 所有 PHP 文件语法正确"
else
echo "❌ 发现 $errors 个语法错误"
# 检查所有 PHP 文件(排除 vendor),保存完整输出
{
find . -name "*.php" -not -path "./vendor/*" -exec sh -c 'php -l "$1" 2>&1 || true' _ {} \;
} > /tmp/lint_output.txt
# 检查是否有错误
if grep -q "^Parse error\|^Fatal error\|^Syntax error" /tmp/lint_output.txt; then
echo "❌ PHP 语法错误:"
cat /tmp/lint_output.txt
exit 1
else
echo "✅ 所有 PHP 文件语法正确"
fi
# 单元测试