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/FunctionSpacing: fixer is broken with doc comment on closing brace line #784

Merged
merged 2 commits into from
Jan 12, 2025
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 @@ -149,6 +149,12 @@ public function process(File $phpcsFile, $stackPtr)

// Allow for comments on the same line as the closer.
for ($nextLineToken = ($closer + 1); $nextLineToken < $phpcsFile->numTokens; $nextLineToken++) {
// A doc comment belongs to the next statement and must not be on
// this line.
if ($tokens[$nextLineToken]['code'] === T_DOC_COMMENT_OPEN_TAG) {
break;
}

if ($tokens[$nextLineToken]['line'] !== $tokens[$closer]['line']) {
break;
}
Expand Down
11 changes: 11 additions & 0 deletions src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -582,3 +582,14 @@ echo 'this line belongs with the #3904 test';

function Foo() {} function bar($name){}
echo 'this line belongs with the #3904 test';


/**
* foo.
*/
function a() {
}/**
* foo.
*/
function b() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -671,3 +671,17 @@ function Foo() {} function bar($name){}


echo 'this line belongs with the #3904 test';


/**
* foo.
*/
function a() {
}


/**
* foo.
*/
function b() {
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function getErrorList($testFile='')
566 => 1,
580 => 2,
583 => 3,
591 => 1,
];

case 'FunctionSpacingUnitTest.2.inc':
Expand Down
Loading