Skip to content

Commit

Permalink
Merge branch 'feature/squiz-methodscope-handle-unconventional-spacing…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jun 13, 2022
2 parents d9cf568 + 10c10ac commit 89a588a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,8 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop
return;
}

$modifier = null;
for ($i = ($stackPtr - 1); $i > 0; $i--) {
if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
break;
} else if (isset(Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) {
$modifier = $i;
break;
}
}

if ($modifier === null) {
$properties = $phpcsFile->getMethodProperties($stackPtr);
if ($properties['scope_specified'] === false) {
$error = 'Visibility must be declared on method "%s"';
$data = [$methodName];
$phpcsFile->addError($error, $stackPtr, 'Missing', $data);
Expand Down
7 changes: 7 additions & 0 deletions src/Standards/Squiz/Tests/Scope/MethodScopeUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ enum SomeEnum
private function func1() {}
protected function func1() {}
}

class UnconventionalSpacing {
public
static
function
myFunction() {}
}

0 comments on commit 89a588a

Please sign in to comment.