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

Appearance settings

Commit 85ee0c8

Browse filesBrowse files
committed
fixed CS, simplified code
1 parent 4639345 commit 85ee0c8
Copy full SHA for 85ee0c8

File tree

6 files changed

+111
-263
lines changed
Filter options

6 files changed

+111
-263
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+10-15Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
3636
use Symfony\Component\Console\Exception\CommandNotFoundException;
3737
use Symfony\Component\Console\Exception\LogicException;
38-
use Symfony\Component\Console\Terminal\TerminalDimensionsProvider;
38+
use Symfony\Component\Console\Terminal;
3939
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
4040

4141
/**
@@ -65,23 +65,18 @@ class Application
6565
private $definition;
6666
private $helperSet;
6767
private $dispatcher;
68+
private $terminal;
6869
private $defaultCommand;
6970

7071
/**
71-
* @var TerminalDimensionsProvider
72+
* @param string $name The name of the application
73+
* @param string $version The version of the application
7274
*/
73-
private $terminalDimensionsProvider;
74-
75-
/**
76-
* @param string $name The name of the application
77-
* @param string $version The version of the application
78-
* @param TerminalDimensionsProvider $terminalDimensionsProvider
79-
*/
80-
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN', TerminalDimensionsProvider $terminalDimensionsProvider = null)
75+
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
8176
{
8277
$this->name = $name;
8378
$this->version = $version;
84-
$this->terminalDimensionsProvider = $terminalDimensionsProvider ?: new TerminalDimensionsProvider();
79+
$this->terminal = new Terminal();
8580
$this->defaultCommand = 'list';
8681
$this->helperSet = $this->getDefaultHelperSet();
8782
$this->definition = $this->getDefaultInputDefinition();
@@ -688,7 +683,7 @@ public function renderException(\Exception $e, OutputInterface $output)
688683
*/
689684
protected function getTerminalWidth()
690685
{
691-
return $this->terminalDimensionsProvider->getTerminalWidth();
686+
return $this->terminal->getWidth();
692687
}
693688

694689
/**
@@ -698,7 +693,7 @@ protected function getTerminalWidth()
698693
*/
699694
protected function getTerminalHeight()
700695
{
701-
return $this->terminalDimensionsProvider->getTerminalWidth();
696+
return $this->terminal->getHeight();
702697
}
703698

704699
/**
@@ -708,7 +703,7 @@ protected function getTerminalHeight()
708703
*/
709704
public function getTerminalDimensions()
710705
{
711-
return $this->terminalDimensionsProvider->getTerminalDimensions();
706+
return $this->terminal->getDimensions();
712707
}
713708

714709
/**
@@ -723,7 +718,7 @@ public function getTerminalDimensions()
723718
*/
724719
public function setTerminalDimensions($width, $height)
725720
{
726-
$this->terminalDimensionsProvider->setTerminalDimensions($width, $height);
721+
$this->terminal->setDimensions($width, $height);
727722

728723
return $this;
729724
}

‎src/Symfony/Component/Console/Helper/ProgressBar.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Helper/ProgressBar.php
+20-12Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Console\Output\ConsoleOutputInterface;
1515
use Symfony\Component\Console\Output\OutputInterface;
1616
use Symfony\Component\Console\Exception\LogicException;
17-
use Symfony\Component\Console\Terminal\TerminalDimensionsProvider;
17+
use Symfony\Component\Console\Terminal;
1818

1919
/**
2020
* The ProgressBar provides helpers to display progress output.
@@ -45,29 +45,24 @@ class ProgressBar
4545
private $formatLineCount;
4646
private $messages;
4747
private $overwrite = true;
48+
private $terminal;
4849

4950
private static $formatters;
5051
private static $formats;
5152

5253
/**
53-
* @var TerminalDimensionsProvider
54+
* @param OutputInterface $output An OutputInterface instance
55+
* @param int $max Maximum steps (0 if unknown)
5456
*/
55-
private $terminalDimensionsProvider;
56-
57-
/**
58-
* @param OutputInterface $output An OutputInterface instance
59-
* @param int $max Maximum steps (0 if unknown)
60-
* @param TerminalDimensionsProvider $terminalDimensionsProvider
61-
*/
62-
public function __construct(OutputInterface $output, $max = 0, TerminalDimensionsProvider $terminalDimensionsProvider = null)
57+
public function __construct(OutputInterface $output, $max = 0)
6358
{
6459
if ($output instanceof ConsoleOutputInterface) {
6560
$output = $output->getErrorOutput();
6661
}
6762

6863
$this->output = $output;
6964
$this->setMaxSteps($max);
70-
$this->terminalDimensionsProvider = $terminalDimensionsProvider ?: new TerminalDimensionsProvider();
65+
$this->terminal = new Terminal();
7166

7267
if (!$this->output->isDecorated()) {
7368
// disable overwrite when output does not support ANSI codes.
@@ -433,6 +428,19 @@ public function clear()
433428
$this->overwrite('');
434429
}
435430

431+
/**
432+
* Sets terminal dimensions.
433+
*
434+
* Can be useful to force terminal dimensions for functional tests.
435+
*
436+
* @param int $width The width
437+
* @param int $height The height
438+
*/
439+
public function setTerminalDimensions($width, $height)
440+
{
441+
$this->terminal->setDimensions($width, $height);
442+
}
443+
436444
/**
437445
* Sets the progress bar format.
438446
*
@@ -607,7 +615,7 @@ private function buildLine()
607615
private function adjustLineWidthToTerminalWidth($line)
608616
{
609617
$lineLength = Helper::strlenWithoutDecoration($this->output->getFormatter(), $line);
610-
$terminalWidth = $this->terminalDimensionsProvider->getTerminalWidth();
618+
$terminalWidth = $this->terminal->getWidth();
611619
if ($lineLength > $terminalWidth) {
612620
$newBarWidth = $this->barWidth - $lineLength + $terminalWidth;
613621
$this->setBarWidth($newBarWidth);

‎src/Symfony/Component/Console/Terminal/TerminalDimensionsProvider.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Terminal/TerminalDimensionsProvider.php
-152Lines changed: 0 additions & 152 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.