Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Use new PHP7.2 functions in hasColorSupport#26910

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

Merged

Conversation

@johnstevenson
Copy link
Contributor

QA
Branch?2.7
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PR

Fixes bc break in#26609
Reference:https://github.com/composer/xdebug-handler/blob/master/src/Process.php#L111

theofidry and andreybolonin reacted with heart emoji
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment
edited
Loading

Choose a reason for hiding this comment

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

There are more places that check for color support (grep ConEmuANSI src/ -r)
could you please sync them all?

  • src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
  • src/Symfony/Component/VarDumper/Dumper/CliDumper.php

@johnstevenson
Copy link
ContributorAuthor

Sure. But I could do with some info regarding CliDumper:

The constructor checks for Windows color support (so it can set a restricted style set), but only uses environment variables and not the output.

  1. I guess it is safe to use$this->outputStream here?
  2. Or would it be better to set the styles within thesupportsColors method later?

ThesupportsColors method does one type of check if$this->outputStream is not the default (is_resource &&posix_isatty, which doesn't include windows) and a different, more stringent one if it is. An explanation why would be really useful. Likewise why if it is not the default, the method returns before checking for color options inargv.

I was wondering if the output needs to be differentiated, and if so, then what are the criteria for each type.

@nicolas-grekas
Copy link
Member

Which color set does new versions of Windows support? If it doesn't need the reduced set, then the current logic in the CliDumper constructor should be fine, so that only supportsColors should be updated.

@johnstevenson
Copy link
ContributorAuthor

Windows 10 has supported 24-bit color for over a year now, but you can obviously still run PHP7.2 on earlier versions.

returnfunction_exists('posix_isatty') && @posix_isatty($this->stream);
if (function_exists('stream_isatty')) {
return @stream_isatty($this->stream);
}elseif (function_exists('posix_isatty')) {
Copy link
Member

Choose a reason for hiding this comment

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

justif, notelseif as the previous case returns

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Okay

@johnstevenson
Copy link
ContributorAuthor

I've synced DeprecationErrorHandler.php, but without any info about CliDumper.php I have no idea if my changes are correct.

I've kept the current logic in the CliDumper constructor, which is not ideal since it won't show 24-bit color output in cmd.exe on Windows 10. Incidentally, the Windows tests pass for me locally, but not on Appveyor for some reason:

There were 3 failures:1) Symfony\Component\HttpKernel\Tests\DataCollector\DumpDataCollectorTest::testCollectDefaultFailed asserting that two strings are identical.--- Expected+++ Actual@@ @@-DumpDataCollectorTest.php on line 65:-123+DumpDataCollectorTest.php on line 65:+123C:\projects\symfony\src\Symfony\Component\HttpKernel\Tests\DataCollector\DumpDataCollectorTest.php:732) Symfony\Component\HttpKernel\Tests\DataCollector\DumpDataCollectorTest::testFlushFailed asserting that two strings are identical.--- Expected+++ Actual@@ @@-DumpDataCollectorTest.php on line 123:-456+DumpDataCollectorTest.php on line 123:+456C:\projects\symfony\src\Symfony\Component\HttpKernel\Tests\DataCollector\DumpDataCollectorTest.php:1293) Symfony\Component\HttpKernel\Tests\DataCollector\DumpDataCollectorTest::testFlushNothingWhenDataDumperIsProvidedFailed asserting that two strings are identical.--- Expected+++ Actual@@ @@-DumpDataCollectorTest.php on line 142:-456+DumpDataCollectorTest.php on line 142:+456C:\projects\symfony\src\Symfony\Component\HttpKernel\Tests\DataCollector

I've also added references to the source of the code, but I'll remove them if not considered desirable.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

LGTM, with one minor comment.
About the CliDumper constructor, we have to use 16 colors only on some terminals, which is what we do by default. Do you think we can improve the logic and somehow detect when the native Windows terminal supports 24b colors? That's what missing there.

* Reference: Composer\XdebugHandler\Process::supportsColor
* https://github.com/composer/xdebug-handler
*
* @return bool

Choose a reason for hiding this comment

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

this annotation should be removed and replaced by a return-type on the hasColorsSupport (same in other files below)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

?? Sorry, you've lost me!

Copy link
Member

@nicolas-grekasnicolas-grekasApr 16, 2018
edited
Loading

Choose a reason for hiding this comment

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

Oups sorry, branch 2.7 doesn't support scalar type hints.

@johnstevenson
Copy link
ContributorAuthor

Do you think we can improve the logic and somehow detect when the native Windows terminal supports 24b colors?

Probably, but I need you to answer my original question:

The constructor checks for Windows color support (so it can set a restricted style set), but only uses environment variables and not the output.

  1. I guess it is safe to use $this->outputStream here?
  2. Or would it be better to set the styles within the supportsColors method later?

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedApr 16, 2018
edited
Loading

It is not safe to use$this->outputStream. The check should be done against a global stream,STDOUT basically.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

(with one minor comment)

*/
privatefunctionisWindowsTrueColor()
{
$result =strval(getenv('ANSICON_VER')) >='183'

Choose a reason for hiding this comment

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

thanks to PHP type juggling, this should be simplified to183 <= getenv('ANSICON_VER')

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ah yes, that is a much better way of doing it.

Copy link
Member

Choose a reason for hiding this comment

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

fixed in9234171

@fabpotfabpotforce-pushed thefix-output-hascolorsupport branch from72482c5 tob0c9225CompareApril 22, 2018 05:55
@fabpot
Copy link
Member

Thank you@johnstevenson.

@fabpotfabpot merged commitb0c9225 intosymfony:2.7Apr 22, 2018
fabpot added a commit that referenced this pull requestApr 22, 2018
This PR was squashed before being merged into the 2.7 branch (closes#26910).Discussion----------Use new PHP7.2 functions in hasColorSupport| Q             | A| ------------- | ---| Branch?       |  2.7| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets || License       | MIT| Doc PR        |Fixes bc break in#26609Reference:https://github.com/composer/xdebug-handler/blob/master/src/Process.php#L111Commits-------b0c9225 Use new PHP7.2 functions in hasColorSupport
@johnstevenson
Copy link
ContributorAuthor

Thanks for fixing this remaining item, and apologies for not fixing it myself (life/time problem!)

@johnstevensonjohnstevenson deleted the fix-output-hascolorsupport branchApril 22, 2018 10:41
nicolas-grekas added a commit that referenced this pull requestApr 25, 2018
…ts (chalasr)This PR was merged into the 2.7 branch.Discussion----------[HttpKernel] Remove decoration from actual output in tests| Q             | A| ------------- | ---| Branch?       | 2.7| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes green again| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aAppVeyor has color support since#26910, that breaks the build.Fixes it by removing decoration from tested DumpDataCollector CLI outputs, same as what's already done for HTML dumpsCommits-------c4daef9 [VarDumper] Remove decoration from actual output in tests
This was referencedApr 27, 2018
@fabpotfabpot mentioned this pull requestApr 30, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@stofstofstof left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

2.7

Development

Successfully merging this pull request may close these issues.

5 participants

@johnstevenson@nicolas-grekas@fabpot@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp