Skip to content

Commit e308591

Browse files
Use ??= more
1 parent b0acb1e commit e308591

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

Application.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,8 @@ public function run(InputInterface $input = null, OutputInterface $output = null
143143
@putenv('COLUMNS='.$this->terminal->getWidth());
144144
}
145145

146-
if (null === $input) {
147-
$input = new ArgvInput();
148-
}
149-
150-
if (null === $output) {
151-
$output = new ConsoleOutput();
152-
}
146+
$input ??= new ArgvInput();
147+
$output ??= new ConsoleOutput();
153148

154149
$renderException = function (\Throwable $e) use ($output) {
155150
if ($output instanceof ConsoleOutputInterface) {

Cursor.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,7 @@ public function getCurrentPosition(): array
183183
{
184184
static $isTtySupported;
185185

186-
if (null === $isTtySupported) {
187-
$isTtySupported = ('/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT));
188-
}
189-
190-
if (!$isTtySupported) {
186+
if (!$isTtySupported ??= '/' === \DIRECTORY_SEPARATOR && stream_isatty(\STDOUT)) {
191187
return [1, 1];
192188
}
193189

Helper/ProgressIndicator.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,8 @@ public function __construct(OutputInterface $output, string $format = null, int
5454
{
5555
$this->output = $output;
5656

57-
if (null === $format) {
58-
$format = $this->determineBestFormat();
59-
}
60-
61-
if (null === $indicatorValues) {
62-
$indicatorValues = ['-', '\\', '|', '/'];
63-
}
64-
57+
$format ??= $this->determineBestFormat();
58+
$indicatorValues ??= ['-', '\\', '|', '/'];
6559
$indicatorValues = array_values($indicatorValues);
6660

6761
if (2 > \count($indicatorValues)) {

Output/StreamOutput.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bo
4747

4848
$this->stream = $stream;
4949

50-
if (null === $decorated) {
51-
$decorated = $this->hasColorSupport();
52-
}
50+
$decorated ??= $this->hasColorSupport();
5351

5452
parent::__construct($verbosity, $decorated, $formatter);
5553
}

0 commit comments

Comments
 (0)