Skip to content

PHP version parsed from composer.json is incorrect when exclusive bounds are used #15777

Open
phpstan/phpstan-src
#7115

Description

@cs278

Bug report

If you have a PHP constraint in composer.json that uses exclusive bounds then PHPStan misinterprets them resulting in an off by one issue.

For example:

{"require": {"php": ">8.2.3 < 8.5.2"}}

Executing PHPStan:

$ phpstan diagnose | grep 'PHP '
PHP runtime version: 8.3.36
PHP composer.json required version: 8.2.3-8.5.2
PHP version for analysis: 8.3.36 (from config)

This is most prominent when with a requirement like 8.4.* where PHPStan detects 8.4-8.5 resulting in \PHPStan\dumpType(\PHP_VERSION_ID); returning int<80400, 80500>.

Code snippet that reproduces the problem

No response

Expected output

{"require": {"php": ">8.2.3 < 8.5.2"}}

Should be detected as 8.2.4-8.5.1.

Did PHPStan help you today? Did it make you happy in any way?

Yes, the speed improvements are awesome. 🏎️💨

Activity

  1. mergeable commented on Nov 19, 2026

    @mergeable

    This bug report is missing a link to reproduction at phpstan.org/try.

    It will most likely be closed after manual review.

  2. added this to the Easy fixes milestone on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions