Skip to content

Commit 4c7b209

Browse files
committed
Update if condition to explicitly check what is expected and add a test to reach that condition
1 parent 2b48e41 commit 4c7b209

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

WordPress/Sniffs/WP/OptionAutoloadSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ private function check_autoload_value( array $autoload_info, $function_name ) {
334334

335335
$normalized_value = strtolower( $autoload_info['clean'] );
336336

337-
if ( \T_NS_SEPARATOR === $this->tokens[ $param_first_token ]['code'] && $param_second_token ) {
337+
if ( \T_NS_SEPARATOR === $this->tokens[ $param_first_token ]['code'] && is_int( $param_second_token ) ) {
338338
$token_content_lowercase = strtolower( $this->tokens[ $param_second_token ]['content'] );
339339

340340
if ( isset( $this->valid_values_add_and_update[ $token_content_lowercase ] ) ) {
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
/*
4+
* Intentional parse error (just a namespace separator as the third parameter).
5+
* This should be the only test in this file.
6+
*/
7+
8+
update_option('my_option', 'new_value', \);

WordPress/Tests/WP/OptionAutoloadUnitTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ public function getWarningList( $testFile = '' ) {
117117
227 => 1,
118118
);
119119

120+
case 'OptionAutoloadUnitTest.3.inc':
121+
return array(
122+
8 => 1,
123+
);
124+
120125
default:
121126
return array();
122127
}

0 commit comments

Comments
 (0)