extract($GLOBALS, EXTR_REFS); is broken in php8.1
Description
The following code:
<?php
$g=5;
(function(){
extract($GLOBALS, EXTR_REFS);
var_dump($g);
$g=6;
})();
var_dump($g);
Resulted in this output:
int(5)
int(5)
as of 8.1, but in php <8.1 it results in this output:
int(5)
int(6)
3v4l: https://3v4l.org/VrkkL
PHP Version
PHP 8.1
Operating System
No response
This BC break is documented:
However, write access to the entire $GLOBALS array is no longer supported.
Do we need to improve the documentation?
TIL, thanks.
For example, array_pop($GLOBALS) will result in an error.
puzzling that we don't get an error in this case, maybe extract($GLOBALS, EXTR_REFS); should also throw an error? "EXTR_REFS" is explicitly requesting write access after all 🤔
This issue is not specific to extract(), but rather affects all parameters which @prefer-ref (you can grep these in *.stub.php; there are not many). Given that there is no warning/error when you pass a value, I don't think that passing $GLOBALS should warn/error either.
I guess instead we want to get rid of @prefer-ref altogether.
No feedback was provided. The issue is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so. Thank you.