Skip to content

Commit b3dbccb

Browse files
committed
CS: Apply ternary_to_null_coalescing fixer
1 parent 12e0712 commit b3dbccb

15 files changed

+28
-28
lines changed

Application.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -925,11 +925,11 @@ private function doActuallyRenderThrowable(\Throwable $e, OutputInterface $outpu
925925
]);
926926

927927
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
928-
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
929-
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
930-
$function = isset($trace[$i]['function']) ? $trace[$i]['function'] : '';
931-
$file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
932-
$line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
928+
$class = $trace[$i]['class'] ?? '';
929+
$type = $trace[$i]['type'] ?? '';
930+
$function = $trace[$i]['function'] ?? '';
931+
$file = $trace[$i]['file'] ?? 'n/a';
932+
$line = $trace[$i]['line'] ?? 'n/a';
933933

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

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
@@ -143,7 +143,7 @@ protected function describeCommand(Command $command, array $options = [])
143143
*/
144144
protected function describeApplication(Application $application, array $options = [])
145145
{
146-
$describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
146+
$describedNamespace = $options['namespace'] ?? null;
147147
$description = new ApplicationDescription($application, $describedNamespace);
148148
$title = $this->getApplicationTitle($application);
149149

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
@@ -163,7 +163,7 @@ public function formatAndWrap(string $message, int $width)
163163
if ($open = '/' != $text[1]) {
164164
$tag = $matches[1][$i][0];
165165
} else {
166-
$tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
166+
$tag = $matches[3][$i][0] ?? '';
167167
}
168168

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

Helper/ProgressBar.php

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

113-
return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
113+
return self::$formatters[$name] ?? null;
114114
}
115115

116116
/**
@@ -143,7 +143,7 @@ public static function getFormatDefinition(string $name): ?string
143143
self::$formats = self::initFormats();
144144
}
145145

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

149149
/**

Helper/ProgressIndicator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public static function getFormatDefinition($name)
149149
self::$formats = self::initFormats();
150150
}
151151

152-
return isset(self::$formats[$name]) ? self::$formats[$name] : null;
152+
return self::$formats[$name] ?? null;
153153
}
154154

155155
/**
@@ -182,7 +182,7 @@ public static function getPlaceholderFormatterDefinition($name)
182182
self::$formatters = self::initPlaceholderFormatters();
183183
}
184184

185-
return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
185+
return self::$formatters[$name] ?? null;
186186
}
187187

188188
private function display()

Helper/QuestionHelper.php

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

172172
if (!$question->isMultiselect()) {
173-
return isset($choices[$default]) ? $choices[$default] : $default;
173+
return $choices[$default] ?? $default;
174174
}
175175

176176
$default = explode(',', $default);
177177
foreach ($default as $k => $v) {
178178
$v = $question->isTrimmable() ? trim($v) : $v;
179-
$default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
179+
$default[$k] = $choices[$v] ?? $v;
180180
}
181181
}
182182

0 commit comments

Comments
 (0)