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] Refactor isTtySupported()#46971

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:6.2fromYurunsoft:refactor-isTtySupported
Jul 21, 2022

Conversation

@Yurunsoft
Copy link
Contributor

QA
Branch?6.2
Bug fix?no
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

stream_isatty():https://www.php.net/manual/en/function.stream-isatty.php (PHP 7 >= 7.2.0, PHP 8)

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.2 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbotcarsonbot changed the titleRefactor isTtySupported()[Console] Refactor isTtySupported()Jul 18, 2022
if (null ===$isTtySupported &&\function_exists('proc_open')) {
$isTtySupported = (bool) @proc_open('echo 1 >/dev/null', [['file','/dev/tty','r'], ['file','/dev/tty','w'], ['file','/dev/tty','w']],$pipes);
if (null ===$isTtySupported) {
$isTtySupported = ('/' === \DIRECTORY_SEPARATOR &&stream_isatty(\STDOUT));
Copy link
Member

Choose a reason for hiding this comment

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

IIUC,stream_isatty supports Windows, so do we need the'/' === \DIRECTORY_SEPARATOR part?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Windows does not supportecho 1 >/dev/null, so we need'/' === \DIRECTORY_SEPARATOR

Copy link
Member

Choose a reason for hiding this comment

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

I don't get it, sorry. Are you saying thatstream_isatty is usingecho 1 >/dev/null behind the scenes?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sorry!
Windows does not supportecho 1 >/dev/null, so we need'/' === \DIRECTORY_SEPARATOR.
Usestream_isatty() to determine if tty is supported.

Copy link
Member

Choose a reason for hiding this comment

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

but you don't useecho 1 >/dev/null anymore, andstream_isatty supports windows natively. So this check become useless, isn't?

Copy link
Member

Choose a reason for hiding this comment

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

To be clear, I think having$isTtySupported = stream_isatty(\STDOUT); is enough.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

getCurrentPosition() does not support in windows.

stream_isatty(\STDOUT) may also returntrue in windows.

php:

$cursor =newCursor($output);var_dump($cursor->getCurrentPosition());

log:

'stty' is not recognized as an internal or external command,operable program or batch file.'stty' is not recognized as an internal or external command,operable program or batch file.'stty' is not recognized as an internal or external command,operable program or batch file.array(2) {  [0]=>  NULL  [1]=>  NULL}

@fabpot
Copy link
Member

Thank you@Yurunsoft.

@fabpotfabpot merged commitab3d9fc intosymfony:6.2Jul 21, 2022
@jsandfordhughes
Copy link

This PR has broken the isTtySupported specifically in PHPStorm using the built in run window on a Mac M1 Pro Chip.

By manually changing the method to the old code, everything works fine.

How can we debug the issue here?

@Yurunsoft
Copy link
ContributorAuthor

This PR has broken the isTtySupported specifically in PHPStorm using the built in run window on a Mac M1 Pro Chip.

By manually changing the method to the old code, everything works fine.

How can we debug the issue here?

I run this code in Windows+PHPStorm 2022.3.1+wsl and the result is consistent. Could you test this code?

<?phpdeclare(strict_types=1);var_dump((bool) @proc_open('echo 1 >/dev/null', [['file','/dev/tty','r'], ['file','/dev/tty','w'], ['file','/dev/tty','w']],$pipes));var_dump(stream_isatty(\STDOUT));

image

@audiojames
Copy link

Also having this issue, please see screenshot below of your code, the upper is the phpstorm terminal, the lower is the phpstorm run window. Phpstorm 2022.3.1 on 2021 Mac M1 Pro.

Screenshot 2023-02-06 at 16 24 06

jsandfordhughes reacted with rocket emoji

@jsandfordhughes
Copy link

Thanks for helping@audiojames

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@lyrixxlyrixxlyrixx left review comments

@fabpotfabpotfabpot approved these changes

@chalasrchalasrAwaiting requested review from chalasrchalasr is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

7 participants

@Yurunsoft@carsonbot@fabpot@jsandfordhughes@audiojames@lyrixx@derrabus

[8]ページ先頭

©2009-2025 Movatter.jp