We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
$GLOBALS
1 parent cb9cf4d commit 637711cCopy full SHA for 637711c
1 file changed
WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc
@@ -320,3 +320,17 @@ class AsymmetricVisibilityProperties {
320
321
public function __construct(public protected(set) int $page = 0) {} // Ok.
322
}
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