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

[Console] Constant STDOUT might be undefined#34344

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
fabpot merged 1 commit intosymfony:3.4fromderrabus:bugfix/windows-stdout
Nov 13, 2019

Conversation

derrabus
Copy link
Member

@derrabusderrabus commentedNov 12, 2019
edited by chalasr
Loading

QA
Branch?3.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#34341
LicenseMIT
Doc PRN/A

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.

fopen('php://stdout', 'w')?

@derrabus
Copy link
MemberAuthor

fopen('php://stdout', 'w')?

Would be overkill here. The constant is defined by the CLI SAPI. Thus, if the constant is not there, we're not on CLI, thus we're not on a terminal with VT100 support.

We already have a similar check in PhpUnitBridge:

if (!\defined('STDOUT')) {
returnfalse;
}

@nicolas-grekas
Copy link
Member

I'm not sure I agree. If the check targets the sapi, let's make it crystal clear. Checks for color support all use php://stdout. STDOUT is not used anywhere else in the codebase as far as I checked. I think we should check what we want to check in a portable way, using php://stdout Sorry my previous comment was too laconic.

@derrabus
Copy link
MemberAuthor

STDOUT is not used anywhere else in the codebase as far as I checked.

Well yes, the method I've linked in my previous comment uses the constant to check for color support as well.

privatestaticfunctionhasColorSupport()
{
if (!\defined('STDOUT')) {
returnfalse;
}
if ('Hyper' ===getenv('TERM_PROGRAM')) {
returntrue;
}
if (\DIRECTORY_SEPARATOR ==='\\') {
return (\function_exists('sapi_windows_vt100_support')
&&sapi_windows_vt100_support(STDOUT))
||false !==getenv('ANSICON')
||'ON' ===getenv('ConEmuANSI')
||'xterm' ===getenv('TERM');
}
if (\function_exists('stream_isatty')) {
returnstream_isatty(STDOUT);
}
if (\function_exists('posix_isatty')) {
returnposix_isatty(STDOUT);
}
$stat =fstat(STDOUT);
// Check if formatted mode is S_IFCHR
return$stat ?0020000 === ($stat['mode'] &0170000) :false;
}

Also, I wouldn't want to change the way stdout is accessed without a Windows machine to test on. 😕

@nicolas-grekas
Copy link
Member

That's the bridge, it's not a piece of reusability, it's a tool :)
No worries about php://stdout, it does the very same job.

@derrabus
Copy link
MemberAuthor

All right, here you go.

@lazosweb Can you please test again? Sorry for the hassle. 😃

@lazosweb
Copy link

@derrabus . All good. No issue. That will work too.

@chalasr
Copy link
Member

Should be merged after#34346 and rebased on 3.4.

@derrabus
Copy link
MemberAuthor

Should be merged after#34346 and rebased on 3.4.

@chalasr Feel free to squash my change into your PR. I don't think, we need to backport a buggy solution first. 😉

@chalasrchalasr changed the base branch from4.3 to3.4November 13, 2019 07:07
fabpot pushed a commit that referenced this pull requestNov 13, 2019
This PR was merged into the 3.4 branch.Discussion----------[Console] Constant STDOUT might be undefined| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       |Fix#34341| License       | MIT| Doc PR        | N/ACommits-------bb8c82c [Console] Constant STDOUT might be undefined.
@fabpotfabpot merged commitbb8c82c intosymfony:3.4Nov 13, 2019
@nicolas-grekas
Copy link
Member

Thank you@derrabus

@fabpotfabpot mentioned this pull requestNov 13, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
3.4
Development

Successfully merging this pull request may close these issues.

6 participants
@derrabus@nicolas-grekas@lazosweb@chalasr@fabpot@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp