diff --git a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index 29e9240057..5f7b9a3ca7 100644 --- a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -346,7 +346,8 @@ public function process_token( $stackPtr ) { if ( \T_WHITESPACE !== $this->tokens[ ( $parenthesisCloser + 1 ) ]['code'] && ! ( // Do NOT flag : immediately following ) for return types declarations. \T_COLON === $this->tokens[ ( $parenthesisCloser + 1 ) ]['code'] - && in_array( $this->tokens[ $this->tokens[ $parenthesisCloser ]['parenthesis_owner'] ]['code'], array( \T_FUNCTION, \T_CLOSURE ), true ) + && ( isset( $this->tokens[ $parenthesisCloser ]['parenthesis_owner'] ) === false + || in_array( $this->tokens[ $this->tokens[ $parenthesisCloser ]['parenthesis_owner'] ]['code'], array( \T_FUNCTION, \T_CLOSURE ), true ) ) ) && ( isset( $scopeOpener ) && \T_COLON !== $this->tokens[ $scopeOpener ]['code'] ) ) { diff --git a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc index 20d16585e0..6e848342a1 100644 --- a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc +++ b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc @@ -290,3 +290,18 @@ $returntype = function ( string $input ): string {}; // Ok. $returntype = function ( string $input ) : string {}; // Ok. $returntype = function ( string $input, array $inputs ): string {}; // Ok. $returntype = function ( string $input, array $inputs ) : string {}; // Ok. + +// Issue 1792. +$matching_options = array_filter( + $imported_options, + function ( $option ) use ( $option_id ): bool { + return $option['id'] === $option_id; + } +); + +$matching_options = array_filter( + $imported_options, + function ( $option ) use ( $option_id ) : bool { + return $option['id'] === $option_id; + } +); diff --git a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc.fixed b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc.fixed index 94e7256ca9..32c01f655d 100644 --- a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc.fixed +++ b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.1.inc.fixed @@ -279,3 +279,18 @@ $returntype = function ( string $input ): string {}; // Ok. $returntype = function ( string $input ) : string {}; // Ok. $returntype = function ( string $input, array $inputs ): string {}; // Ok. $returntype = function ( string $input, array $inputs ) : string {}; // Ok. + +// Issue 1792. +$matching_options = array_filter( + $imported_options, + function ( $option ) use ( $option_id ): bool { + return $option['id'] === $option_id; + } +); + +$matching_options = array_filter( + $imported_options, + function ( $option ) use ( $option_id ) : bool { + return $option['id'] === $option_id; + } +);