lint.yml 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. name: "PHP Lint"
  2. on:
  3. - push
  4. - pull_request
  5. permissions:
  6. contents: read
  7. jobs:
  8. tests:
  9. name: "Lint"
  10. runs-on: ubuntu-latest
  11. strategy:
  12. matrix:
  13. php-version:
  14. - "8.1"
  15. - "nightly"
  16. steps:
  17. - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
  18. - uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
  19. with:
  20. php-version: "${{ matrix.php-version }}"
  21. coverage: none
  22. - name: "Lint PHP files"
  23. run: |
  24. hasErrors=0
  25. for f in $(find src/ tests/ -type f -name '*.php' ! -path '*/vendor/*' ! -path '*/Fixtures/*')
  26. do
  27. { error="$(php -derror_reporting=-1 -ddisplay_errors=1 -l -f $f 2>&1 1>&3 3>&-)"; } 3>&1;
  28. if [ "$error" != "" ]; then
  29. while IFS= read -r line; do echo "::error file=$f::$line"; done <<< "$error"
  30. hasErrors=1
  31. fi
  32. done
  33. if [ $hasErrors -eq 1 ]; then
  34. exit 1
  35. fi