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

bug: Fix indentation for comment at end of function followed by a comma #6542

Conversation

julienfalque
Copy link
Member

Fixes #6511.

@julienfalque julienfalque force-pushed the fix-indentation-function-ending-with-comment-followed-by-comma branch from f71db01 to 0e53e25 Compare August 7, 2022 16:28

return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) {
return $guesser->guessRequiredForConstraint($constraint);
// Fallback to false...
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is yet another case of comment that is meant for the next line and thus should be unindented. This is not reliable and we should drop this IMO. Related discussion: #6490.

Copy link
Contributor

@jrmajor jrmajor Aug 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#6490 is a bit different, as switch cases have no braces. This comment should just be indented with the rest of the closure body IMO. If it's meant for the next line, it should be placed before the next line, not inside another braces block:

return $this->guess(
	$class,
	$property,
	function (Constraint $constraint) use ($guesser) {
		return $guesser->guessRequiredForConstraint($constraint);
	},
	// Fallback to false...
	// ... due to sth...
	false,
);

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 92.923% when pulling 0e53e25 on julienfalque:fix-indentation-function-ending-with-comment-followed-by-comma into 198293b on FriendsOfPHP:master.

@julienfalque julienfalque force-pushed the fix-indentation-function-ending-with-comment-followed-by-comma branch from 0e53e25 to fab4db1 Compare August 13, 2022 11:39
@keradus
Copy link
Member

keradus commented Jan 29, 2023

thanks @julienfalque !

@keradus keradus merged commit 2ed718a into PHP-CS-Fixer:master Jan 29, 2023
@julienfalque julienfalque deleted the fix-indentation-function-ending-with-comment-followed-by-comma branch January 29, 2023 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

if with comments indentation is still broken in v3.9.5
4 participants