Minimum PHP version for next major version
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.
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).
👍 for 7.1.
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.
As it's now one year later, I wonder whether PHP 7.1 is still the right target?
As for Rector and PHPStan, both now require PHP 7.2+ (in downgraded versions).
FWIW you could require PHP 8 and it would still be fine for PHPStan + Rector 😊
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:

It definitely feels like 7.4 is a good target.
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?
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?
I think I'm going to stick with 7.1 for now, for the sake of simplicity. That should affect about zero people.
Given how another year has passed in the meantime (ooops), I'll probably go for a PHP 7.4 requirement after all.
Thanks :clap:
With Rector downgrade, the low PHP version-compatibility is pieces of cake :+1: