Skip to content

Commit

Permalink
Fixed bug squizlabs#709 : Squiz.Sniffs.Whitespace.ScopeClosingBraceSn…
Browse files Browse the repository at this point in the history
…iff marking indented endif in mixed inline HTML blocks
  • Loading branch information
gsherwood committed Sep 20, 2015
1 parent b2c7832 commit 91b2c91
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$scopeEnd = $tokens[$stackPtr]['scope_closer'];

// Check that the closing brace is on it's own line.
$lastContent = $phpcsFile->findPrevious(array(T_WHITESPACE, T_OPEN_TAG), ($scopeEnd - 1), $scopeStart, true);
$lastContent = $phpcsFile->findPrevious(array(T_INLINE_HTML, T_WHITESPACE, T_OPEN_TAG), ($scopeEnd - 1), $scopeStart, true);
if ($tokens[$lastContent]['line'] === $tokens[$scopeEnd]['line']) {
$error = 'Closing brace must be on a line by itself';
$fix = $phpcsFile->addFixableError($error, $scopeEnd, 'ContentBefore');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ switch ($blah) {
<?php while($row = $data->getRow()): ?>
<p><?= $val ?></p>
<?php endwhile; ?>

<body>
<div>
<?php if (true == false) : ?>
<h1>o hai!</h1>
<?php endif; ?>
</div>
</body>
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Thanks to Kunal Mehta for the patch
- Fixed bug #694 : Long sniff codes can cause PHP warnings in source report when showing error codes
- Fixed bug #704 : ScopeIndent can fail when an opening parenthesis is on a line by itself
- Fixed bug #709 : Squiz.Sniffs.Whitespace.ScopeClosingBraceSniff marking indented endif in mixed inline HTML blocks
</notes>
<contents>
<dir name="/">
Expand Down

0 comments on commit 91b2c91

Please sign in to comment.