Skip to content

PHPUnit 8.5 incompatibility with PHP 8.1 #4575

@nikic

Description

@nikic
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.

Metadata

Metadata

Labels

type/change-in-php-requires-adaptationA change in PHP requires a change so that existing PHPUnit functionality continues to work

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions