Remove max php version from composer.json
$ composer require --dev vimeo/psalm
Cannot use vimeo/psalm's latest version 6.13.1 as it requires php ~8.1.31 || ~8.2.27 || ~8.3.16 || ~8.4.3 which is not satisfied by your platform.
Lock file operations: 2 installs, 0 updates, 0 removals
- Locking vimeo/psalm (0.3.14)
I use alpha PHP versions locally for testing (PHP 8.5), so when I tried installing psalm, composer just installed version 0.3 which is really wack behavior of composer to be honest. Adding --ignore-platform-reqs of course installs the latest version.
Hey @xPaw, can you reproduce the issue on https://psalm.dev? These will be used as phpunit tests when implementing the feature or fixing this bug.
Psalm is not yet tested with PHP 8.5. We can't guarantee it's working properly so there's no reason to allow installation for it yet.
You're using the --ignore-platform-reqs in a correct way here.
If you do find any issue or if you wish to push a PR adding tests for PHP 8.5 and showing it works, it would be appreciated :)
Note that composer is behaving perfectly correctly. There must have been a time long ago when Psalm's constraints allowed PHP 8.5. This was a mistake, if it wasn't made, Composer would have correctly told you Psalm couldn't be installed at all
I feel like this would be better as a runtime warning (CS fixer does this), otherwise getting a version from 2017 installed is silly.
I dont use 8.5 features, just the the runtime to test my own code.
To prevent installation of old versions, you can add the constraint:
composer require --ignore-platform-reqs --dev vimeo/psalm:^6
I have issue like this
Running on PHP 8.1.33, Psalm 6.13.1@1e3b7f0a8ab32b23197b91107adc0a7ed8a05b51.
JIT acceleration: ON
JIT compilation in progress... Uncaught ParseError: syntax error, unexpected identifier "OLD", expecting "=" in /home/runner/work/CodeIgniter4/CodeIgniter4/utils/vendor/sebastian/diff/src/Differ.php:33 Stack trace: #0 /home/runner/work/CodeIgniter4/CodeIgniter4/vendor/composer/ClassLoader.php(427): Composer\Autoload{closure}() #1 [internal function]: Composer\Autoload\ClassLoader->loadClass() #2 /home/runner/work/CodeIgniter4/CodeIgniter4/utils/vendor/vimeo/psalm/src/Psalm/Internal/Preloader.php(27): class_exists() #3 /home/runner/work/CodeIgniter4/CodeIgniter4/utils/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(1050): Psalm\Internal\Preloader::preload() #4 /home/runner/work/CodeIgniter4/CodeIgniter4/utils/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(290): Psalm\Internal\Cli\Psalm::restart() #5 /home/runner/work/CodeIgniter4/CodeIgniter4/utils/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run() #6 /home/runner/work/CodeIgniter4/CodeIgniter4/utils/vendor/bin/psalm(119): include('...') #7 {main} (Psalm 6.13.1@1e3b7f0a8ab32b23197b91107adc0a7ed8a05b51 crashed due to an uncaught Throwable)
Psalm is not yet tested with PHP 8.5. We can't guarantee it's working properly so there's no reason to allow installation for it yet.
I’d encourage reconsidering this approach. Setting an upper bound on PHP versions in composer.json often blocks projects from adopting new, stable PHP releases even when no actual incompatibilities exist. This can slow down upgrades, security patch adoption, and testing on pre-release or just-released PHP versions.
It's a much better developer experience when packages only specify a minimum version. This approach lets proactive developers help catch issues early, and those on the leading edge can run Psalm immediately after a PHP release, rather than having to wait for a version constraint bump. Of course those proactive developers can install newer versions with --ignore-platform-reqs, but most will not want to add that to their CI pipeline when packaging production code, blocking them from moving to the new PHP version.
I've had this same issue with a large number of packages with every PHP version upgrade over the past years and have contributed many PRs that do nothing more than change the PHP version constraint in composer.json (which feels very unnecessary).
Any news on the PHP 8.5 upgrade?
Is it possible to prevent this check when running PSALM using --ignore-platform-reqs, this allow early adopters to test new version of PHP, but check for common users.