PHP-Parser icon indicating copy to clipboard operation
PHP-Parser copied to clipboard

Minimum PHP version for next major version

Open nikic opened this issue 5 years ago • 10 comments

I'm wondering what minimum PHP version I should target for the next major version of this library. I think the viable choices are:

  • PHP 7.1: Nullable types.
  • PHP 7.4: Property types.

Targeting any of the versions in between is not worthwhile. I think this library would benefit from property types a lot, because the whole AST structure is represented using public properties, but I'm not sure if PHP 7.4 isn't jumping the gun a bit, given the amount of dependents this library has.

nikic avatar Jun 27 '20 17:06 nikic

My vote for 7.1 is due to the widespread use of this library and being a critical infrastructure project for many.

(Personally I've 7.4 everywhere and on top of my head I can't name anything my projects depend on which requires this library, so I'm not saying this just for my own benefit).

Since you only want to give two options, I usually also go by https://www.php.net/supported-versions.php 7.1 is already EOL, otherwise I would have said 7.2 (but then again depends on when do you plan the new release).

mfn avatar Jun 27 '20 19:06 mfn

👍 for 7.1.

GrahamCampbell avatar Aug 09 '20 10:08 GrahamCampbell

PHPStan needs php-parser to support PHP 7.1, but I'd respect a different decision, I can transform the sources to be 7.1-compatible during the PHAR build.

ondrejmirtes avatar Aug 14 '20 20:08 ondrejmirtes

As it's now one year later, I wonder whether PHP 7.1 is still the right target?

nikic avatar Jun 04 '22 11:06 nikic

As for Rector and PHPStan, both now require PHP 7.2+ (in downgraded versions).

TomasVotruba avatar Jun 04 '22 11:06 TomasVotruba

FWIW you could require PHP 8 and it would still be fine for PHPStan + Rector 😊

ondrejmirtes avatar Jun 04 '22 12:06 ondrejmirtes

Even PHP 8.2 :wink:

But packagist might be more useful about general usage: https://packagist.org/packages/nikic/php-parser/php-stats#4

This is overview of PHP version that use of php-parser 4.* as for today:

image

TomasVotruba avatar Jun 05 '22 09:06 TomasVotruba

It definitely feels like 7.4 is a good target.

djmattyg007 avatar Jun 10 '22 22:06 djmattyg007

FWIW you could require PHP 8 and it would still be fine for PHPStan + Rector

I'm not sure that would actually work. If I dropped support for old versions I'd also drop the token emulation code for those, and I believe you'd still need that?

nikic avatar Jun 12 '22 19:06 nikic

Oh yeah, sure, those are super useful. It allows us to run PHPStan on a certain PHP version, and analyse the code as if it was for a different PHP version.

It'd be impossible for you to test these emulations because you couldn't run PHP-Parser on an old PHP version, but maybe it's sufficient to give some kind of API for that and let the emulations be a userland respnsibility?

ondrejmirtes avatar Jun 12 '22 19:06 ondrejmirtes

I think I'm going to stick with 7.1 for now, for the sake of simplicity. That should affect about zero people.

nikic avatar Aug 28 '22 17:08 nikic

Given how another year has passed in the meantime (ooops), I'll probably go for a PHP 7.4 requirement after all.

nikic avatar Aug 13 '23 14:08 nikic

Thanks :clap:

With Rector downgrade, the low PHP version-compatibility is pieces of cake :+1:

TomasVotruba avatar Aug 13 '23 17:08 TomasVotruba