Skip to content

Commit 4118225

Browse files
committed
CS: Apply ternary_to_null_coalescing fixer
1 parent 80b042c commit 4118225

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

Loader/YamlFileLoader.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,13 @@ public function supports($resource, $type = null)
108108
*/
109109
protected function parseRoute(RouteCollection $collection, $name, array $config, $path)
110110
{
111-
$defaults = isset($config['defaults']) ? $config['defaults'] : [];
112-
$requirements = isset($config['requirements']) ? $config['requirements'] : [];
113-
$options = isset($config['options']) ? $config['options'] : [];
114-
$host = isset($config['host']) ? $config['host'] : '';
115-
$schemes = isset($config['schemes']) ? $config['schemes'] : [];
116-
$methods = isset($config['methods']) ? $config['methods'] : [];
117-
$condition = isset($config['condition']) ? $config['condition'] : null;
111+
$defaults = $config['defaults'] ?? [];
112+
$requirements = $config['requirements'] ?? [];
113+
$options = $config['options'] ?? [];
114+
$host = $config['host'] ?? '';
115+
$schemes = $config['schemes'] ?? [];
116+
$methods = $config['methods'] ?? [];
117+
$condition = $config['condition'] ?? null;
118118

119119
foreach ($requirements as $placeholder => $requirement) {
120120
if (\is_int($placeholder)) {
@@ -161,15 +161,15 @@ protected function parseRoute(RouteCollection $collection, $name, array $config,
161161
*/
162162
protected function parseImport(RouteCollection $collection, array $config, $path, $file)
163163
{
164-
$type = isset($config['type']) ? $config['type'] : null;
165-
$prefix = isset($config['prefix']) ? $config['prefix'] : '';
166-
$defaults = isset($config['defaults']) ? $config['defaults'] : [];
167-
$requirements = isset($config['requirements']) ? $config['requirements'] : [];
168-
$options = isset($config['options']) ? $config['options'] : [];
169-
$host = isset($config['host']) ? $config['host'] : null;
170-
$condition = isset($config['condition']) ? $config['condition'] : null;
171-
$schemes = isset($config['schemes']) ? $config['schemes'] : null;
172-
$methods = isset($config['methods']) ? $config['methods'] : null;
164+
$type = $config['type'] ?? null;
165+
$prefix = $config['prefix'] ?? '';
166+
$defaults = $config['defaults'] ?? [];
167+
$requirements = $config['requirements'] ?? [];
168+
$options = $config['options'] ?? [];
169+
$host = $config['host'] ?? null;
170+
$condition = $config['condition'] ?? null;
171+
$schemes = $config['schemes'] ?? null;
172+
$methods = $config['methods'] ?? null;
173173
$trailingSlashOnRoot = $config['trailing_slash_on_root'] ?? true;
174174
$exclude = $config['exclude'] ?? null;
175175

Matcher/TraceableUrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
146146

147147
$this->addTrace('Route matches!', self::ROUTE_MATCHES, $name, $route);
148148

149-
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, isset($status[1]) ? $status[1] : []));
149+
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, $status[1] ?? []));
150150
}
151151

152152
return [];

Matcher/UrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ protected function matchCollection($pathinfo, RouteCollection $routes)
192192
continue;
193193
}
194194

195-
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, isset($status[1]) ? $status[1] : []));
195+
return $this->getAttributes($route, $name, array_replace($matches, $hostMatches, $status[1] ?? []));
196196
}
197197

198198
return [];

RequestContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public function setParameters(array $parameters)
294294
*/
295295
public function getParameter($name)
296296
{
297-
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
297+
return $this->parameters[$name] ?? null;
298298
}
299299

300300
/**

Route.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public function setOption($name, $value)
324324
*/
325325
public function getOption($name)
326326
{
327-
return isset($this->options[$name]) ? $this->options[$name] : null;
327+
return $this->options[$name] ?? null;
328328
}
329329

330330
/**
@@ -397,7 +397,7 @@ public function addDefaults(array $defaults)
397397
*/
398398
public function getDefault($name)
399399
{
400-
return isset($this->defaults[$name]) ? $this->defaults[$name] : null;
400+
return $this->defaults[$name] ?? null;
401401
}
402402

403403
/**
@@ -490,7 +490,7 @@ public function addRequirements(array $requirements)
490490
*/
491491
public function getRequirement($key)
492492
{
493-
return isset($this->requirements[$key]) ? $this->requirements[$key] : null;
493+
return $this->requirements[$key] ?? null;
494494
}
495495

496496
/**

RouteCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function all()
9797
*/
9898
public function get($name)
9999
{
100-
return isset($this->routes[$name]) ? $this->routes[$name] : null;
100+
return $this->routes[$name] ?? null;
101101
}
102102

103103
/**

0 commit comments

Comments
 (0)