#!/bin/bash set -u echo "========================" echo " Davidson CI - PHP" echo "========================" PHP_COUNT="${DAVIDSON_PHP_COUNT:-0}" PHP_STATUS="SKIP" set_status() { PHP_STATUS="$1" echo "DAVIDSON_PHP_STATUS=$PHP_STATUS" >> "${GITHUB_ENV:-/dev/null}" } if [ "$PHP_COUNT" -eq 0 ]; then echo "No PHP files detected - skipping PHP module" set_status "SKIP" exit 0 fi echo echo "PHP files detected: $PHP_COUNT" echo FAIL=0 echo "→ PHP syntax" if ! find . \ -type f \ -name "*.php" \ -not -path "./vendor/*" \ -print0 | xargs -0 -n1 php -l then FAIL=1 fi echo echo "→ Composer" if [ -f composer.json ]; then if ! composer validate --no-check-publish; then FAIL=1 fi if [ -f composer.lock ]; then if ! composer install \ --no-interaction \ --prefer-dist \ --no-progress then FAIL=1 fi else echo "composer.json found but no composer.lock" fi else echo "No composer.json - skipping Composer" fi echo echo "→ PHPStan" if [ -x vendor/bin/phpstan ]; then if ! vendor/bin/phpstan analyse; then FAIL=1 fi else echo "PHPStan not installed - skipping" fi echo echo "→ PHPUnit" if [ -x vendor/bin/phpunit ]; then if ! vendor/bin/phpunit; then FAIL=1 fi else echo "PHPUnit not installed - skipping" fi if [ "$FAIL" -eq 0 ]; then set_status "PASS" echo echo "PHP module completed successfully" exit 0 else set_status "FAIL" echo echo "PHP module failed" exit 1 fi