Skip to content

Commit 4086bb0

Browse files
committed
ConstantsHelper::is_use_of_global_constant(): do not treat use const alias as global constant usage
This method was incorrectly identifying a constant alias as a global constant. This change aligns this method with how the sibling method in PHPCompatibility behaves (https://github.com/PHPCompatibility/PHPCompatibility/blob/6e10469b0f3827862b37df2ac2b7ec4580ce888f/PHPCompatibility/Helpers/MiscHelper.php#L45).
1 parent a94350c commit 4086bb0

3 files changed

Lines changed: 2 additions & 2 deletions

File tree

WordPress/Helpers/ConstantsHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public static function is_use_of_global_constant( File $phpcsFile, $stackPtr ) {
7979
\T_INSTANCEOF => true,
8080
\T_INSTEADOF => true,
8181
\T_GOTO => true,
82+
\T_AS => true,
8283
);
8384
$tokens_to_ignore += Tokens::$ooScopeTokens;
8485
$tokens_to_ignore += Collections::objectOperators();

WordPress/Tests/WP/DiscouragedConstantsUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ echo BACKGROUND_COLOR;
6161
echo BACKGROUND_IMAGE;
6262

6363
use const STYLESHEETPATH as SSP;
64-
use const ABC as STYLESHEETPATH;
64+
use const ABC as STYLESHEETPATH; // This is ok, as `STYLESHEETPATH` is not a global constant here.
6565

6666
switch( STYLESHEETPATH ) {
6767
case STYLESHEETPATH:

WordPress/Tests/WP/DiscouragedConstantsUnitTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public function getWarningList() {
4949
60 => 1,
5050
61 => 1,
5151
63 => 1,
52-
64 => 1,
5352
66 => 1,
5453
67 => 1,
5554
71 => 1,

0 commit comments

Comments
 (0)