Skip to content

Commit 00d4f35

Browse files
authored
Merge pull request #571 from Automattic/fix/no-yoda-in-own-codebase
2 parents a3334db + fe6ccec commit 00d4f35

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+290
-286
lines changed

.phpcs.xml.dist

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<exclude name="WordPress.Files.FileName"/>
1818
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
1919
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
20+
<exclude name="WordPress.PHP.YodaConditions"/>
2021
</rule>
2122

2223
<rule ref="WordPress-Docs"/>
@@ -32,9 +33,12 @@
3233

3334
<rule ref="PSR2.Methods.FunctionClosingBrace"/>
3435

35-
<!-- Disallow long array syntax -->
36+
<!-- Disallow long array syntax. -->
3637
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
3738

39+
<!-- Disallow Yoda conditions. -->
40+
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>
41+
3842
<!-- Check code for cross-version PHP compatibility. -->
3943
<config name="testVersion" value="5.4-"/>
4044
<rule ref="PHPCompatibility">

WordPressVIPMinimum/Sniffs/AbstractVariableRestrictionsSniff.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ abstract class AbstractVariableRestrictionsSniff extends Sniff {
6161
*/
6262
public function register() {
6363
// Retrieve the groups only once and don't set up a listener if there are no groups.
64-
if ( false === $this->setup_groups() ) {
64+
if ( $this->setup_groups() === false ) {
6565
return [];
6666
}
6767

@@ -138,7 +138,7 @@ public function process_token( $stackPtr ) {
138138
if ( \in_array( $token['code'], [ \T_OBJECT_OPERATOR, \T_DOUBLE_COLON ], true ) ) { // This only works for object vars and array members.
139139
$method = $this->phpcsFile->findNext( \T_WHITESPACE, $stackPtr + 1, null, true );
140140
$possible_parenthesis = $this->phpcsFile->findNext( \T_WHITESPACE, $method + 1, null, true );
141-
if ( \T_OPEN_PARENTHESIS === $this->tokens[ $possible_parenthesis ]['code'] ) {
141+
if ( $this->tokens[ $possible_parenthesis ]['code'] === \T_OPEN_PARENTHESIS ) {
142142
return; // So .. it is a function after all !
143143
}
144144
}
@@ -190,9 +190,9 @@ public function process_token( $stackPtr ) {
190190

191191
$patterns = array_map( [ $this, 'test_patterns' ], $patterns );
192192
$pattern = implode( '|', $patterns );
193-
$delim = ( \T_OPEN_SQUARE_BRACKET !== $token['code'] && \T_HEREDOC !== $token['code'] ) ? '\b' : '';
193+
$delim = ( $token['code'] !== \T_OPEN_SQUARE_BRACKET && $token['code'] !== \T_HEREDOC ) ? '\b' : '';
194194

195-
if ( \T_DOUBLE_QUOTED_STRING === $token['code'] || \T_HEREDOC === $token['code'] ) {
195+
if ( $token['code'] === \T_DOUBLE_QUOTED_STRING || $token['code'] === \T_HEREDOC ) {
196196
$var = $token['content'];
197197
}
198198

@@ -203,7 +203,7 @@ public function process_token( $stackPtr ) {
203203
$this->addMessage(
204204
$group['message'],
205205
$stackPtr,
206-
'error' === $group['type'],
206+
$group['type'] === 'error',
207207
$this->string_to_errorcode( $groupName . '_' . $match[1] ),
208208
[ $var ]
209209
);

WordPressVIPMinimum/Sniffs/Classes/DeclarationCompatibilitySniff.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currSco
218218
$methodName = $phpcsFile->getDeclarationName( $stackPtr );
219219

220220
$parentClassName = $phpcsFile->findExtendedClassName( $currScope );
221-
if ( false === $parentClassName ) {
221+
if ( $parentClassName === false ) {
222222
// This class does not extend any other class.
223223
return;
224224
}
225225

226226
// Meed to define the originalParentClassName since we might override the parentClassName due to signature notations grouping.
227227
$originalParentClassName = $parentClassName;
228228

229-
if ( false === array_key_exists( $parentClassName, $this->checkClasses ) ) {
229+
if ( array_key_exists( $parentClassName, $this->checkClasses ) === false ) {
230230
// This class does not extend a class we are interested in.
231231
foreach ( $this->checkClassesGroups as $parent => $children ) {
232232
// But it might be one of the grouped classes.
@@ -237,14 +237,14 @@ protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currSco
237237
}
238238
}
239239
}
240-
if ( false === array_key_exists( $parentClassName, $this->checkClasses ) ) {
240+
if ( array_key_exists( $parentClassName, $this->checkClasses ) === false ) {
241241
// This class really does not extend a class we are interested in.
242242
return;
243243
}
244244
}
245245

246-
if ( false === array_key_exists( $methodName, $this->checkClasses[ $parentClassName ] ) &&
247-
false === in_array( $methodName, $this->checkClasses[ $parentClassName ], true )
246+
if ( array_key_exists( $methodName, $this->checkClasses[ $parentClassName ] ) === false &&
247+
in_array( $methodName, $this->checkClasses[ $parentClassName ], true ) === false
248248
) {
249249
// This method is not a one we are interested in.
250250
return;
@@ -258,11 +258,11 @@ protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currSco
258258
$extra_params = array_slice( $signatureParams, count( $parentSignature ) - count( $signatureParams ) );
259259
$all_extra_params_have_default = true;
260260
foreach ( $extra_params as $extra_param ) {
261-
if ( false === array_key_exists( 'default', $extra_param ) || 'true' !== $extra_param['default'] ) {
261+
if ( array_key_exists( 'default', $extra_param ) === false || $extra_param['default'] !== 'true' ) {
262262
$all_extra_params_have_default = false;
263263
}
264264
}
265-
if ( true === $all_extra_params_have_default ) {
265+
if ( $all_extra_params_have_default === true ) {
266266
return; // We're good.
267267
}
268268
}
@@ -274,16 +274,16 @@ protected function processTokenWithinScope( File $phpcsFile, $stackPtr, $currSco
274274

275275
$i = 0;
276276
foreach ( $parentSignature as $key => $param ) {
277-
if ( true === is_array( $param ) ) {
277+
if ( is_array( $param ) === true ) {
278278
if (
279279
(
280-
true === array_key_exists( 'default', $param ) &&
281-
false === array_key_exists( 'default', $signatureParams[ $i ] )
280+
array_key_exists( 'default', $param ) === true &&
281+
array_key_exists( 'default', $signatureParams[ $i ] ) === false
282282
) || (
283-
true === array_key_exists( 'pass_by_reference', $param ) &&
283+
array_key_exists( 'pass_by_reference', $param ) === true &&
284284
$param['pass_by_reference'] !== $signatureParams[ $i ]['pass_by_reference']
285285
) || (
286-
true === array_key_exists( 'variable_length', $param ) &&
286+
array_key_exists( 'variable_length', $param ) === true &&
287287
$param['variable_length'] !== $signatureParams[ $i ]['variable_length']
288288
)
289289
) {
@@ -329,26 +329,26 @@ private function generateParamList( $methodSignature ) {
329329
$paramList = [];
330330
foreach ( $methodSignature as $param => $options ) {
331331
$paramName = '$';
332-
if ( false === is_array( $options ) ) {
332+
if ( is_array( $options ) === false ) {
333333
$paramList[] = '$' . $options;
334334
continue;
335335
}
336336

337-
if ( true === array_key_exists( 'name', $options ) ) {
337+
if ( array_key_exists( 'name', $options ) === true ) {
338338
$paramName = $options['name'];
339339
} else {
340340
$paramName .= $param;
341341
}
342342

343-
if ( true === array_key_exists( 'variable_length', $options ) && true === $options['variable_length'] ) {
343+
if ( array_key_exists( 'variable_length', $options ) === true && $options['variable_length'] === true ) {
344344
$paramName = '...' . $paramName;
345345
}
346346

347-
if ( true === array_key_exists( 'pass_by_reference', $options ) && true === $options['pass_by_reference'] ) {
347+
if ( array_key_exists( 'pass_by_reference', $options ) === true && $options['pass_by_reference'] === true ) {
348348
$paramName = '&' . $paramName;
349349
}
350350

351-
if ( true === array_key_exists( 'default', $options ) && false === empty( $options['default'] ) ) {
351+
if ( array_key_exists( 'default', $options ) === true && empty( $options['default'] ) === false ) {
352352
$paramName .= ' = ' . trim( $options['default'] );
353353
}
354354

@@ -371,7 +371,7 @@ protected function loadFunctionNamesInScope( File $phpcsFile, $currScope ) {
371371
$tokens = $phpcsFile->getTokens();
372372

373373
for ( $i = ( $tokens[ $currScope ]['scope_opener'] + 1 ); $i < $tokens[ $currScope ]['scope_closer']; $i++ ) {
374-
if ( T_FUNCTION !== $tokens[ $i ]['code'] ) {
374+
if ( $tokens[ $i ]['code'] !== T_FUNCTION ) {
375375
continue;
376376
}
377377

WordPressVIPMinimum/Sniffs/Classes/RestrictedExtendClassesSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getGroups() {
4747
public function process_matched_token( $stackPtr, $group_name, $matched_content ) {
4848
$tokens = $this->phpcsFile->getTokens();
4949

50-
if ( T_EXTENDS !== $tokens[ $stackPtr ]['code'] ) {
50+
if ( $tokens[ $stackPtr ]['code'] !== T_EXTENDS ) {
5151
// If not extending, bail.
5252
return;
5353
}

WordPressVIPMinimum/Sniffs/Compatibility/ZoninatorSniff.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,26 @@ public function register() {
3535
*/
3636
public function process_token( $stackPtr ) {
3737

38-
if ( 'wpcom_vip_load_plugin' !== $this->tokens[ $stackPtr ]['content'] ) {
38+
if ( $this->tokens[ $stackPtr ]['content'] !== 'wpcom_vip_load_plugin' ) {
3939
return;
4040
}
4141

4242
$openBracket = $this->phpcsFile->findNext( Tokens::$emptyTokens, $stackPtr + 1, null, true );
4343

44-
if ( T_OPEN_PARENTHESIS !== $this->tokens[ $openBracket ]['code'] ) {
44+
if ( $this->tokens[ $openBracket ]['code'] !== T_OPEN_PARENTHESIS ) {
4545
// Not a function call.
4646
return;
4747
}
4848

4949
$plugin_name = $this->phpcsFile->findNext( Tokens::$emptyTokens, $openBracket + 1, null, true );
5050

51-
if ( 'zoninator' !== $this->remove_wrapping_quotation_marks( $this->tokens[ $plugin_name ]['content'] ) ) {
51+
if ( $this->remove_wrapping_quotation_marks( $this->tokens[ $plugin_name ]['content'] ) !== 'zoninator' ) {
5252
return;
5353
}
5454

5555
$comma = $this->phpcsFile->findNext( Tokens::$emptyTokens, $plugin_name + 1, null, true );
5656

57-
if ( ! $comma || 'PHPCS_T_COMMA' !== $this->tokens[ $comma ]['code'] ) {
57+
if ( ! $comma || $this->tokens[ $comma ]['code'] !== 'PHPCS_T_COMMA' ) {
5858
// We are loading the default version.
5959
return;
6060
}
@@ -63,15 +63,15 @@ public function process_token( $stackPtr ) {
6363

6464
$comma = $this->phpcsFile->findNext( Tokens::$emptyTokens, $folder + 1, null, true );
6565

66-
if ( ! $comma || 'PHPCS_T_COMMA' !== $this->tokens[ $comma ]['code'] ) {
66+
if ( ! $comma || $this->tokens[ $comma ]['code'] !== 'PHPCS_T_COMMA' ) {
6767
// We are loading the default version.
6868
return;
6969
}
7070

7171
$version = $this->phpcsFile->findNext( Tokens::$emptyTokens, $comma + 1, null, true );
7272
$version = $this->remove_wrapping_quotation_marks( $this->tokens[ $version ]['content'] );
7373

74-
if ( true === version_compare( $version, '0.8', '>=' ) ) {
74+
if ( version_compare( $version, '0.8', '>=' ) === true ) {
7575
$message = 'Zoninator of version >= v0.8 requires WordPress core REST API. Please, make sure the `wpcom_vip_load_wp_rest_api()` is being called on all sites loading this file.';
7676
$this->phpcsFile->addWarning( $message, $stackPtr, 'RequiresRESTAPI' );
7777
}

WordPressVIPMinimum/Sniffs/Constants/ConstantStringSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,26 @@ public function register() {
3838
*/
3939
public function process_token( $stackPtr ) {
4040

41-
if ( false === in_array( $this->tokens[ $stackPtr ]['content'], [ 'define', 'defined' ], true ) ) {
41+
if ( in_array( $this->tokens[ $stackPtr ]['content'], [ 'define', 'defined' ], true ) === false ) {
4242
return;
4343
}
4444

4545
// Find the next non-empty token.
4646
$nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true );
4747

48-
if ( T_OPEN_PARENTHESIS !== $this->tokens[ $nextToken ]['code'] ) {
48+
if ( $this->tokens[ $nextToken ]['code'] !== T_OPEN_PARENTHESIS ) {
4949
// Not a function call.
5050
return;
5151
}
5252

53-
if ( false === isset( $this->tokens[ $nextToken ]['parenthesis_closer'] ) ) {
53+
if ( isset( $this->tokens[ $nextToken ]['parenthesis_closer'] ) === false ) {
5454
// Not a function call.
5555
return;
5656
}
5757

5858
$nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, $nextToken + 1, null, true, null, true );
5959

60-
if ( T_CONSTANT_ENCAPSED_STRING !== $this->tokens[ $nextToken ]['code'] ) {
60+
if ( $this->tokens[ $nextToken ]['code'] !== T_CONSTANT_ENCAPSED_STRING ) {
6161
$message = 'Constant name, as a string, should be used along with `%s()`.';
6262
$data = [ $this->tokens[ $stackPtr ]['content'] ];
6363
$this->phpcsFile->addError( $message, $nextToken, 'NotCheckingConstantName', $data );

WordPressVIPMinimum/Sniffs/Constants/RestrictedConstantsSniff.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,18 @@ public function register() {
5858
*/
5959
public function process_token( $stackPtr ) {
6060

61-
if ( T_STRING === $this->tokens[ $stackPtr ]['code'] ) {
61+
if ( $this->tokens[ $stackPtr ]['code'] === T_STRING ) {
6262
$constantName = $this->tokens[ $stackPtr ]['content'];
6363
} else {
6464
$constantName = trim( $this->tokens[ $stackPtr ]['content'], "\"'" );
6565
}
6666

67-
if ( false === in_array( $constantName, $this->restrictedConstantNames, true ) && false === in_array( $constantName, $this->restrictedConstantDeclaration, true ) ) {
67+
if ( in_array( $constantName, $this->restrictedConstantNames, true ) === false && in_array( $constantName, $this->restrictedConstantDeclaration, true ) === false ) {
6868
// Not the constant we are looking for.
6969
return;
7070
}
7171

72-
if ( T_STRING === $this->tokens[ $stackPtr ]['code'] && true === in_array( $constantName, $this->restrictedConstantNames, true ) ) {
72+
if ( $this->tokens[ $stackPtr ]['code'] === T_STRING && in_array( $constantName, $this->restrictedConstantNames, true ) === true ) {
7373
$message = 'Code is touching the `%s` constant. Make sure it\'s used appropriately.';
7474
$data = [ $constantName ];
7575
$this->phpcsFile->addWarning( $message, $stackPtr, 'UsingRestrictedConstant', $data );
@@ -79,12 +79,12 @@ public function process_token( $stackPtr ) {
7979
// Find the previous non-empty token.
8080
$openBracket = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, $stackPtr - 1, null, true, null, true );
8181

82-
if ( T_OPEN_PARENTHESIS !== $this->tokens[ $openBracket ]['code'] ) {
82+
if ( $this->tokens[ $openBracket ]['code'] !== T_OPEN_PARENTHESIS ) {
8383
// Not a function call.
8484
return;
8585
}
8686

87-
if ( false === isset( $this->tokens[ $openBracket ]['parenthesis_closer'] ) ) {
87+
if ( isset( $this->tokens[ $openBracket ]['parenthesis_closer'] ) === false ) {
8888
// Not a function call.
8989
return;
9090
}
@@ -93,17 +93,17 @@ public function process_token( $stackPtr ) {
9393
$search = Tokens::$emptyTokens;
9494
$search[] = T_BITWISE_AND;
9595
$previous = $this->phpcsFile->findPrevious( $search, $openBracket - 1, null, true );
96-
if ( T_FUNCTION === $this->tokens[ $previous ]['code'] ) {
96+
if ( $this->tokens[ $previous ]['code'] === T_FUNCTION ) {
9797
// It's a function definition, not a function call.
9898
return;
9999
}
100100

101-
if ( true === in_array( $this->tokens[ $previous ]['code'], Tokens::$functionNameTokens, true ) ) {
101+
if ( in_array( $this->tokens[ $previous ]['code'], Tokens::$functionNameTokens, true ) === true ) {
102102
$data = [ $constantName ];
103-
if ( 'define' === $this->tokens[ $previous ]['content'] ) {
103+
if ( $this->tokens[ $previous ]['content'] === 'define' ) {
104104
$message = 'The definition of `%s` constant is prohibited. Please use a different name.';
105105
$this->phpcsFile->addError( $message, $previous, 'DefiningRestrictedConstant', $data );
106-
} elseif ( true === in_array( $constantName, $this->restrictedConstantNames, true ) ) {
106+
} elseif ( in_array( $constantName, $this->restrictedConstantNames, true ) === true ) {
107107
$message = 'Code is touching the `%s` constant. Make sure it\'s used appropriately.';
108108
$this->phpcsFile->addWarning( $message, $previous, 'UsingRestrictedConstant', $data );
109109
}

WordPressVIPMinimum/Sniffs/Files/IncludingFileSniff.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,35 +94,35 @@ public function register() {
9494
public function process_token( $stackPtr ) {
9595
$nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true );
9696

97-
if ( T_OPEN_PARENTHESIS === $this->tokens[ $nextToken ]['code'] ) {
97+
if ( $this->tokens[ $nextToken ]['code'] === T_OPEN_PARENTHESIS ) {
9898
// The construct is using parenthesis, grab the next non empty token.
9999
$nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, $nextToken + 1, null, true, null, true );
100100
}
101101

102-
if ( T_DIR === $this->tokens[ $nextToken ]['code'] || '__DIR__' === $this->tokens[ $nextToken ]['content'] ) {
102+
if ( $this->tokens[ $nextToken ]['code'] === T_DIR || $this->tokens[ $nextToken ]['content'] === '__DIR__' ) {
103103
// The construct is using __DIR__ which is fine.
104104
return;
105105
}
106106

107-
if ( T_VARIABLE === $this->tokens[ $nextToken ]['code'] ) {
107+
if ( $this->tokens[ $nextToken ]['code'] === T_VARIABLE ) {
108108
$message = 'File inclusion using variable (`%s`). Probably needs manual inspection.';
109109
$data = [ $this->tokens[ $nextToken ]['content'] ];
110110
$this->phpcsFile->addWarning( $message, $nextToken, 'UsingVariable', $data );
111111
return;
112112
}
113113

114-
if ( T_STRING === $this->tokens[ $nextToken ]['code'] ) {
115-
if ( true === in_array( $this->tokens[ $nextToken ]['content'], $this->getPathFunctions, true ) ) {
114+
if ( $this->tokens[ $nextToken ]['code'] === T_STRING ) {
115+
if ( in_array( $this->tokens[ $nextToken ]['content'], $this->getPathFunctions, true ) === true ) {
116116
// The construct is using one of the function for getting correct path which is fine.
117117
return;
118118
}
119119

120-
if ( true === in_array( $this->tokens[ $nextToken ]['content'], $this->allowedConstants, true ) ) {
120+
if ( in_array( $this->tokens[ $nextToken ]['content'], $this->allowedConstants, true ) === true ) {
121121
// The construct is using one of the allowed constants which is fine.
122122
return;
123123
}
124124

125-
if ( true === array_key_exists( $this->tokens[ $nextToken ]['content'], $this->restrictedConstants ) ) {
125+
if ( array_key_exists( $this->tokens[ $nextToken ]['content'], $this->restrictedConstants ) === true ) {
126126
// The construct is using one of the restricted constants.
127127
$message = '`%s` constant might not be defined or available. Use `%s()` instead.';
128128
$data = [ $this->tokens[ $nextToken ]['content'], $this->restrictedConstants[ $this->tokens[ $nextToken ]['content'] ] ];
@@ -131,22 +131,22 @@ public function process_token( $stackPtr ) {
131131
}
132132

133133
$nextNextToken = $this->phpcsFile->findNext( array_merge( Tokens::$emptyTokens, [ T_COMMENT ] ), $nextToken + 1, null, true, null, true );
134-
if ( 1 === preg_match( '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $this->tokens[ $nextToken ]['content'] ) && T_OPEN_PARENTHESIS !== $this->tokens[ $nextNextToken ]['code'] ) {
134+
if ( preg_match( '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $this->tokens[ $nextToken ]['content'] ) === 1 && $this->tokens[ $nextNextToken ]['code'] !== T_OPEN_PARENTHESIS ) {
135135
// The construct is using custom constant, which needs manual inspection.
136136
$message = 'File inclusion using custom constant (`%s`). Probably needs manual inspection.';
137137
$data = [ $this->tokens[ $nextToken ]['content'] ];
138138
$this->phpcsFile->addWarning( $message, $nextToken, 'UsingCustomConstant', $data );
139139
return;
140140
}
141141

142-
if ( 0 === strpos( $this->tokens[ $nextToken ]['content'], '$' ) ) {
142+
if ( strpos( $this->tokens[ $nextToken ]['content'], '$' ) === 0 ) {
143143
$message = 'File inclusion using variable (`%s`). Probably needs manual inspection.';
144144
$data = [ $this->tokens[ $nextToken ]['content'] ];
145145
$this->phpcsFile->addWarning( $message, $nextToken, 'UsingVariable', $data );
146146
return;
147147
}
148148

149-
if ( true === in_array( $this->tokens[ $nextToken ]['content'], $this->slashingFunctions, true ) ) {
149+
if ( in_array( $this->tokens[ $nextToken ]['content'], $this->slashingFunctions, true ) === true ) {
150150
// The construct is using one of the slashing functions, it's probably correct.
151151
return;
152152
}
@@ -163,7 +163,7 @@ public function process_token( $stackPtr ) {
163163
return;
164164
}
165165

166-
if ( T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $nextToken ]['code'] && filter_var( str_replace( [ '"', "'" ], '', $this->tokens[ $nextToken ]['content'] ), FILTER_VALIDATE_URL ) ) {
166+
if ( $this->tokens[ $nextToken ]['code'] === T_CONSTANT_ENCAPSED_STRING && filter_var( str_replace( [ '"', "'" ], '', $this->tokens[ $nextToken ]['content'] ), FILTER_VALIDATE_URL ) ) {
167167
$message = 'Include path must be local file source, external URLs are prohibited on WordPress VIP.';
168168
$this->phpcsFile->addError( $message, $nextToken, 'ExternalURL' );
169169
return;

0 commit comments

Comments
 (0)