New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prohibit using PHPUnit with unsupported versions of PHP #3799
Comments
Note: this is super-annoying when people are working on bleeding edge, but |
PHPUnit 9 will support PHP 7.3, PHP 7.4, and PHP 8.0. Starting with that version, we will enforce the PHP version supported by PHPUnit. For Composer this is easy: --- a/composer.json
+++ b/composer.json
@@ -21,7 +21,7 @@
},
"prefer-stable": true,
"require": {
- "php": "^7.2",
+ "php": "7.3.* || 7.4.* || 8.0.*",
"ext-dom": "*",
"ext-json": "*",
"ext-libxml": "*",
@@ -52,7 +52,7 @@
},
"config": {
"platform": {
- "php": "7.2.0"
+ "php": "7.3.0"
},
"optimize-autoloader": true,
"sort-packages": true As @Ocramius already commented, However, I would also like to enforce the maximum supported version of PHP on startup, just like we already do for the minimum required version of PHP. Simply doing --- a/phpunit
+++ b/phpunit
@@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/
-if (version_compare('7.2.0', PHP_VERSION, '>')) {
+if (!in_array(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, ['7.3', '7.4', '8.0'])) {
fwrite(
STDERR,
sprintf(
- 'This version of PHPUnit is supported on PHP 7.2, PHP 7.3, and PHP 7.4.' . PHP_EOL .
+ 'This version of PHPUnit is supported on PHP 7.3, PHP 7.4, and PHP 8.0.' . PHP_EOL .
'You are using PHP %s (%s).' . PHP_EOL,
PHP_VERSION,
PHP_BINARY would render the aforementioned --- a/phpunit
+++ b/phpunit
@@ -9,11 +9,12 @@
* file that was distributed with this source code.
*/
-if (version_compare('7.2.0', PHP_VERSION, '>')) {
+if (!isset($_ENV['PHPUNIT_IGNORE_PHP_VERSION']) &&
+ !in_array(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, ['7.3', '7.4', '8.0'])) {
fwrite(
STDERR,
sprintf(
- 'This version of PHPUnit is supported on PHP 7.2, PHP 7.3, and PHP 7.4.' . PHP_EOL .
+ 'This version of PHPUnit is supported on PHP 7.3, PHP 7.4, and PHP 8.0.' . PHP_EOL .
'You are using PHP %s (%s).' . PHP_EOL,
PHP_VERSION,
PHP_BINARY This approach also allows PHPUnit itself to be tested against "bleeding edge" PHP versions. |
Please do not enforce a maximum version of PHP on startup. That doesn't help anyone, but adds more annoyance on top of |
That is indeed annoying, but it is also true that folks running on bleeding edge can set |
Just throwing it out: Add The problem right now is that there's a fairly large lag between work on a new PHP version starting and PHPUnit releasing an officially compatible version -- in good conscience, PHPUnit can only really do that very late in the release cycle, because there might still be breaking changes otherwise. PHP 8 is the first time this really shows up due to the way constraints were written, but this is going to be a larger problem with the suggested change to use strict version ranges. We want to encourage people to test Allowing the next |
Just to clarify: PHPUnit 8 does not have, and will not get, a check that enforces the maximum supported version (which is PHP 7.4). |
I have no problem with Would this be good enough for you, @nikic? |
@sebastianbergmann Possibly, I'm not sure how that would look like in practice. Would you have to include
The point of allowing the development snapshot of PHP in the stable release is specifically that the release will not be compatible with the next PHP version when it becomes stable. It allows tiding over CI testing until a PHPUnit version with full support is released, but the new stable PHP version is explicitly not going to be supported on the old PHPUnit version, and composer will force you to use the new PHPUnit version once that time rolls around. At least that's what I had in mind. |
People are trying to use PHPUnit 7 with PHP 7.4, for instance, and Composer does not prevent them from doing so due to
"php": "^7.1"
incomposer.json
. Similarly,phpunit.phar
has no measure for preventing it from being used with PHP versions that are too new. Both mechanisms, Composer and PHAR, of course ensure that PHPUnit is not used with versions of PHPUnit that are too old.@Ocramius, for instance, is considering similar measures for his projects, see Ocramius/ProxyManager#492 for reference.
The text was updated successfully, but these errors were encountered: