Skip to content

Commit 022d814

Browse files
committed
CS: Apply ternary_to_null_coalescing fixer
1 parent 697a4ee commit 022d814

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

Caster/ExceptionCaster.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@ public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $is
138138

139139
$frame = new FrameStub(
140140
[
141-
'object' => isset($f['object']) ? $f['object'] : null,
142-
'class' => isset($f['class']) ? $f['class'] : null,
143-
'type' => isset($f['type']) ? $f['type'] : null,
144-
'function' => isset($f['function']) ? $f['function'] : null,
141+
'object' => $f['object'] ?? null,
142+
'class' => $f['class'] ?? null,
143+
'type' => $f['type'] ?? null,
144+
'function' => $f['function'] ?? null,
145145
] + $frames[$i - 1],
146146
false,
147147
true
@@ -160,7 +160,7 @@ public static function castTraceStub(TraceStub $trace, array $a, Stub $stub, $is
160160
}
161161
$f = $frames[$i - 1];
162162
if ($trace->keepArgs && !empty($f['args']) && $frame instanceof EnumStub) {
163-
$frame->value['arguments'] = new ArgsStub($f['args'], isset($f['function']) ? $f['function'] : null, isset($f['class']) ? $f['class'] : null);
163+
$frame->value['arguments'] = new ArgsStub($f['args'], $f['function'] ?? null, $f['class'] ?? null);
164164
}
165165
} elseif ('???' !== $lastCall) {
166166
$label = new ClassStub($lastCall);
@@ -209,12 +209,12 @@ public static function castFrameStub(FrameStub $frame, array $a, Stub $stub, $is
209209
$srcKey = $f['file'];
210210
$ellipsis = new LinkStub($srcKey, 0);
211211
$srcAttr = 'collapse='.(int) $ellipsis->inVendor;
212-
$ellipsisTail = isset($ellipsis->attr['ellipsis-tail']) ? $ellipsis->attr['ellipsis-tail'] : 0;
213-
$ellipsis = isset($ellipsis->attr['ellipsis']) ? $ellipsis->attr['ellipsis'] : 0;
212+
$ellipsisTail = $ellipsis->attr['ellipsis-tail'] ?? 0;
213+
$ellipsis = $ellipsis->attr['ellipsis'] ?? 0;
214214

215215
if (file_exists($f['file']) && 0 <= self::$srcContext) {
216216
if (!empty($f['class']) && (is_subclass_of($f['class'], 'Twig\Template') || is_subclass_of($f['class'], 'Twig_Template')) && method_exists($f['class'], 'getDebugInfo')) {
217-
$template = isset($f['object']) ? $f['object'] : unserialize(sprintf('O:%d:"%s":0:{}', \strlen($f['class']), $f['class']));
217+
$template = $f['object'] ?? unserialize(sprintf('O:%d:"%s":0:{}', \strlen($f['class']), $f['class']));
218218

219219
$ellipsis = 0;
220220
$templateSrc = method_exists($template, 'getSourceContext') ? $template->getSourceContext()->getCode() : (method_exists($template, 'getSource') ? $template->getSource() : '');
@@ -312,7 +312,7 @@ private static function extractSource(string $srcLines, int $line, int $srcConte
312312
$src = [];
313313

314314
for ($i = $line - 1 - $srcContext; $i <= $line - 1 + $srcContext; ++$i) {
315-
$src[] = (isset($srcLines[$i]) ? $srcLines[$i] : '')."\n";
315+
$src[] = ($srcLines[$i] ?? '')."\n";
316316
}
317317

318318
if ($frame['function'] ?? false) {

Caster/ReflectionCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public static function castReflectionGenerator(\ReflectionGenerator $c, array $a
114114
}
115115
$function = $c->getFunction();
116116
$frame = [
117-
'class' => isset($function->class) ? $function->class : null,
117+
'class' => $function->class ?? null,
118118
'type' => isset($function->class) ? ($function->isStatic() ? '::' : '->') : null,
119119
'function' => $function->name,
120120
'file' => $c->getExecutingFile(),

Dumper/CliDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ protected function dumpKey(Cursor $cursor)
409409
}
410410
}
411411

412-
$this->line .= $bin.$this->style($style, $key[1], $attr).(isset($attr['separator']) ? $attr['separator'] : ': ');
412+
$this->line .= $bin.$this->style($style, $key[1], $attr).($attr['separator'] ?? ': ');
413413
} else {
414414
// This case should not happen
415415
$this->line .= '-'.$bin.'"'.$this->style('private', $key, ['class' => '']).'": ';
@@ -467,7 +467,7 @@ protected function style($style, $value, $attr = [])
467467
$s = $startCchr;
468468
$c = $c[$i = 0];
469469
do {
470-
$s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', \ord($c[$i]));
470+
$s .= $map[$c[$i]] ?? sprintf('\x%02X', \ord($c[$i]));
471471
} while (isset($c[++$i]));
472472

473473
return $s.$endCchr;
@@ -488,7 +488,7 @@ protected function style($style, $value, $attr = [])
488488

489489
href:
490490
if ($this->colors && $this->handlesHrefGracefully) {
491-
if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], isset($attr['line']) ? $attr['line'] : 0)) {
491+
if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], $attr['line'] ?? 0)) {
492492
if ('note' === $style) {
493493
$value .= "\033]8;;{$href}\033\\^\033]8;;\033\\";
494494
} else {

Dumper/HtmlDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,13 +936,13 @@ protected function style($style, $value, $attr = [])
936936
$s .= '">';
937937
}
938938

939-
$s .= isset($map[$c[$i]]) ? $map[$c[$i]] : sprintf('\x%02X', \ord($c[$i]));
939+
$s .= $map[$c[$i]] ?? sprintf('\x%02X', \ord($c[$i]));
940940
} while (isset($c[++$i]));
941941

942942
return $s.'</span>';
943943
}, $v).'</span>';
944944

945-
if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], isset($attr['line']) ? $attr['line'] : 0)) {
945+
if (isset($attr['file']) && $href = $this->getSourceLink($attr['file'], $attr['line'] ?? 0)) {
946946
$attr['href'] = $href;
947947
}
948948
if (isset($attr['href'])) {

0 commit comments

Comments
 (0)