Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1500dc9

Browse files
authoredMar 2, 2025··
feat(RequirementChecker): Update the Terminal (#1466)
1 parent 10bd170 commit 1500dc9

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed
 

‎requirement-checker/src/Terminal.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
use function fopen;
2020
use function function_exists;
2121
use function getenv;
22-
use function is_resource;
2322
use function preg_match;
2423
use function proc_close;
2524
use function proc_open;
25+
use function sapi_windows_cp_get;
26+
use function sapi_windows_cp_set;
2627
use function sapi_windows_vt100_support;
2728
use function stream_get_contents;
2829
use function trim;
@@ -173,8 +174,9 @@ private static function readFromProcess(string $command): ?string
173174
2 => ['pipe', 'w'],
174175
];
175176

176-
$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
177-
if (!is_resource($process)) {
177+
$cp = function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0;
178+
179+
if (!$process = @proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true])) {
178180
return null;
179181
}
180182

@@ -183,6 +185,10 @@ private static function readFromProcess(string $command): ?string
183185
fclose($pipes[2]);
184186
proc_close($process);
185187

188+
if ($cp) {
189+
sapi_windows_cp_set($cp);
190+
}
191+
186192
return $info;
187193
}
188194
}

‎requirement-checker/tests/TerminalCompatibility/expected_diff

+3-8
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ namespace Symfony\Component\Console; | namespace KevinGH\RequirementChec
1212
> use function fopen;
1313
> use function function_exists;
1414
> use function getenv;
15-
> use function is_resource;
1615
> use function preg_match;
1716
> use function proc_close;
1817
> use function proc_open;
18+
> use function sapi_windows_cp_get;
19+
> use function sapi_windows_cp_set;
1920
> use function sapi_windows_vt100_support;
2021
> use function stream_get_contents;
2122
> use function trim;
@@ -50,10 +51,4 @@ namespace Symfony\Component\Console; | namespace KevinGH\RequirementChec
5051
*/ <
5152
private static function initDimensionsUsingStty() <
5253
if (!\function_exists('proc_open')) { | if (!function_exists('proc_open')) {
53-
$cp = \function_exists('sapi_windows_cp_set') ? sapi_ <
54-
<
55-
if (!\is_resource($process)) { | if (!is_resource($process)) {
56-
<
57-
if ($cp) { <
58-
sapi_windows_cp_set($cp); <
59-
} <
54+
$cp = \function_exists('sapi_windows_cp_set') ? sapi_ | $cp = function_exists('sapi_windows_cp_set') ? sapi_w

0 commit comments

Comments
 (0)
Please sign in to comment.