Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ list(
get($year, $day) => &$not_a_wp_global[$year]
] = $array;

// Live coding/parse error.
// This has to be the last test in the file!
list( $tab, $tabs
/*
* $GLOBALS with non-string key, unable to determine if it is a global variable override or not.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahum... it's definitely a global variable override, we just don't know whether it is one we should flag.

Suggested change
* $GLOBALS with non-string key, unable to determine if it is a global variable override or not.
* $GLOBALS with non-string key, unable to determine which variable is being overridden.

*/
$GLOBALS[ "some{$name}" ] = 'test'; // Ok.
$GLOBALS[ $obj->global_name ] = 'test'; // Ok.
$GLOBALS[ MyClass::GLOBAL_NAME ] = 'test'; // Ok.
$GLOBALS[ GLOBAL_NAME_CONSTANT ] = 'test'; // Ok.
$GLOBALS[ get_my_global_name() ] = 'test'; // Ok.
$GLOBALS[ MyNamespace\get_my_global_name() ] = 'test'; // Ok.
$GLOBALS[ \MyNamespace\get_my_global_name() ] = 'test'; // Ok.
$GLOBALS[ namespace\get_my_global_name() ] = 'test'; // Ok.
Comment on lines +317 to +324
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap this test code within a simple function declaration to prevent it potentially affecting other tests in the file. (I vaguely remember we had issues with this in the past, better to prevent new ones in the future ;-) )

8 changes: 8 additions & 0 deletions WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.8.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

/*
* Intentional parse error (missing T_CLOSE_PARENTHESIS).
* This should be the only test in this file.
*/

list( $tab, $tabs
Loading