feat: composer install with any php linters (#6599)

Install dependencies with Composer when any PHP linter is enabled and
there are files to lint with that linter, not just when Psalm is
enabled.

Close #6336
Close #6598
Close #6597
This commit is contained in:
Marco Ferrari 2025-02-24 13:03:54 +01:00 committed by GitHub
parent b354da5267
commit 9f7f83bca5
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View file

@ -33,7 +33,7 @@ Notes:
- If the default branch for your repository doesn't match the default, you can
use the `DEFAULT_BRANCH` variable to set the default branch. For more
information about the default value of the `DEFAULT_BRANCH` variable, see the
[README](../README.md).
[Readme](../README.md).
- You can add as many configuration options as needed. Configuration options are
documented in the [readme](../README.md#configure-super-linter).

View file

@ -293,9 +293,13 @@ function RunAdditionalInstalls() {
##################################
# Run installs for Psalm and PHP #
##################################
if [ "${VALIDATE_PHP_PSALM}" == "true" ] && [ -e "${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_PSALM" ]; then
if [[ ("${VALIDATE_PHP:-"${VALIDATE_PHP_BUILTIN}"}" == "true" && -e "${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_BUILTIN") ]] ||
[[ ("${VALIDATE_PHP_BUILTIN}" == "true" && -e "${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_BUILTIN") ]] ||
[[ ("${VALIDATE_PHP_PHPCS}" == "true" && -e "${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_PHPCS") ]] ||
[[ ("${VALIDATE_PHP_PHPSTAN}" == "true" && -e "${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_PHPSTAN") ]] ||
[[ ("${VALIDATE_PHP_PSALM}" == "true" && -e "${FILE_ARRAYS_DIRECTORY_PATH}/file-array-PHP_PSALM") ]]; then
# found PHP files and were validating it, need to composer install
info "Found PHP files to validate, and VALIDATE_PHP_PSALM is set to ${VALIDATE_PHP_PSALM}. Check if we need to run composer install"
info "Found PHP files to validate. Check if we need to run composer install"
mapfile -t COMPOSER_FILE_ARRAY < <(find "${GITHUB_WORKSPACE}" -name composer.json 2>&1)
debug "COMPOSER_FILE_ARRAY contents: ${COMPOSER_FILE_ARRAY[*]}"
if [ "${#COMPOSER_FILE_ARRAY[@]}" -ne 0 ]; then