Skip to content

Commit

Permalink
Merge branch 'feature/3.x-fixer-conflict-squiz-embeddedphp' of https:…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jul 12, 2017
2 parents 5fd3d10 + f1db2ba commit ade7d4b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php
Expand Up @@ -370,6 +370,10 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr)
$trailingSpace = 0;
if ($tokens[($closeTag - 1)]['code'] === T_WHITESPACE) {
$trailingSpace = strlen($tokens[($closeTag - 1)]['content']);
} else if ($tokens[($closeTag - 1)]['code'] === T_COMMENT
&& substr($tokens[($closeTag - 1)]['content'], -1) === ' '
) {
$trailingSpace = (strlen($tokens[($closeTag - 1)]['content']) - strlen(rtrim($tokens[($closeTag - 1)]['content'])));
}

if ($trailingSpace !== 1) {
Expand All @@ -379,6 +383,8 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr)
if ($fix === true) {
if ($trailingSpace === 0) {
$phpcsFile->fixer->addContentBefore($closeTag, ' ');
} else if ($tokens[($closeTag - 1)]['code'] === T_COMMENT) {
$phpcsFile->fixer->replaceToken(($closeTag - 1), rtrim($tokens[($closeTag - 1)]['content']).' ');
} else {
$phpcsFile->fixer->replaceToken(($closeTag - 1), ' ');
}
Expand Down
4 changes: 4 additions & 0 deletions src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc
Expand Up @@ -107,3 +107,7 @@ function foo()

<?php if ($foo) { ?>
<?php } ?>

<?php echo 'oops'; // Something. ?>
<?php echo 'oops'; // Something. ?>
<?php echo 'oops'; // Something.?>
4 changes: 4 additions & 0 deletions src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.inc.fixed
Expand Up @@ -107,3 +107,7 @@ function foo()

<?php if ($foo) { ?>
<?php } ?>

<?php echo 'oops'; // Something. ?>
<?php echo 'oops'; // Something. ?>
<?php echo 'oops'; // Something. ?>
2 changes: 2 additions & 0 deletions src/Standards/Squiz/Tests/PHP/EmbeddedPhpUnitTest.php
Expand Up @@ -51,6 +51,8 @@ public function getErrorList()
94 => 2,
100 => 1,
102 => 1,
112 => 1,
113 => 1,
);

}//end getErrorList()
Expand Down

0 comments on commit ade7d4b

Please sign in to comment.