Skip to content

narrow scope on version_compare( PHP_VERSION, '8.4', '<' ) #13904

@staabm

Description

@staabm

Feature request

In phpstan/phpstan-src#3642 we added php version dependent narrowing for conditions checking PHP_VERSION_ID, like e.g. if (PHP_VERSION_ID >= 80000) {}.

there are more conditions which narrow the php version which could re-use the implemented logic to narrow the php-version in Scope. examples are

  • version_compare( PHP_VERSION, '8.4', '<' )
  • version_compare( PHP_VERSION, '8.4' ) === 1

maybe we can just re-write the AST in case version_compare is invoked with PHP_VERSION in one of the 2 version parameters?

https://phpstan.org/r/1eab8f33-e339-4c4a-addc-f1274d5d06a4


refs phpstan/phpstan-deprecation-rules#162

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions