From 674c3e94157a302f2c2caacf1d45badfc186b3e4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 26 Jul 2016 04:08:09 +0200 Subject: [PATCH] Prevent WPCS throwing an "undefined offset" notice during live code review. Fixes #628 --- WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index 1e901f460f..19f0b72ce2 100644 --- a/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -100,7 +100,7 @@ public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) { $this->init( $phpcsFile ); - if ( T_WHITESPACE !== $tokens[ ( $stackPtr + 1) ]['code'] + if ( isset( $tokens[ ( $stackPtr + 1 ) ] ) && T_WHITESPACE !== $tokens[ ( $stackPtr + 1 ) ]['code'] && ! ( T_ELSE === $tokens[ $stackPtr ]['code'] && T_COLON === $tokens[ ( $stackPtr + 1 ) ]['code'] ) && ! ( T_CLOSURE === $tokens[ $stackPtr ]['code']