From a64fad2a9d799b1b68e195e6986f97d63be70b2a Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Sat, 8 Mar 2025 09:18:08 -0500 Subject: [PATCH] Fix psalm install error on future php releases (#930) * Skip running psalm on future PHP releases * Clean up indentation --- composer.json | 3 +-- tests/run.sh | 17 +++++++++++++++++ tests/run_coding_standards_check.sh | 17 +++++++++-------- tests/run_static_analysis_check_psalm.sh | 22 +++++++++++++--------- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index 0e7a8bb..8eb824c 100644 --- a/composer.json +++ b/composer.json @@ -29,8 +29,7 @@ "phpcsstandards/phpcsutils": "@alpha", "phpstan/phpstan": "*", "phpunit/phpunit": "*", - "squizlabs/php_codesniffer": "*", - "vimeo/psalm": ">=5.26.1" + "squizlabs/php_codesniffer": "*" }, "suggest": { "ext-mbstring": "*" diff --git a/tests/run.sh b/tests/run.sh index 4c66954..9a72e44 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -6,6 +6,23 @@ errors=() if [[ "${CI}" == "true" ]]; then composer self-update + + # Skip attempting to install psalm on future PHP releases to avoid the + # following error that would otherwise block the remaining tests from + # running: + # Your requirements could not be resolved to an installable set of packages. + # + # Problem 1 + # - Root composer.json requires vimeo/psalm >=5.26.1 -> satisfiable by vimeo/psalm[5.26.1, 6.0.0, ..., 6.8.8]. + # - vimeo/psalm 5.26.1 requires php ^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 -> your php version (8.5.0-dev) does not satisfy that requirement. + # - vimeo/psalm[6.0.0, ..., 6.5.0] require php ~8.1.17 || ~8.2.4 || ~8.3.0 || ~8.4.0 -> your php version (8.5.0-dev) does not satisfy that requirement. + # - vimeo/psalm[6.5.1, ..., 6.8.8] require php ~8.1.31 || ~8.2.27 || ~8.3.16 || ~8.4.3 -> your php version (8.5.0-dev) does not satisfy that requirement. + # + # Error: Your requirements could not be resolved to an installable set of packages. + if ! "${CI_PHP_FUTURE_RELEASE}"; then + composer require --dev "vimeo/psalm:>=5.26.1" + fi + composer install --prefer-source --no-interaction if [[ "${?}" -ne 0 ]]; then echo "❌ Error: composer install failed" diff --git a/tests/run_coding_standards_check.sh b/tests/run_coding_standards_check.sh index 7f04852..8a6b832 100755 --- a/tests/run_coding_standards_check.sh +++ b/tests/run_coding_standards_check.sh @@ -123,14 +123,15 @@ fi # https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/pull/8300 if [[ $(echo "${CI_PHP_VERSION} < 8.4" | bc -l) -eq 1 ]]; then -# Run PHP-CS-Fixer. -vendor/bin/php-cs-fixer --version -vendor/bin/php-cs-fixer fix --ansi --config="tests/.php-cs-fixer.php" --diff --dry-run -if [[ "${?}" -ne 0 ]]; then - echo "❌ Error: found PHP-CS-Fixer coding standard violation(s)" - errors+=("found PHP-CS-Fixer coding standard violation(s)") -fi - + # Run PHP-CS-Fixer. + vendor/bin/php-cs-fixer --version + vendor/bin/php-cs-fixer fix --ansi --config="tests/.php-cs-fixer.php" --diff --dry-run + if [[ "${?}" -ne 0 ]]; then + echo "❌ Error: found PHP-CS-Fixer coding standard violation(s)" + errors+=("found PHP-CS-Fixer coding standard violation(s)") + fi +else + echo "⚠️ Skipped running PHP-CS-Fixer coding standards check" fi popd diff --git a/tests/run_static_analysis_check_psalm.sh b/tests/run_static_analysis_check_psalm.sh index 2f1c048..2c5b6e2 100755 --- a/tests/run_static_analysis_check_psalm.sh +++ b/tests/run_static_analysis_check_psalm.sh @@ -10,17 +10,21 @@ pushd .. set -x -vendor/bin/psalm --version - -if [[ $(echo "${CI_PHP_VERSION} == 7.4" | bc -l) -eq 1 ]]; then - vendor/bin/psalm --config="tests/psalm_7.4.xml" +if [[ ! -f "vendor/bin/psalm" ]]; then + echo "⚠️ Skipped running psalm static analysis check" else - vendor/bin/psalm --config="tests/psalm.xml" -fi + vendor/bin/psalm --version -if [[ "${?}" -ne 0 ]]; then - echo "❌ Error: psalm static analysis check failed" - errors+=("psalm static analysis check failed") + if [[ $(echo "${CI_PHP_VERSION} == 7.4" | bc -l) -eq 1 ]]; then + vendor/bin/psalm --config="tests/psalm_7.4.xml" + else + vendor/bin/psalm --config="tests/psalm.xml" + fi + + if [[ "${?}" -ne 0 ]]; then + echo "❌ Error: psalm static analysis check failed" + errors+=("psalm static analysis check failed") + fi fi popd