From 3105944c52330eb286938ba481ff33fa7be15c3b Mon Sep 17 00:00:00 2001 From: aleksandr-shevchenko Date: Mon, 10 Apr 2023 14:08:12 +0400 Subject: [PATCH 1/4] [Console] Restoring the ability to output unicode text to the Win10 console Restoring the ability to output unicode text to the Win10 console after corrupting the console on line 224 --- Terminal.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Terminal.php b/Terminal.php index 08c53535b..24cef5340 100644 --- a/Terminal.php +++ b/Terminal.php @@ -157,6 +157,8 @@ private static function readFromProcess(string $command): ?string 2 => ['pipe', 'w'], ]; + $cp = \function_exists('sapi_windows_cp_set') ? sapi_windows_cp_get() : 0; + $process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]); if (!\is_resource($process)) { return null; @@ -167,6 +169,10 @@ private static function readFromProcess(string $command): ?string fclose($pipes[2]); proc_close($process); + if ($cp) { + sapi_windows_cp_set($cp); + } + return $info; } } From 79e7e16e187a107e79dd67a531207d2eb9420444 Mon Sep 17 00:00:00 2001 From: cay89 Date: Thu, 5 Jan 2023 13:43:03 +0100 Subject: [PATCH 2/4] [Console] Fix computing column width containing multibyte chars --- Helper/Table.php | 2 +- Tests/Helper/TableTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Helper/Table.php b/Helper/Table.php index 3f2d99145..5c3447ab3 100644 --- a/Helper/Table.php +++ b/Helper/Table.php @@ -805,7 +805,7 @@ private function calculateColumnsWidth(iterable $groups) $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell); $textLength = Helper::width($textContent); if ($textLength > 0) { - $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan())); + $contentColumns = mb_str_split($textContent, ceil($textLength / $cell->getColspan())); foreach ($contentColumns as $position => $content) { $row[$i + $position] = $content; } diff --git a/Tests/Helper/TableTest.php b/Tests/Helper/TableTest.php index 2d70bd271..53001d428 100644 --- a/Tests/Helper/TableTest.php +++ b/Tests/Helper/TableTest.php @@ -316,7 +316,7 @@ public function renderProvider() ], new TableSeparator(), [ - new TableCell('Cupiditate dicta atque porro, tempora exercitationem modi animi nulla nemo vel nihil!', ['colspan' => 3]), + new TableCell('Cupìdĭtâte díctá âtquè pôrrò, tèmpórà exercitátìónèm mòdí ânìmí núllà nèmò vèl níhìl!', ['colspan' => 3]), ], ], 'default', @@ -333,7 +333,7 @@ public function renderProvider() | 9971-5-0210-0 | A Tale of | | | Two Cities | +-------------------------------+-------------------------------+-----------------------------+ -| Cupiditate dicta atque porro, tempora exercitationem modi animi nulla nemo vel nihil! | +| Cupìdĭtâte díctá âtquè pôrrò, tèmpórà exercitátìónèm mòdí ânìmí núllà nèmò vèl níhìl! | +-------------------------------+-------------------------------+-----------------------------+ TABLE From 930de4346ba192c482661d700bf5b9a05620eeb2 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 21 Apr 2023 20:01:19 +0200 Subject: [PATCH 3/4] Fix the list of supported shells for completions in a phar Using glob inside a phar does not work (it does not find anything). Using a DirectoryIterator on the other hand works with phars. This allows this command to compute the list of supported shells properly when used inside a phar. --- Command/DumpCompletionCommand.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Command/DumpCompletionCommand.php b/Command/DumpCompletionCommand.php index 518d606a0..6f809e2f1 100644 --- a/Command/DumpCompletionCommand.php +++ b/Command/DumpCompletionCommand.php @@ -132,8 +132,14 @@ private function tailDebugLog(string $commandName, OutputInterface $output): voi */ private function getSupportedShells(): array { - return array_map(function ($f) { - return pathinfo($f, \PATHINFO_EXTENSION); - }, glob(__DIR__.'/../Resources/completion.*')); + $shells = []; + + foreach (new \DirectoryIterator(__DIR__.'/../Resources/') as $file) { + if (str_starts_with($file->getBasename(), 'completion.') && $file->isFile()) { + $shells[] = $file->getExtension(); + } + } + + return $shells; } } From 90f21e27d0d88ce38720556dd164d4a1e4c3934c Mon Sep 17 00:00:00 2001 From: Dane Powell Date: Mon, 24 Apr 2023 11:47:29 -0700 Subject: [PATCH 4/4] trim(): Argument #1 () must be of type string, bool given --- Terminal.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Terminal.php b/Terminal.php index 24cef5340..04653d3bd 100644 --- a/Terminal.php +++ b/Terminal.php @@ -77,7 +77,8 @@ public static function hasSttyAvailable(): bool private static function initDimensions() { if ('\\' === \DIRECTORY_SEPARATOR) { - if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) { + $ansicon = getenv('ANSICON'); + if (false !== $ansicon && preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim($ansicon), $matches)) { // extract [w, H] from "wxh (WxH)" // or [w, h] from "wxh" self::$width = (int) $matches[1];