Skip to content

Commit

Permalink
[5.8] Use coalesce operator
Browse files Browse the repository at this point in the history
  • Loading branch information
rentalhost committed Apr 21, 2019
1 parent bc71036 commit f7bb1ca
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 41 deletions.
4 changes: 1 addition & 3 deletions src/Illuminate/Auth/Passwords/PasswordBrokerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ public function broker($name = null)
{
$name = $name ?: $this->getDefaultDriver();

return isset($this->brokers[$name])
? $this->brokers[$name]
: $this->brokers[$name] = $this->resolve($name);
return $this->brokers[$name] ?? ($this->brokers[$name] = $this->resolve($name));
}

/**
Expand Down
12 changes: 2 additions & 10 deletions src/Illuminate/Container/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,7 @@ protected function rebound($abstract)
*/
protected function getReboundCallbacks($abstract)
{
if (isset($this->reboundCallbacks[$abstract])) {
return $this->reboundCallbacks[$abstract];
}

return [];
return $this->reboundCallbacks[$abstract] ?? [];
}

/**
Expand Down Expand Up @@ -1122,11 +1118,7 @@ protected function getExtenders($abstract)
{
$abstract = $this->getAlias($abstract);

if (isset($this->extenders[$abstract])) {
return $this->extenders[$abstract];
}

return [];
return $this->extenders[$abstract] ?? [];
}

/**
Expand Down
4 changes: 1 addition & 3 deletions src/Illuminate/Database/Query/Grammars/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,7 @@ protected function compileOrders(Builder $query, $orders)
protected function compileOrdersToArray(Builder $query, $orders)
{
return array_map(function ($order) {
return ! isset($order['sql'])
? $this->wrap($order['column']).' '.$order['direction']
: $order['sql'];
return $order['sql'] ?? $this->wrap($order['column']).' '.$order['direction'];
}, $orders);
}

Expand Down
6 changes: 1 addition & 5 deletions src/Illuminate/Queue/Console/ListFailedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ protected function matchJobName($payload)
{
preg_match('/"([^"]+)"/', $payload['data']['command'], $matches);

if (isset($matches[1])) {
return $matches[1];
}

return $payload['job'] ?? null;
return $matches[1] ?? $payload['job'] ?? null;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Illuminate/Support/Testing/Fakes/NotificationFake.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ public function hasSent($notifiable, $notification)
*/
protected function notificationsFor($notifiable, $notification)
{
if (isset($this->notifications[get_class($notifiable)][$notifiable->getKey()][$notification])) {
return $this->notifications[get_class($notifiable)][$notifiable->getKey()][$notification];
}

return [];
return $this->notifications[get_class($notifiable)][$notifiable->getKey()][$notification] ?? [];
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Illuminate/Translation/ArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ public function load($locale, $group, $namespace = null)
{
$namespace = $namespace ?: '*';

if (isset($this->messages[$namespace][$locale][$group])) {
return $this->messages[$namespace][$locale][$group];
}

return [];
return $this->messages[$namespace][$locale][$group] ?? [];
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Illuminate/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ public function get($key, array $replace = [], $locale = null, $fallback = true)
// If the line doesn't exist, we will return back the key which was requested as
// that will be quick to spot in the UI if language keys are wrong or missing
// from the application's language files. Otherwise we can return the line.
if (isset($line)) {
return $line;
}

return $key;
return $line ?? $key;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/Illuminate/View/Concerns/ManagesLayouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ protected function extendSection($section, $content)
*/
public function yieldContent($section, $default = '')
{
$sectionContent = $default instanceof View ? $default : e($default);

if (isset($this->sections[$section])) {
$sectionContent = $this->sections[$section];
}
$sectionContent = $this->sections[$section] ?? ($default instanceof View ? $default : e($default));

$sectionContent = str_replace('@@parent', '--parent--holder--', $sectionContent);

Expand Down

0 comments on commit f7bb1ca

Please sign in to comment.