Skip to content

Commit 602d9ef

Browse files
committed
GlobalVariablesOverride: move parse error test to separate file
... as it would cause a fixer conflict with the new rules. As the fixer conflict is directly related to the parse error, I'm not concerned about it and I don't believe a fix is needed for the sniff. Excluding this particular parse error file from the fixer conflict check should be an acceptable solution.
1 parent dfc72e4 commit 602d9ef

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

.github/workflows/basic-qa.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
continue-on-error: true
153153
run: |
154154
set +e
155-
$(pwd)/vendor/bin/phpcbf -pq ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary --ignore=/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.inc
155+
$(pwd)/vendor/bin/phpcbf -pq ./WordPress/Tests/ --standard=WordPress --extensions=inc --exclude=Generic.PHP.Syntax --report=summary --ignore=/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.inc,/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.7.inc
156156
exitcode="$?"
157157
echo "EXITCODE=$exitcode" >> $GITHUB_OUTPUT
158158
exit "$exitcode"

WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.1.inc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,20 @@ function global_vars() {
183183
return $closure( $pagenow ); // OK, not an assignment.
184184
}
185185

186-
// Verify skipping over rest of the function when live coding/parse error in nested scope structure.
187-
function global_vars() {
188-
global $pagenow;
189186

190-
$closure = function ( $pagenow ) {
191-
global $feeds;
192187

193-
$nested_closure_with_parse_error = function ( $feeds )
194188

195-
$feeds = 'something'; // Bad, but ignored because of the parse error in the closure.
196-
};
197189

198-
$pagenow = 'something'; // Bad, should be picked up. Tests that skipping on parse error doesn't skip too far.
199-
}
190+
191+
192+
193+
194+
195+
196+
197+
198+
199+
200200

201201
$GLOBALS[] = 'something';
202202
$GLOBALS[103] = 'something';
@@ -314,4 +314,3 @@ list(
314314
// Live coding/parse error.
315315
// This has to be the last test in the file!
316316
list( $tab, $tabs
317-
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/*
4+
* Separate test file to isolate the parse error test.
5+
*/
6+
7+
// Verify skipping over rest of the function when live coding/parse error in nested scope structure.
8+
function global_vars() {
9+
global $pagenow;
10+
11+
$closure = function ( $pagenow ) {
12+
global $feeds;
13+
14+
$nested_closure_with_parse_error = function ( $feeds )
15+
16+
$feeds = 'something'; // Bad, but ignored because of the parse error in the closure.
17+
};
18+
19+
$pagenow = 'something'; // Bad, should be picked up. Tests that skipping on parse error doesn't skip too far.
20+
}

WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function getErrorList( $testFile = '' ) {
5959
143 => 1,
6060
146 => 1,
6161
181 => 1,
62-
198 => 1,
6362
212 => 4,
6463
230 => 2,
6564
231 => 2,
@@ -91,6 +90,11 @@ public function getErrorList( $testFile = '' ) {
9190
29 => 1,
9291
);
9392

93+
case 'GlobalVariablesOverrideUnitTest.7.inc':
94+
return array(
95+
19 => 1,
96+
);
97+
9498
default:
9599
return array();
96100
}

0 commit comments

Comments
 (0)