Skip to content

Commit 58afa65

Browse files
committed
WP/DiscouragedConstants: add tests for namespaced function calls
Add tests safeguarding that namespaced calls to functions named `define` are handled correctly.
1 parent c16b933 commit 58afa65

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

WordPress/Tests/WP/DiscouragedConstantsUnitTest.inc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,11 @@ enum ContainsConst {
102102
}
103103

104104
echo HEADER_TEXTCOLOR::$var; // OK.
105+
106+
/*
107+
* Safeguard correct handling of all types of namespaced function calls.
108+
*/
109+
\define( 'STYLESHEETPATH', 'something' ); // Bad.
110+
\MyNamespace\define( 'STYLESHEETPATH', 'something' ); // Ok.
111+
MyNamespace\define( 'STYLESHEETPATH', 'something' ); // Ok.
112+
namespace\define( 'STYLESHEETPATH', 'something' ); // Ok.

WordPress/Tests/WP/DiscouragedConstantsUnitTest.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,27 @@ public function getErrorList() {
3636
*/
3737
public function getWarningList() {
3838
return array(
39-
50 => 1,
40-
51 => 1,
41-
52 => 1,
42-
53 => 1,
43-
54 => 1,
44-
55 => 1,
45-
56 => 1,
46-
57 => 1,
47-
58 => 1,
48-
59 => 1,
49-
60 => 1,
50-
61 => 1,
51-
63 => 1,
52-
64 => 1,
53-
66 => 1,
54-
67 => 1,
55-
71 => 1,
56-
72 => 1,
57-
83 => 1,
58-
88 => 1,
39+
50 => 1,
40+
51 => 1,
41+
52 => 1,
42+
53 => 1,
43+
54 => 1,
44+
55 => 1,
45+
56 => 1,
46+
57 => 1,
47+
58 => 1,
48+
59 => 1,
49+
60 => 1,
50+
61 => 1,
51+
63 => 1,
52+
64 => 1,
53+
66 => 1,
54+
67 => 1,
55+
71 => 1,
56+
72 => 1,
57+
83 => 1,
58+
88 => 1,
59+
109 => 1,
5960
);
6061
}
6162
}

0 commit comments

Comments
 (0)