Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] Support formatted text cutting#22225
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| * Sets the decorated flag. | ||
| * | ||
| * @param bool $decorated Whether to decorate the messages or not | ||
| * {@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.
does this patch apply to lower branches? if yes, should be done there
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.
Will look into that.
| * @param string $message The message to style | ||
| * | ||
| * @return string The styled message | ||
| * {@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.
that one is not possible: $width is not in the interface, thus should be documented here
| * @return string The styled message | ||
| */ | ||
| publicfunctionformat($message); | ||
| publicfunctionformat($message/*, $width = 0*/); |
nicolas-grekasApr 3, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Changing an interface like that is a hard BC break. Anyone implementing it without extendingOutputFormatter will get no deprecation warning.
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.
Any suggestions? Took this approach fromLogoutUrlGenerator::registerListener ;) which is not bound to an interface.
Note that this way is the easiest implementation and avoids double processing the formatted text, which is nice.
ro0NL commentedApr 7, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Approach updated.. not sure this makes sense either :P but im concerning users extending from Guess i like the |
…ro0NL)This PR was merged into the 2.7 branch.Discussion----------[Console] Inherit phpdoc from OutputFormatterInterface| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#22225 (comment)| License | MIT| Doc PR | symfony/symfony-docs#... <!--highly recommended for new features-->Commits-------ff3cb9c [Console] Inherit phpdoc from OutputFormatterInterface
nicolas-grekas commentedOct 8, 2017
Moving to 4.1. Rebase on master might be needed, where PHP 7.1 features can be used btw. |
fabpot commentedMar 31, 2018
@ro0NL Can you tell us the status of this PR? Looks like it should be rebased. |
ro0NL commentedMar 31, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@fabpot is the current upgrade path OK? If so, suggestions for naming but i was hoping we eventually dont need this interface and have status: needs work |
| if (__CLASS__ !==get_class($this)) { | ||
| $r =new \ReflectionMethod($this,__FUNCTION__); | ||
| if (__CLASS__ !==$r->getDeclaringClass()->getName()) { | ||
| @trigger_error(sprintf('Method "%s()" will have a 2nd `$width = 0` argument in version 5.0. Not defining it is deprecated since 4.1.',__METHOD__),E_USER_DEPRECATED); |
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.
... in version 5.0, not defining it is deprecated since Symfony 4.1
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.
I don't understand why you want to force people to define the$width. Not setting it explicitly seems fine to me.
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.
Right. I should check for defined no. of arguments on the signature.
ro0NL commentedApr 4, 2018
I think the upgrade path is OK now. But i need to have a 2nd look at the fix.. cause im getting different results now as before. |
ro0NL commentedApr 4, 2018
ro0NL commentedApr 4, 2018
It seems to break as soon as it breaks out the window, thus creates a scrollbar. WTF :) |
fabpot commentedSep 4, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@ro0NL What do we do here? Any ideas how to move forward? |
ro0NL commentedSep 4, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
ro0NL commentedSep 4, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
And perhaps rethink Perhaps more explicit Then again, currently it allows to update |
ro0NL commentedSep 4, 2018
Updated. Much cleaner IMHO. |
fabpot left a comment
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.
Looks much better to me
chalasr commentedSep 4, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Nice one! Thanks Roland. |
This PR was squashed before being merged into the 4.2-dev branch (closes#22225).Discussion----------[Console] Support formatted text cutting| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes/no| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | symfony/symfony-docs#... <!--highly recommended for new features-->allows cutting a formatted text to a certain width. Actually needed if we want to support max. column widths in tables (see#22156)```php$text = 'pre <error>foo bar baz</error> post';dump('BEFORE');$output->writeln(wordwrap($output->getFormatter()->format($text), 3, "\n", true), OutputInterface::OUTPUT_RAW);dump('AFTER');$output->writeln($output->getFormatter()->format($text, 3), OutputInterface::OUTPUT_RAW);```Commits-------09f8ad9 [Console] Support formatted text cutting
This PR was squashed before being merged into the 4.2-dev branch (closes#28373).Discussion----------[Console] Support max column width in Table| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets |#22156,#27832| License | MIT| Doc PR |symfony/symfony-docs#10300Continuation of#22225 to better preserve spaces (which preserves background colors), using `wordwrap` it caused some issues.Also the wrapping was plain wrong by not taking the current line length into account.While at it, it comes with `Table` integration :)Given```php$table = new Table($output);$table->setColumnMaxWidth(0, 2);$table->setRow(0, ['pre <error>foo bar baz</error> post']);$table->render();$table = new Table($output);$table->setColumnMaxWidth(0, 3);$table->setRow(0, ['pre <error>foo bar baz</error> post']);$table->render();$table = new Table($output);$table->setColumnMaxWidth(0, 4);$table->setRow(0, ['pre <error>foo bar baz</error> post']);$table->render();```Commits-------175f68f [Console] Support max column width in Table

Uh oh!
There was an error while loading.Please reload this page.
allows cutting a formatted text to a certain width. Actually needed if we want to support max. column widths in tables (see#22156)