Skip to content
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

PHPUnit 8.5 incompatibility with PHP 8.1 #4575

Closed
nikic opened this issue Jan 7, 2021 · 1 comment · Fixed by multitheftauto/mtasa-php-sdk#88
Closed

PHPUnit 8.5 incompatibility with PHP 8.1 #4575

nikic opened this issue Jan 7, 2021 · 1 comment · Fixed by multitheftauto/mtasa-php-sdk#88
Assignees
Labels
type/change-in-php-requires-adaptation A change in PHP requires a change in PHPUnit

Comments

@nikic
Copy link

nikic commented Jan 7, 2021

Q A
PHPUnit version 8.5
PHP version 8.1-dev
Installation Method Composer

Summary

$target = &$GLOBALS;
throws a compile-time error as a result of https://wiki.php.net/rfc/restrict_globals_usage. This issue only exists in PHPUnit 8 and lower, not in PHPUnit 9.

If I understand the purpose of the code right, I think this would be a good way to fix the issue:

foreach ($configuration[$array] as $name => $data) {
    $GLOBALS[$name] = $data['value'];
    $_SERVER[$name] = $data['value'];
    $_POST[$name] = $data['value'];
    $_GET[$name] = $data['value'];
    $_REQUEST[$name] = $data['value'];
    $_COOKIE[$name] = $data['value'];
    $_FILES[$name] = $data['value'];
}

In this case the code that tries to abstract over the different arrays makes things more complicated than just directly assigning all of them, due to the special cases that need to be handled.

@nikic nikic added the type/bug Something is broken label Jan 7, 2021
@sebastianbergmann sebastianbergmann added type/change-in-php-requires-adaptation A change in PHP requires a change in PHPUnit and removed type/bug Something is broken labels Jan 7, 2021
@sebastianbergmann
Copy link
Owner

Thank you for bringing this to my attention, I will work on this as soon as possible.

@sebastianbergmann sebastianbergmann self-assigned this Jan 7, 2021
sebastianbergmann added a commit that referenced this issue Jan 7, 2021
This was referenced Mar 12, 2021
jrfnl added a commit to jrfnl/BrainMonkey that referenced this issue Nov 11, 2021
While PHPUnit as of version 8.5.12 allows for installation on PHP 8.0, it still contained a [nasty bug](sebastianbergmann/phpunit#4575) which would error out the test run with a Fatal.

This bug was fixed in version 8.5.14.

This adjustment of the version constraint means that when `composer install` is run with `--prefer-lowest` on PHP 8.0.x, PHPUnit 8.5.14 will be installed instead of PHP 8.5.12, while still allowing for all other versions in all other circumstances.

Ref: https://github.com/sebastianbergmann/phpunit/blob/8.5/ChangeLog-8.5.md
jrfnl added a commit to jrfnl/BrainMonkey that referenced this issue Nov 11, 2021
While PHPUnit as of version 8.5.12 allows for installation on PHP 8.0, it still contained a [nasty bug](sebastianbergmann/phpunit#4575) which would error out the test run with a Fatal when PHPUnit 8.5.12 would be installed for PHP 8.1.

This bug was fixed in version 8.5.14.

This adjustment of the version constraints means that when `composer install` is run with `--prefer-lowest` on PHP 8.x, PHPUnit 8.5.14 will be installed instead of PHP 8.5.12, while still allowing for all other 8.x versions in all other circumstances.

Ref: https://github.com/sebastianbergmann/phpunit/blob/8.5/ChangeLog-8.5.md
jrfnl added a commit to Brain-WP/BrainMonkey that referenced this issue Nov 11, 2021
While PHPUnit as of version 8.5.12 allows for installation on PHP 8.0, it still contained a [nasty bug](sebastianbergmann/phpunit#4575) which would error out the test run with a Fatal when PHPUnit 8.5.12 would be installed for PHP 8.1.

This bug was fixed in version 8.5.14.

This adjustment of the version constraints means that when `composer install` is run with `--prefer-lowest` on PHP 8.x, PHPUnit 8.5.14 will be installed instead of PHP 8.5.12, while still allowing for all other 8.x versions in all other circumstances.

Ref: https://github.com/sebastianbergmann/phpunit/blob/8.5/ChangeLog-8.5.md
Firehed added a commit to Firehed/container that referenced this issue Oct 18, 2022
Firehed added a commit to Firehed/container that referenced this issue Oct 18, 2022
* Test on 8.1 and 8.2

* Bump min phpunit version: sebastianbergmann/phpunit#4575

* Add attribute for newer php versions

* Fix warning about possible missing offset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/change-in-php-requires-adaptation A change in PHP requires a change in PHPUnit
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants