Skip to content

Commit 3d598e3

Browse files
committed
Fixed bug #523 : Generic ScopeIndent errors for IF in FINALLY
1 parent 616397b commit 3d598e3

File tree

7 files changed

+45
-2
lines changed

7 files changed

+45
-2
lines changed

CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,16 @@ array(
835835
},
836836
);
837837

838+
try {
839+
echo 'foo';
840+
} catch (\Exception $e) {
841+
echo 'catch';
842+
} finally {
843+
if (false) {
844+
echo 'finally false';
845+
}
846+
}
847+
838848
function foo()
839849
{
840850
$foo = array(

CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,16 @@ array(
835835
},
836836
);
837837

838+
try {
839+
echo 'foo';
840+
} catch (\Exception $e) {
841+
echo 'catch';
842+
} finally {
843+
if (false) {
844+
echo 'finally false';
845+
}
846+
}
847+
838848
function foo()
839849
{
840850
$foo = array(

CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,16 @@ array(
835835
},
836836
);
837837

838+
try {
839+
echo 'foo';
840+
} catch (\Exception $e) {
841+
echo 'catch';
842+
} finally {
843+
if (false) {
844+
echo 'finally false';
845+
}
846+
}
847+
838848
function foo()
839849
{
840850
$foo = array(

CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,16 @@ array(
835835
},
836836
);
837837

838+
try {
839+
echo 'foo';
840+
} catch (\Exception $e) {
841+
echo 'catch';
842+
} finally {
843+
if (false) {
844+
echo 'finally false';
845+
}
846+
}
847+
838848
function foo()
839849
{
840850
$foo = array(

CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
139139
802 => 1,
140140
803 => 1,
141141
823 => 1,
142-
838 => 1,
143-
850 => 1,
142+
848 => 1,
143+
860 => 1,
144144
);
145145

146146
}//end getErrorList()

CodeSniffer/Tokens.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ final class PHP_CodeSniffer_Tokens
177177
T_DO => 50,
178178
T_TRY => 50,
179179
T_CATCH => 50,
180+
T_FINALLY => 50,
180181
T_SWITCH => 50,
181182

182183
T_SELF => 25,
@@ -494,6 +495,7 @@ final class PHP_CodeSniffer_Tokens
494495
T_DO => T_DO,
495496
T_TRY => T_TRY,
496497
T_CATCH => T_CATCH,
498+
T_FINALLY => T_FINALLY,
497499
T_PROPERTY => T_PROPERTY,
498500
T_OBJECT => T_OBJECT,
499501
T_USE => T_USE,

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
4343
- Fixed bug #479 : Yielded values are not recognised as returned values in Squiz FunctionComment sniff
4444
- Fixed bug #512 : Endless loop whilst parsing mixture of control structure styles
4545
- Fixed bug #515 : Spaces in JS block incorrectly flagged as indentation error
46+
- Fixed bug #523 : Generic ScopeIndent errors for IF in FINALLY
4647
- Fixed bug #527 : Closure inside IF statement is not tokenized correctly
4748
</notes>
4849
<contents>

0 commit comments

Comments
 (0)