Skip to content

Commit 2a6c145

Browse files
committed
Fixed bug #1266 : PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML
1 parent 1336d8b commit 2a6c145

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
166166
$fix = $phpcsFile->addFixableError($error, $scopeEnd, 'BreakIndent', $data);
167167
}
168168
} else {
169-
$expectedIndent = ($startColumn - 1);
169+
$expectedIndent = max(0, ($startColumn - 1));
170170
if ($braceIndent !== $expectedIndent) {
171171
$error = 'Closing brace indented incorrectly; expected %s spaces, found %s';
172172
$data = array(

CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc

+4
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,7 @@ switch ( $a ) {
140140
}
141141
return 5;
142142
}
143+
144+
?>
145+
<?php $_cartQty = $this->getSummaryCount(); ?>
146+
<div id="minicart" <?php if ($_cartQty == 0): ?>class="empty"<?php endif; ?>>

CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc.fixed

+5
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,8 @@ switch ( $a ) {
143143
}
144144
return 5;
145145
}
146+
147+
?>
148+
<?php $_cartQty = $this->getSummaryCount(); ?>
149+
<div id="minicart" <?php if ($_cartQty == 0): ?>class="empty"<?php
150+
endif; ?>>

CodeSniffer/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function getErrorList()
5656
127 => 1,
5757
135 => 1,
5858
141 => 1,
59+
146 => 1,
5960
);
6061

6162
}//end getErrorList()

package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
4949
- Squiz.WhiteSpace.OperatorSpacing no longer checks the equal sign in declare statements
5050
-- Thanks to Juliette Reinders Folmer for the patch
5151
- Added missing error codes for a couple of sniffs so they can now be customised as normal
52+
- Fixed bug #1266 : PEAR.WhiteSpace.ScopeClosingBrace can throw an error while fixing mixed PHP/HTML
5253
- Fixed bug #1364 : Yield From values are not recognised as returned values in Squiz FunctionComment sniff
5354
- Fixed bug #1373 : Error in tab expansion results in white-space of incorrect size
5455
-- Thanks to Mark Clements for the patch

0 commit comments

Comments
 (0)