Skip to content

[12.x] use single indent for multiline ternaries #54971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Illuminate/Auth/Access/Gate.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ protected function authorizeOnDemand($condition, $message, $code, $allowWhenResp

if ($condition instanceof Closure) {
$response = $this->canBeCalledWithUser($user, $condition)
? $condition($user)
: new Response(false, $message, $code);
? $condition($user)
: new Response(false, $message, $code);
} else {
$response = $condition;
}
Expand Down Expand Up @@ -277,8 +277,8 @@ protected function buildAbilityCallback($ability, $callback)
}

return isset($method)
? $policy->{$method}(...func_get_args())
: $policy(...func_get_args());
? $policy->{$method}(...func_get_args())
: $policy(...func_get_args());
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Auth/DatabaseUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public function retrieveByToken($identifier, #[\SensitiveParameter] $token)
);

return $user && $user->getRememberToken() && hash_equals($user->getRememberToken(), $token)
? $user : null;
? $user
: null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/EloquentUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ public function rehashPasswordIfRequired(UserContract $user, #[\SensitiveParamet
protected function newModelQuery($model = null)
{
$query = is_null($model)
? $this->createModel()->newQuery()
: $model->newQuery();
? $this->createModel()->newQuery()
: $model->newQuery();

with($query, $this->queryCallback);

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function handle($request, Closure $next, $redirectToRoute = null)
($request->user() instanceof MustVerifyEmail &&
! $request->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'Your email address is not verified.')
: Redirect::guest(URL::route($redirectToRoute ?: 'verification.notice'));
? abort(403, 'Your email address is not verified.')
: Redirect::guest(URL::route($redirectToRoute ?: 'verification.notice'));
}

return $next($request);
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/SessionGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ public function id()
}

return $this->user()
? $this->user()->getAuthIdentifier()
: $this->session->get($this->getName());
? $this->user()->getAuthIdentifier()
: $this->session->get($this->getName());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Broadcasting/BroadcastController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public function authenticateUser(Request $request)
}

return Broadcast::resolveAuthenticatedUser($request)
?? throw new AccessDeniedHttpException;
?? throw new AccessDeniedHttpException;
}
}
6 changes: 3 additions & 3 deletions src/Illuminate/Broadcasting/BroadcastEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function __construct($event)
public function handle(BroadcastingFactory $manager)
{
$name = method_exists($this->event, 'broadcastAs')
? $this->event->broadcastAs() : get_class($this->event);
? $this->event->broadcastAs() : get_class($this->event);

$channels = Arr::wrap($this->event->broadcastOn());

Expand All @@ -84,8 +84,8 @@ public function handle(BroadcastingFactory $manager)
}

$connections = method_exists($this->event, 'broadcastConnections')
? $this->event->broadcastConnections()
: [null];
? $this->event->broadcastConnections()
: [null];

$payload = $this->getPayloadFromEvent($this->event);

Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Broadcasting/Broadcasters/AblyBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function validAuthenticationResponse($request, $result)
$user = $this->retrieveUser($request, $channelName);

$broadcastIdentifier = method_exists($user, 'getAuthIdentifierForBroadcasting')
? $user->getAuthIdentifierForBroadcasting()
: $user->getAuthIdentifier();
? $user->getAuthIdentifierForBroadcasting()
: $user->getAuthIdentifier();

