Browse files

Fixed bug #20045 : Errors about indentation for closures with multi-l…

…ine 'use' in functions
  • Loading branch information...
1 parent bc345e0 commit 12a1ec7ab9f362b85a3e5d5717dbc807e98e1d2b @gsherwood gsherwood committed Aug 23, 2013
View
3 CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php
@@ -250,7 +250,8 @@ public function processMultiLineDeclaration(PHP_CodeSniffer_File $phpcsFile, $st
if ($tokens[$i]['line'] !== $lastLine) {
if ($i === $tokens[$stackPtr]['parenthesis_closer']
|| ($tokens[$i]['code'] === T_WHITESPACE
- && ($i + 1) === $tokens[$stackPtr]['parenthesis_closer'])
+ && (($i + 1) === $closeBracket
+ || ($i + 1) === $tokens[$stackPtr]['parenthesis_closer']))
) {
// Closing braces need to be indented to the same level
// as the function.
View
15 CodeSniffer/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc
@@ -109,4 +109,19 @@ $longArgs_longVars = function (
$muchLongerVar3) {
// body
};
+
+function test()
+{
+ $longArgs_longVars = function (
+ $longArgument,
+ $longerArgument,
+ $muchLongerArgument
+ ) use (
+ $longVar1,
+ $longerVar2,
+ $muchLongerVar3
+ ) {
+ // body
+ };
+}
?>
View
1 package.xml
@@ -44,6 +44,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Adds new error message for single-line arrays that end with a comma
- Fixed bug #20029 : ForbiddenFunction sniff incorrectly recognizes methods in USE clauses
- Fixed bug #20044 : PSR1 camelCase check does not ignore leading underscores
+ - Fixed bug #20045 : Errors about indentation for closures with multi-line 'use' in functions
</notes>
<contents>
<dir name="/">

0 comments on commit 12a1ec7

Please sign in to comment.