Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve DowngradeStreamIsattyRector when stream_isatty is available #61

Merged
merged 4 commits into from
May 18, 2021

Conversation

pdelre
Copy link
Contributor

@pdelre pdelre commented May 17, 2021

Closes rectorphp/rector#6416

I had originally believed that symfony/console might have a solution that'd work better as it inverts the order of operations. Further investigation showed that Rector already sourced the implementation from Symfony's Polyfills. Running under the assumption that the implementation in symfony/polyfill-php72 is highly used & tested, rules/DowngradePhp72/snippet/isatty_closure.php.inc has been updated to use the latest implementation.

In practice, this adds a function_exists call verifying that posix_isatty is available which is not always the case.

Additionally, given it appears the intent is to downgrade to support lower minimum requirements, this change also adds a check to see if stream_isatty is available and uses the originally intended function when found. My hope here is that PHP >=7.2 is fully supported with mostly unmodified function calls, while <7.2 is supported with the polyfill implementation.

@pdelre pdelre changed the title Issue 6416 improve stream isatty Improve DowngradeStreamIsattyRector when stream_isatty is available May 17, 2021
@TomasVotruba
Copy link
Member

Thank you for very well written description 👍

@TomasVotruba TomasVotruba merged commit 478f5c8 into rectorphp:main May 18, 2021
@pdelre pdelre deleted the issue-6416-improve-stream_isatty branch May 18, 2021 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect behavior of DowngradeStreamIsattyRector
2 participants