You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #19012 [Console] progress bar fix (TomasVotruba, fabpot)
This PR was merged into the 3.2-dev branch.
Discussion
----------
[Console] progress bar fix
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #13019
| License | MIT
| Doc PR | -
This is #16490 where I've simplified the code as much as possible and added a test for the bug we're trying to fix.
The main change is the renaming of the `TerminalDimensionsProvider` to just `Terminal`. The new class can probably be useful to add more about the terminal.
Commits
-------
2f81247 switched to use COLUMNS and LINES env vars to change terminal dimensions
bf7a5c5 fixed logic
a589635 deprecated some Console Application methods
8f206c8 fixed CS, simplified code
b030c24 [Console] ProgressBar - adjust to the window width (static)
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
630
629
if (defined('HHVM_VERSION') && $width > 1 << 31) {
631
630
$width = 1 << 31;
@@ -689,60 +688,42 @@ public function renderException(\Exception $e, OutputInterface $output)
689
688
* Tries to figure out the terminal width in which this application runs.
690
689
*
691
690
* @return int|null
691
+
*
692
+
* @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
692
693
*/
693
694
protectedfunctiongetTerminalWidth()
694
695
{
695
-
$dimensions = $this->getTerminalDimensions();
696
+
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
696
697
697
-
return$dimensions[0];
698
+
return$this->terminal->getWidth();
698
699
}
699
700
700
701
/**
701
702
* Tries to figure out the terminal height in which this application runs.
702
703
*
703
704
* @return int|null
705
+
*
706
+
* @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
704
707
*/
705
708
protectedfunctiongetTerminalHeight()
706
709
{
707
-
$dimensions = $this->getTerminalDimensions();
710
+
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
708
711
709
-
return$dimensions[1];
712
+
return$this->terminal->getHeight();
710
713
}
711
714
712
715
/**
713
716
* Tries to figure out the terminal dimensions based on the current environment.
714
717
*
715
718
* @return array Array containing width and height
719
+
*
720
+
* @deprecated since version 3.2, to be removed in 4.0. Create a Terminal instance instead.
716
721
*/
717
722
publicfunctiongetTerminalDimensions()
718
723
{
719
-
if ($this->terminalDimensions) {
720
-
return$this->terminalDimensions;
721
-
}
724
+
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Create a Terminal instance instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
722
725
723
-
if ('\\' === DIRECTORY_SEPARATOR) {
724
-
// extract [w, H] from "wxh (WxH)"
725
-
if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
@trigger_error(sprintf('%s is deprecated as of 3.2 and will be removed in 4.0. Set the COLUMNS and LINES env vars instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
744
+
745
+
putenv('COLUMNS='.$width);
746
+
putenv('LINES='.$height);
761
747
762
748
return$this;
763
749
}
@@ -927,54 +913,6 @@ protected function getDefaultHelperSet()
927
913
));
928
914
}
929
915
930
-
/**
931
-
* Runs and parses stty -a if it's available, suppressing any error output.
0 commit comments