Skip to content

Commit a620674

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: CS: Apply ternary_to_null_coalescing fixer
2 parents 60aeac9 + b3dbccb commit a620674

15 files changed

+28
-28
lines changed

Application.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,11 +836,11 @@ protected function doRenderThrowable(\Throwable $e, OutputInterface $output): vo
836836
]);
837837

838838
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
839-
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
840-
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
841-
$function = isset($trace[$i]['function']) ? $trace[$i]['function'] : '';
842-
$file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
843-
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
839+
$class = $trace[$i]['class'] ?? '';
840+
$type = $trace[$i]['type'] ?? '';
841+
$function = $trace[$i]['function'] ?? '';
842+
$file = $trace[$i]['file'] ?? 'n/a';
843+
$line = $trace[$i]['line'] ?? 'n/a';
844844

845845
$output->writeln(sprintf(' %s%s at <info>%s:%s</info>', $class, $function ? $type.$function.'()' : '', $file, $line), OutputInterface::VERBOSITY_QUIET);
846846
}

Descriptor/ApplicationDescription.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function getCommand(string $name): Command
8080
throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name));
8181
}
8282

83-
return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
83+
return $this->commands[$name] ?? $this->aliases[$name];
8484
}
8585

8686
private function inspectApplication()

Descriptor/JsonDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected function describeCommand(Command $command, array $options = [])
6363
*/
6464
protected function describeApplication(Application $application, array $options = [])
6565
{
66-
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
66+
$describedNamespace = $options['namespace'] ?? null;
6767
$description = new ApplicationDescription($application, $describedNamespace, true);
6868
$commands = [];
6969

@@ -95,7 +95,7 @@ protected function describeApplication(Application $application, array $options
9595
*/
9696
private function writeData(array $data, array $options)
9797
{
98-
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
98+
$flags = $options['json_encoding'] ?? 0;
9999

100100
$this->write(json_encode($data, $flags));
101101
}

Descriptor/MarkdownDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected function describeCommand(Command $command, array $options = [])
147147
*/
148148
protected function describeApplication(Application $application, array $options = [])
149149
{
150-
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
150+
$describedNamespace = $options['namespace'] ?? null;
151151
$description = new ApplicationDescription($application, $describedNamespace);
152152
$title = $this->getApplicationTitle($application);
153153

Descriptor/TextDescriptor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function describeInputArgument(InputArgument $argument, array $options
3939
$default = '';
4040
}
4141

42-
$totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
42+
$totalWidth = $options['total_width'] ?? Helper::strlen($argument->getName());
4343
$spacingWidth = $totalWidth - \strlen($argument->getName());
4444

4545
$this->writeText(sprintf(' <info>%s</info> %s%s%s',
@@ -71,7 +71,7 @@ protected function describeInputOption(InputOption $option, array $options = [])
7171
}
7272
}
7373

74-
$totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions([$option]);
74+
$totalWidth = $options['total_width'] ?? $this->calculateTotalWidthForOptions([$option]);
7575
$synopsis = sprintf('%s%s',
7676
$option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
7777
sprintf('--%s%s', $option->getName(), $value)
@@ -176,7 +176,7 @@ protected function describeCommand(Command $command, array $options = [])
176176
*/
177177
protected function describeApplication(Application $application, array $options = [])
178178
{
179-
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
179+
$describedNamespace = $options['namespace'] ?? null;
180180
$description = new ApplicationDescription($application, $describedNamespace);
181181

182182
if (isset($options['raw_text']) && $options['raw_text']) {

Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function describeCommand(Command $command, array $options = [])
152152
*/
153153
protected function describeApplication(Application $application, array $options = [])
154154
{
155-
$this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
155+
$this->writeDocument($this->getApplicationDocument($application, $options['namespace'] ?? null));
156156
}
157157

158158
/**

Formatter/OutputFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function formatAndWrap(?string $message, int $width)
161161
if ($open = '/' != $text[1]) {
162162
$tag = $matches[1][$i][0];
163163
} else {
164-
$tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
164+
$tag = $matches[3][$i][0] ?? '';
165165
}
166166

167167
if (!$open && !$tag) {

Helper/ProgressBar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static function getPlaceholderFormatterDefinition(string $name): ?callabl
113113
self::$formatters = self::initPlaceholderFormatters();
114114
}
115115

116-
return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
116+
return self::$formatters[$name] ?? null;
117117
}
118118

119119
/**
@@ -146,7 +146,7 @@ public static function getFormatDefinition(string $name): ?string
146146
self::$formats = self::initFormats();
147147
}
148148

149-
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
149+
return self::$formats[$name] ?? null;
150150
}
151151

152152
/**

Helper/ProgressIndicator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static function getFormatDefinition(string $name)
142142
self::$formats = self::initFormats();
143143
}
144144

145-
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
145+
return self::$formats[$name] ?? null;
146146
}
147147

148148
/**
@@ -170,7 +170,7 @@ public static function getPlaceholderFormatterDefinition(string $name)
170170
self::$formatters = self::initPlaceholderFormatters();
171171
}
172172

173-
return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
173+
return self::$formatters[$name] ?? null;
174174
}
175175

176176
private function display()

Helper/QuestionHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ private function getDefaultAnswer(Question $question)
172172
$choices = $question->getChoices();
173173

174174
if (!$question->isMultiselect()) {
175-
return isset($choices[$default]) ? $choices[$default] : $default;
175+
return $choices[$default] ?? $default;
176176
}
177177

178178
$default = explode(',', $default);
179179
foreach ($default as $k => $v) {
180180
$v = $question->isTrimmable() ? trim($v) : $v;
181-
$default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
181+
$default[$k] = $choices[$v] ?? $v;
182182
}
183183
}
184184

0 commit comments

Comments
 (0)