Skip to content

Commit 53c680f

Browse files
committed
Handle case when $array_token is false + add a test for it
1 parent 3cc21c3 commit 53c680f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

WordPress/Sniffs/WP/OptionAutoloadSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private function handle_wp_set_option_autoload_values( array $options_param ) {
243243
true
244244
);
245245

246-
if ( false === isset( Collections::arrayOpenTokensBC()[ $this->tokens[ $array_token ]['code'] ] ) ) {
246+
if ( false === $array_token || false === isset( Collections::arrayOpenTokensBC()[ $this->tokens[ $array_token ]['code'] ] ) ) {
247247
// Bail if the first non-empty token in the parameter is not an array opener as this
248248
// means it is not possible to determine the option names and autoload values passed to
249249
// wp_set_option_autoload_values().
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 (missing parameter value after parameter name).
5+
* This should be the only test in this file.
6+
*/
7+
8+
wp_set_option_autoload_values(options:);

0 commit comments

Comments
 (0)