Commit b2c3414b authored by DevPilot's avatar DevPilot

fix(accounting): use statement مكانش ينفع جوه if — واتضاف فحص صياغة شامل

الـ view اتدفع وفيه خطأ صياغة لأن git commit ما بيلنتش. tools/php_lint.sh
بيفحص الـ ٢٣٩٠ ملف PHP في ثواني، وده اللي كان لازم يتشغّل قبل الدفع.
parent d1cdb878
<?php $__template->layout('Layout.main'); ?>
<?php
use App\Modules\Accounting\Services\PeriodCloseReadinessService as RD;
$__template->layout('Layout.main');
?>
<?php $__template->section('title'); ?>إقفال الفترات<?php $__template->endSection(); ?>
......@@ -23,7 +26,6 @@
<?php if ($fiscal_year && !empty($readiness)): ?>
<!-- جاهزية الإقفال -->
<?php
use App\Modules\Accounting\Services\PeriodCloseReadinessService as RD;
$ok = $readiness['can_close'];
$styles = [
RD::PASS => ['#ECFDF5', '#A7F3D0', '#047857', '✓'],
......
#!/usr/bin/env bash
# فحص صياغة كل ملفات PHP.
#
# خطأ صياغة في view واحد بيوقّع الشاشة بالكامل، و`git commit` مش بيشوفه.
# شغّل ده قبل أي push.
#
# tools/php_lint.sh # كل المشروع
# tools/php_lint.sh --staged # الملفات المعدّلة بس (أسرع)
set -uo pipefail
cd "$(dirname "$0")/.." || exit 1
if [ "${1:-}" = "--staged" ]; then
mapfile -t files < <(git diff --name-only --cached --diff-filter=ACM -- '*.php')
[ ${#files[@]} -eq 0 ] && mapfile -t files < <(git diff --name-only --diff-filter=ACM -- '*.php')
else
mapfile -t files < <(find app database public tools -name '*.php' 2>/dev/null)
fi
fails=0
for f in "${files[@]}"; do
[ -f "$f" ] || continue
if ! out=$(php -l "$f" 2>&1); then
echo "$out"
fails=$((fails + 1))
fi
done
echo "فُحص ${#files[@]} ملف، $fails بهم خطأ صياغة"
exit $([ $fails -gt 0 ] && echo 1 || echo 0)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment