Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method params incorrectly detected when default value uses short array syntax #642

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions CodeSniffer/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down