From c95da5f6f7ec9606ec28dcb6bfc12e275f74e3f7 Mon Sep 17 00:00:00 2001 From: jdavis Date: Thu, 16 Jul 2015 10:30:21 -0600 Subject: [PATCH] Fix for bracket arrays in function parameter list. *When code sniffing for doc blocks, PHPCS broke when the PHP 5.4 short array syntax was introduced. *To fix this, I added a check for a bracket_opener and then skipped to the bracket_closer similar to the check for a parenthesis_opener/closer. --- CodeSniffer/File.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CodeSniffer/File.php b/CodeSniffer/File.php index 1f13d764ea..6889c72f9f 100644 --- a/CodeSniffer/File.php +++ b/CodeSniffer/File.php @@ -2717,9 +2717,9 @@ public function getMethodParameters($stackPtr) $typeHint = ''; for ($i = ($opener + 1); $i <= $closer; $i++) { - // Check to see if this token has a parenthesis opener. If it does - // its likely to be an array, which might have arguments in it, which - // we cause problems in our parsing below, so lets just skip to the + // Check to see if this token has a parenthesis or bracket opener. If it does + // it's likely to be an array which might have arguments in it. This + // could cause problems in our parsing below, so lets just skip to the // end of it. if (isset($this->_tokens[$i]['parenthesis_opener']) === true) { // Don't do this if it's the close parenthesis for the method. @@ -2728,6 +2728,13 @@ public function getMethodParameters($stackPtr) } } + if (isset($this->_tokens[$i]['bracket_opener']) === true) { + // Don't do this if it's the close parenthesis for the method. + if ($i !== $this->_tokens[$i]['bracket_closer']) { + $i = ($this->_tokens[$i]['bracket_closer'] + 1); + } + } + switch ($this->_tokens[$i]['code']) { case T_BITWISE_AND: $passByReference = true;