-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Symfony Console Style tweaks #15964
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
Symfony Console Style tweaks #15964
Changes from 1 commit
162d047
8fc9db7
bbcbddb
e4cbfae
9f03c00
176d25f
48efdd9
c65c1d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,7 @@ public function text($message) | |
$this->autoPrependText(); | ||
|
||
if (!is_array($message)) { | ||
$this->writeln(sprintf(' // %s', $message)); | ||
$this->writeln(sprintf(' %s', $message)); | ||
|
||
return; | ||
} | ||
|
@@ -160,6 +160,24 @@ public function text($message) | |
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function comment($message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is not defined in the parent class. So inheritdoc makes no sense. Also I guess this method should be part of StyleInterface. But I don't really see the point of this interface either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm very glad that I'm not the only one to wonder about why one insists on having interfaces for everything. Here again, I'm 👍 for removing this interface. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the way, the interface is useless as we always create concrete instances instead of injecting them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can image a user-case: Having a centralized place where the style is created. And all commands would just work with StyleInterface. Thus one can easily replace the style evewhere. But that is not how commands currently work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am +1 for removing the interface as well. There was a reason for it that was discussed during the initial PR but I can't find it. Laravel is using this feature but they extend |
||
{ | ||
$this->autoPrependText(); | ||
|
||
if (!is_array($message)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it could be simplified to something like: $this->autoPrependText();
$messages = is_array($messages) ? array_values($messages) : array($messages);
foreach ($messages as $message) {
$this->writeln(sprintf(' // %s', $message));
} Unless you really need the recursion to do something like: $sfStyle->comment([
array('lorem', array('ipsum', 'dolor')),
'Sit',
'amet',
]) Which would be kind of confusing and should be reflected to other similar methods. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this proposal. If @kbond (the original author of this code) doesn't say anything against it, I'll do these changes. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh ! Actually I didn't see it was the same implementation as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the recursion is necessary. Simplify away :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changes made. Thanks. |
||
$this->writeln(sprintf(' // %s', $message)); | ||
|
||
return; | ||
} | ||
|
||
foreach ($message as $element) { | ||
$this->comment($element); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
|
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.
Isn't it a BC break ? I think the
StyleInterface
is already implemented by some third-party libraries. (But I like the comment method over the text one, it makes much more sense !) Anyway it's a really minor one.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.
Yeah,
StyleInterface
already was present on 2.7There 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.
OK, I've removed the new method from the interface.