At the begigin of phpunit there is a condition, but i'm lacking of knowledge to understand it:
if (!version_compare(PHP_VERSION, PHP_VERSION, '=')) {
fwrite(
STDERR,
sprintf(
'%s declares an invalid value for PHP_VERSION.' . PHP_EOL .
'This breaks fundamental functionality such as version_compare().' . PHP_EOL .
'Please use a different PHP interpreter.' . PHP_EOL,
PHP_BINARY
)
);
die(1);
}
source: https://github.com/sebastianbergmann/phpunit/blob/main/phpunit
See doc php about version_compare: https://www.php.net/manual/en/function.version-compare.php
Version_compare — Compares two "PHP-standardized" version number strings. But here we are testing the same thing 'PHP_VERSION'.
In which case this condition could be TRUE?
It may be obvious, but I don't understand. Thank you for your help.
If you git-blame the source code there, the commit contains a link to a blog post which explains the problem in detail: https://bbqsoftwares.com/blog/phpunit-big-sur.
In a nutshell: On specific versions of PHP, the internal version number would contain additional text and be technically invalid, breaking some PHPUnit code later on which tests PHP_VERSION
using version_compare
. To preempt this problem later on in the code, the author added this simple check which passes for all regular supported PHP versions, and fails for this specific PHP version which would cause obscure and unintuitive problems otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With