$signature = $this->generateAblySignature(
$request->channel_name,
Expand Down Expand Up @@ -175,8 +175,8 @@ public function normalizeChannelName($channel)
{
if ($this->isGuardedChannel($channel)) {
return str_starts_with($channel, 'private-')
? Str::replaceFirst('private-', '', $channel)
: Str::replaceFirst('presence-', '', $channel);
? Str::replaceFirst('private-', '', $channel)
: Str::replaceFirst('presence-', '', $channel);
}

return $channel;
Expand Down
3 changes: 2 additions & 1 deletion src/Illuminate/Broadcasting/Broadcasters/Broadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ protected function binder()
{
if (! $this->bindingRegistrar) {
$this->bindingRegistrar = Container::getInstance()->bound(BindingRegistrar::class)
? Container::getInstance()->make(BindingRegistrar::class) : null;
? Container::getInstance()->make(BindingRegistrar::class)
: null;
}

return $this->bindingRegistrar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public function validAuthenticationResponse($request, $result)
$user = $this->retrieveUser($request, $channelName);

$broadcastIdentifier = method_exists($user, 'getAuthIdentifierForBroadcasting')
? $user->getAuthIdentifierForBroadcasting()
: $user->getAuthIdentifier();
? $user->getAuthIdentifierForBroadcasting()
: $user->getAuthIdentifier();

return $this->decodePusherResponse(
$request,
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Broadcasting/Broadcasters/RedisBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public function validAuthenticationResponse($request, $result)
$user = $this->retrieveUser($request, $channelName);

$broadcastIdentifier = method_exists($user, 'getAuthIdentifierForBroadcasting')
? $user->getAuthIdentifierForBroadcasting()
: $user->getAuthIdentifier();
? $user->getAuthIdentifierForBroadcasting()
: $user->getAuthIdentifier();

return json_encode(['channel_data' => [
'user_id' => $broadcastIdentifier,
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Broadcasting/InteractsWithBroadcasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ trait InteractsWithBroadcasting
public function broadcastVia($connection = null)
{
$this->broadcastConnection = is_null($connection)
? [null]
: Arr::wrap($connection);
? [null]
: Arr::wrap($connection);

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Broadcasting/UniqueBroadcastEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __construct($event)
public function uniqueVia()
{
return method_exists($this->event, 'uniqueVia')
? $this->event->uniqueVia()
: Container::getInstance()->make(Repository::class);
? $this->event->uniqueVia()
: Container::getInstance()->make(Repository::class);
}
}
4 changes: 2 additions & 2 deletions src/Illuminate/Bus/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public function __construct(Container $container, ?Closure $queueResolver = null
public function dispatch($command)
{
return $this->queueResolver && $this->commandShouldBeQueued($command)
? $this->dispatchToQueue($command)
: $this->dispatchNow($command);
? $this->dispatchToQueue($command)
: $this->dispatchNow($command);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Illuminate/Bus/PendingBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public function progressCallbacks()
public function then($callback)
{
$this->options['then'][] = $callback instanceof Closure
? new SerializableClosure($callback)
: $callback;
? new SerializableClosure($callback)
: $callback;

return $this;
}
Expand All @@ -196,8 +196,8 @@ public function thenCallbacks()
public function catch($callback)
{
$this->options['catch'][] = $callback instanceof Closure
? new SerializableClosure($callback)
: $callback;
? new SerializableClosure($callback)
: $callback;

return $this;
}
Expand All @@ -221,8 +221,8 @@ public function catchCallbacks()
public function finally($callback)
{
$this->options['finally'][] = $callback instanceof Closure
? new SerializableClosure($callback)
: $callback;
? new SerializableClosure($callback)
: $callback;

return $this;
}
Expand Down
16 changes: 8 additions & 8 deletions src/Illuminate/Bus/UniqueLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ public function __construct(Cache $cache)
public function acquire($job)
{
$uniqueFor = method_exists($job, 'uniqueFor')
? $job->uniqueFor()
: ($job->uniqueFor ?? 0);
? $job->uniqueFor()
: ($job->uniqueFor ?? 0);

$cache = method_exists($job, 'uniqueVia')
? $job->uniqueVia()
: $this->cache;
? $job->uniqueVia()
: $this->cache;

return (bool) $cache->lock($this->getKey($job), $uniqueFor)->get();
}
Expand All @@ -52,8 +52,8 @@ public function acquire($job)
public function release($job)
{
$cache = method_exists($job, 'uniqueVia')
? $job->uniqueVia()
: $this->cache;
? $job->uniqueVia()
: $this->cache;

$cache->lock($this->getKey($job))->forceRelease();
}
Expand All @@ -67,8 +67,8 @@ public function release($job)
public static function getKey($job)
{
$uniqueId = method_exists($job, 'uniqueId')
? $job->uniqueId()
: ($job->uniqueId ?? '');
? $job->uniqueId()
: ($job->uniqueId ?? '');

return 'laravel_unique_job:'.get_class($job).':'.$uniqueId;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Cache/CacheLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public function acquire()
}

return ($this->seconds > 0)
? $this->store->put($this->name, $this->owner, $this->seconds)
: $this->store->forever($this->name, $this->owner);
? $this->store->put($this->name, $this->owner, $this->seconds)
: $this->store->forever($this->name, $this->owner);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Cache/DynamoDbStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ public function flush()
protected function toTimestamp($seconds)
{
return $seconds > 0
? $this->availableAt($seconds)
: $this->currentTime();
? $this->availableAt($seconds)
: $this->currentTime();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Collections/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,12 @@ public static function sortRecursive($array, $options = SORT_REGULAR, $descendin

if (! array_is_list($array)) {
$descending
? krsort($array, $options)
: ksort($array, $options);
? krsort($array, $options)
: ksort($array, $options);
} else {
$descending
? rsort($array, $options)
: sort($array, $options);
? rsort($array, $options)
: sort($array, $options);
}

return $array;
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Collections/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ public function forPage($page, $perPage)
public function partition($key, $operator = null, $value = null)
{
$callback = func_num_args() === 1
? $this->valueRetriever($key)
: $this->operatorForWhere(...func_get_args());
? $this->valueRetriever($key)
: $this->operatorForWhere(...func_get_args());

[$passed, $failed] = Arr::partition($this->getIterator(), $callback);

Expand Down Expand Up @@ -991,8 +991,8 @@ public function getCachingIterator($flags = CachingIterator::CALL_TOSTRING)
public function __toString()
{
return $this->escapeWhenCastingToString
? e($this->toJson())
: $this->toJson();
? e($this->toJson())
: $this->toJson();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ protected function parseCommand($command, $parameters)
public function output()
{
return $this->lastOutput && method_exists($this->lastOutput, 'fetch')
? $this->lastOutput->fetch()
: '';
? $this->lastOutput->fetch()
: '';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
));

return (int) (is_numeric($this->option('isolated'))
? $this->option('isolated')
: $this->isolatedExitCode);
? $this->option('isolated')
: $this->isolatedExitCode);
}

$method = method_exists($this, 'handle') ? 'handle' : '__invoke';
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/GeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ protected function qualifyModel(string $model)
}

return is_dir(app_path('Models'))
? $rootNamespace.'Models\\'.$model
: $rootNamespace.$model;
? $rootNamespace.'Models\\'.$model
: $rootNamespace.$model;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Scheduling/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ protected function withOutputCallback(Closure $callback, $onlyIfOutputExists = f
$output = $this->output && is_file($this->output) ? file_get_contents($this->output) : '';

return $onlyIfOutputExists && empty($output)
? null
: $container->call($callback, ['output' => new Stringable($output)]);
? null
: $container->call($callback, ['output' => new Stringable($output)]);
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Console/Scheduling/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ public function __construct($timezone = null)
$container = Container::getInstance();

$this->eventMutex = $container->bound(EventMutex::class)
? $container->make(EventMutex::class)
: $container->make(CacheEventMutex::class);
? $container->make(EventMutex::class)
: $container->make(CacheEventMutex::class);

$this->schedulingMutex = $container->bound(SchedulingMutex::class)
? $container->make(SchedulingMutex::class)
: $container->make(CacheSchedulingMutex::class);
? $container->make(SchedulingMutex::class)
: $container->make(CacheSchedulingMutex::class);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Scheduling/ScheduleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ private function getRepeatExpression($event)
private function sortEvents(\Illuminate\Support\Collection $events, DateTimeZone $timezone)
{
return $this->option('next')
? $events->sortBy(fn ($event) => $this->getNextDueDateForEvent($event, $timezone))
: $events;
? $events->sortBy(fn ($event) => $this->getNextDueDateForEvent($event, $timezone))
: $events;
}

/**
Expand Down
Loading
Loading