- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
SingleLineThrowFixer - fix handling anonymous classes #5593
Conversation
I can't review the logic as I'm not into php-cs-fixer much but I think the target is nice, thanks for working on this! |
@nicolas-grekas I am interested on your opinion from a user perspective - what should happen to this code:
Fully single line:
or without class body:
? |
|
||
if (\PHP_VERSION_ID >= 70000) { | ||
yield [ | ||
'<?php throw new class() extends Exception { protected $message = "Custom message"; };', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be pretty long
can we, easily, achieve that throw new class() extends Exception
is enforced to be a single line, and the body of class is formatted properly by braces
fixer?
if not, let's skill formatting of anonymous classes by single_line_throw
, imho
Thank you @kubawerlos. |
Is this a right solution or
SingleLineThrowFixer
should not remove new lines from anonymous class definition?Ping @nicolas-grekas for an opinion (as you are the person who originally requested this fixer).