Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squiz/ControlStructureSpacing: bug fix - allow for PHPCS annotation tokens #1836

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ public function process(File $phpcsFile, $stackPtr)
true
);

if ($tokens[$trailingContent]['code'] === T_COMMENT) {
if ($tokens[$trailingContent]['code'] === T_COMMENT
|| isset(Tokens::$phpcsCommentTokens[$tokens[$trailingContent]['code']]) === true
) {
// Special exception for code where the comment about
// an ELSE or ELSEIF is written between the control structures.
$nextCode = $phpcsFile->findNext(
Expand Down Expand Up @@ -327,7 +329,8 @@ public function process(File $phpcsFile, $stackPtr)
true
);

if ($tokens[$trailingContent]['code'] === T_COMMENT
if (($tokens[$trailingContent]['code'] === T_COMMENT
|| isset(Tokens::$phpcsCommentTokens[$tokens[$trailingContent]['code']]) === true)
&& $tokens[$trailingContent]['line'] === $tokens[$scopeCloser]['line']
) {
$phpcsFile->fixer->addNewline($trailingContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,11 @@ if ($true) {
}//end if
echo 'hi';

if ($true) {
echo 'hi 2';
} // phpcs:enable Standard.Category.Sniff -- for reasons.
echo 'hi';

?>
<?php foreach($formset['Fieldset'] as $fieldset): ?>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ if ($true) {

echo 'hi';

if ($true) {
echo 'hi 2';
} // phpcs:enable Standard.Category.Sniff -- for reasons.

echo 'hi';

?>
<?php foreach($formset['Fieldset'] as $fieldset): ?>
<?php foreach($fieldset['Field'] as $field):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ public function getErrorList($testFile='ControlStructureSpacingUnitTest.inc')
189 => 1,
222 => 1,
234 => 1,
238 => 1,
240 => 1,
239 => 1,
243 => 1,
245 => 1,
];
break;
case 'ControlStructureSpacingUnitTest.js':
Expand Down