Split output to stderr and stdout#1654
Conversation
|
What about switching to SymfonyStyle ? |
|
We'd have to raise our min console version. |
|
Raising dep version for just raising it is pointless. but rising it for functionality is OK ;) |
|
BTW, then you won't need to test if console printer works on our end, just rely on vendor code (and it's tests) |
|
hmm even more work to be done in symfony/console... ;) I don't like the current output construction, because if an output is given to a receiver/output writter it has to check if there is another output attached to it that is even more appropriate. This is causing code like this all over the place; anyway, |
For ensuring that if it is possible the stdErr is used. |
yes, and changing it will fix symfony/symfony#15986 ;) |
To use SymfonyStyle we will need to bump to v2.7, which has raised PHP requirement: - "php": ">=5.3.3"
+ "php": ">=5.3.9"I'm ok with that, since it bump only PATCH version |
|
Maybe 2.x is a better place to make this change? |
|
Could you justify that? |
it would safe you the merge hell ;) |
|
There should not be a lot of differences between 1.x and 2.x since the output of both should be the same, but it is fine for me. |
|
What about creating our own Style on top of SymfonyStyle, so we could add more things there (like our progress) ? |
|
SymfonyStyle is about formatting the output. Telling that some styles must go to stdout and some other styles go to stderr is wrong. This is misunderstanding the goal of stderr and stdout (naming them stderr and stdout does not help understand their goal either btw). |
|
Yep, we want to push the progress to stderr. |
|
@SpacePossum I think we won't hear anything about this from Symfony soon. |
Why do you think, all members are busy? I'll ping again, its been 10 days since my last proposal, hope I ping the right people ^-^ |
|
@SpacePossum , symfony/symfony#15794 has been merged. Would it help us? |
|
@keradus that PR addresses some helpers we don't use ATM (and probably won't any time soon). |
|
My PR to SF to get testing options for both stdout and stderr has been merged, however it has been done on 3.x line only. I would like to suggest to move on without it by adding a bit of a polyfill until the fixer requirements reach the 3.x line of packages of SF. |
|
fine for me |
|
ping @SpacePossum |
|
I think a wait out #1824 since it will cover the output format testing. This means the tests here can be removed and this PR can focus on the used output streams only. I'll work on this soon to get the test logic in place we are going to need though :) |
|
#1824 is merged. please update |
|
|
||
| $fixEvent = $this->stopwatch->getEvent('fixFiles'); | ||
| $output->writeln(sprintf('%s all files in %.3f seconds, %.3f MB memory used', $input->getOption('dry-run') ? 'Checked' : 'Fixed', $fixEvent->getDuration() / 1000, $fixEvent->getMemory() / 1024 / 1024)); | ||
| $stdErr->writeln(sprintf('%s all files in %.3f seconds, %.3f MB memory used', $input->getOption('dry-run') ? 'Checked' : 'Fixed', $fixEvent->getDuration() / 1000, $fixEvent->getMemory() / 1024 / 1024)); |
There was a problem hiding this comment.
seems wrong to print information to stderr when it's not an error
There was a problem hiding this comment.
It is not, the naming of the streams is confusing. It is better, IMO, to send all kind of information to stdErr and only parsable formatted info to stdOut
|
Reworked, please note this PR is now for ^1.12 only. |
|
you mean that non of those changes should be merged into 2.x, right? |
indeed, it is all good on 2.x :) |
|
Cool ;) |
|
Thank you @SpacePossum. |
This PR was merged into the 1.12 branch. Discussion ---------- Split output to stderr and stdout For more correct testing I need symfony/symfony#17255 to be resolved. issue: #1579 (and others) Commits ------- 880f58d Split output to stderr and stdout.
|
I'm writing post about CLI output styles PHP packages use and I Googled this is the 1 place in PHP CS Fixer that mentions It was declided due to min-requiremeent bump to Symfony 2.8. Now the min. version is Symfony 3.2, so it's ready 👍 Just FYI |
For more correct testing I need symfony/symfony#17255 to be resolved.
issue: #1579 (and others)