1- # Reusable workflow: runs `php -l` on every PHP source file across a matrix
2- # of all supported PHP versions . Catches parse errors before any runtime
3- # testing. No artifact needed — only requires a source checkout. Runs in
4- # parallel with the build job in qa.yml .
1+ # Reusable workflow: runs `php -l` on every PHP source file for all supported
2+ # PHP versions in a single job (sequential) . Catches parse errors before any
3+ # runtime testing. No artifact needed — only requires a source checkout.
4+ # Single job eliminates per-version runner startup overhead vs. a matrix .
55
66name : QA - PHP Syntax Check
77
1414jobs :
1515 php-syntax-check :
1616 runs-on : ubuntu-24.04
17- strategy :
18- fail-fast : false
19- matrix :
20- php-version : ["7.4", "8.2", "8.5"]
21- name : PHP ${{ matrix.php-version }} Syntax Check
17+ name : PHP Syntax Check (7.4, 8.2, 8.5)
2218 steps :
2319 - uses : actions/checkout@v4
2420
25- - name : Setup PHP ${{ matrix.php-version }}
26- uses : shivammathur/setup-php@v2
27- with :
28- php-version : ${{ matrix.php-version }}
29-
30- - name : PHP Syntax Check (PHP ${{ matrix.php-version }})
21+ - name : Find PHP files
22+ id : find
3123 run : |
3224 FILES=$(find . -name "*.php" \
3325 -not -path "./vendor/*" \
3426 -not -path "./node_modules/*" \
3527 -not -path "./.git/*")
28+ echo "TOTAL=$(echo "$FILES" | wc -l | tr -d ' ')" >> "$GITHUB_ENV"
29+ # Write file list to a temp file so all steps share it
30+ echo "$FILES" > /tmp/php_files.txt
31+
32+ # ── PHP 7.4 ────────────────────────────────────────────────────────────
33+ - name : Setup PHP 7.4
34+ uses : shivammathur/setup-php@v2
35+ with :
36+ php-version : " 7.4"
37+
38+ - name : PHP Syntax Check (PHP 7.4)
39+ run : |
40+ ERRORS=0
41+ while IFS= read -r file; do
42+ OUTPUT=$(php -l "$file" 2>&1)
43+ if [ $? -ne 0 ]; then
44+ echo "::error file=$file::$OUTPUT"
45+ ERRORS=$((ERRORS + 1))
46+ fi
47+ done < /tmp/php_files.txt
48+ if [ "$ERRORS" -gt 0 ]; then
49+ echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 7.4"
50+ exit 1
51+ fi
52+ echo "✅ All $TOTAL PHP files passed syntax check on PHP 7.4"
3653
54+ # ── PHP 8.2 ────────────────────────────────────────────────────────────
55+ - name : Setup PHP 8.2
56+ uses : shivammathur/setup-php@v2
57+ with :
58+ php-version : " 8.2"
59+
60+ - name : PHP Syntax Check (PHP 8.2)
61+ run : |
3762 ERRORS=0
3863 while IFS= read -r file; do
3964 OUTPUT=$(php -l "$file" 2>&1)
4065 if [ $? -ne 0 ]; then
4166 echo "::error file=$file::$OUTPUT"
4267 ERRORS=$((ERRORS + 1))
4368 fi
44- done <<< "$FILES"
69+ done < /tmp/php_files.txt
70+ if [ "$ERRORS" -gt 0 ]; then
71+ echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 8.2"
72+ exit 1
73+ fi
74+ echo "✅ All $TOTAL PHP files passed syntax check on PHP 8.2"
75+
76+ # ── PHP 8.5 ────────────────────────────────────────────────────────────
77+ - name : Setup PHP 8.5
78+ uses : shivammathur/setup-php@v2
79+ with :
80+ php-version : " 8.5"
4581
46- TOTAL=$(echo "$FILES" | wc -l | tr -d ' ')
82+ - name : PHP Syntax Check (PHP 8.5)
83+ run : |
84+ ERRORS=0
85+ while IFS= read -r file; do
86+ OUTPUT=$(php -l "$file" 2>&1)
87+ if [ $? -ne 0 ]; then
88+ echo "::error file=$file::$OUTPUT"
89+ ERRORS=$((ERRORS + 1))
90+ fi
91+ done < /tmp/php_files.txt
4792 if [ "$ERRORS" -gt 0 ]; then
48- echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP ${{ matrix.php-version }} "
93+ echo "::error::PHP syntax errors found in $ERRORS / $TOTAL file(s) on PHP 8.5 "
4994 exit 1
5095 fi
51- echo "✅ All $TOTAL PHP files passed syntax check on PHP ${{ matrix.php-version }} "
96+ echo "✅ All $TOTAL PHP files passed syntax check on PHP 8.5 "
0 commit comments