Skip to content

Commit 637711c

Browse files
authored
WP/GlobalVariablesOverride: more tests covering unresolvable $GLOBALS keys (#2580)
* WP/GlobalVariablesOverride: more tests covering unresolvable `$GLOBALS` keys
1 parent cb9cf4d commit 637711c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,17 @@ class AsymmetricVisibilityProperties {
320320

321321
public function __construct(public protected(set) int $page = 0) {} // Ok.
322322
}
323+
324+
/*
325+
* $GLOBALS with non-string key, unable to determine which variable is being overridden.
326+
*/
327+
function globals_with_non_string_key() {
328+
$GLOBALS[ "some{$name}" ] = 'test'; // Ok.
329+
$GLOBALS[ $obj->global_name ] = 'test'; // Ok.
330+
$GLOBALS[ MyClass::GLOBAL_NAME ] = 'test'; // Ok.
331+
$GLOBALS[ GLOBAL_NAME_CONSTANT ] = 'test'; // Ok.
332+
$GLOBALS[ get_my_global_name() ] = 'test'; // Ok.
333+
$GLOBALS[ MyNamespace\get_my_global_name() ] = 'test'; // Ok.
334+
$GLOBALS[ \MyNamespace\get_my_global_name() ] = 'test'; // Ok.
335+
$GLOBALS[ namespace\get_my_global_name() ] = 'test'; // Ok.
336+
}

0 commit comments

Comments
 (0)