Skip to content

Commit 14b8ae5

Browse files
authored
[5.x] consistent multiline chaining (#1594)
* consistent multiline chaining sync with styling changes from `laravel/framework` - chained method call on newline - short closures for simple statements * styling fixes
1 parent 395003d commit 14b8ae5

28 files changed

+239
-191
lines changed

src/Console/ContinueCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class ContinueCommand extends Command
3434
*/
3535
public function handle(MasterSupervisorRepository $masters)
3636
{
37-
$masters = collect($masters->all())->filter(function ($master) {
38-
return Str::startsWith($master->name, MasterSupervisor::basename());
39-
})->all();
37+
$masters = collect($masters->all())
38+
->filter(fn ($master) => Str::startsWith($master->name, MasterSupervisor::basename()))
39+
->all();
4040

4141
collect(Arr::pluck($masters, 'pid'))
4242
->whenNotEmpty(fn () => $this->components->info('Sending CONT signal to processes.'))

src/Console/PauseCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class PauseCommand extends Command
3434
*/
3535
public function handle(MasterSupervisorRepository $masters)
3636
{
37-
$masters = collect($masters->all())->filter(function ($master) {
38-
return Str::startsWith($master->name, MasterSupervisor::basename());
39-
})->all();
37+
$masters = collect($masters->all())
38+
->filter(fn ($master) => Str::startsWith($master->name, MasterSupervisor::basename()))
39+
->all();
4040

4141
collect(Arr::pluck($masters, 'pid'))
4242
->whenNotEmpty(fn () => $this->components->info('Sending USR2 signal to processes.'))

src/Console/TerminateCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public function handle(CacheFactory $cache, MasterSupervisorRepository $masters)
4646
);
4747
}
4848

49-
$masters = collect($masters->all())->filter(function ($master) {
50-
return Str::startsWith($master->name, MasterSupervisor::basename());
51-
})->all();
49+
$masters = collect($masters->all())
50+
->filter(fn ($master) => Str::startsWith($master->name, MasterSupervisor::basename()))
51+
->all();
5252

5353
collect(Arr::pluck($masters, 'pid'))
5454
->whenNotEmpty(fn () => $this->components->info('Sending TERM signal to processes.'))

src/Http/Controllers/CompletedJobsController.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ public function __construct(JobRepository $jobs)
3535
*/
3636
public function index(Request $request)
3737
{
38-
$jobs = $this->jobs->getCompleted($request->query('starting_at', -1))->map(function ($job) {
39-
$job->payload = json_decode($job->payload);
38+
$jobs = $this->jobs
39+
->getCompleted($request->query('starting_at', -1))
40+
->map(function ($job) {
41+
$job->payload = json_decode($job->payload);
4042

41-
return $job;
42-
})->values();
43+
return $job;
44+
})
45+
->values();
4346

4447
return [
4548
'jobs' => $jobs,

src/Http/Controllers/DashboardStatsController.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ protected function totalProcessCount()
4343
{
4444
$supervisors = app(SupervisorRepository::class)->all();
4545

46-
return collect($supervisors)->reduce(function ($carry, $supervisor) {
47-
return $carry + collect($supervisor->processes)->sum();
48-
}, 0);
46+
return collect($supervisors)
47+
->reduce(fn ($carry, $supervisor) => $carry + collect($supervisor->processes)->sum(), 0);
4948
}
5049

5150
/**
@@ -59,9 +58,8 @@ protected function currentStatus()
5958
return 'inactive';
6059
}
6160

62-
return collect($masters)->every(function ($master) {
63-
return $master->status === 'paused';
64-
}) ? 'paused' : 'running';
61+
return collect($masters)
62+
->every(fn ($master) => $master->status === 'paused') ? 'paused' : 'running';
6563
}
6664

6765
/**
@@ -75,8 +73,8 @@ protected function totalPausedMasters()
7573
return 0;
7674
}
7775

78-
return collect($masters)->filter(function ($master) {
79-
return $master->status === 'paused';
80-
})->count();
76+
return collect($masters)
77+
->filter(fn ($master) => $master->status === 'paused')
78+
->count();
8179
}
8280
}

src/Http/Controllers/FailedJobsController.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public function index(Request $request)
6767
*/
6868
protected function paginate(Request $request)
6969
{
70-
return $this->jobs->getFailed($request->query('starting_at') ?: -1)->map(function ($job) {
71-
return $this->decode($job);
72-
});
70+
return $this->jobs
71+
->getFailed($request->query('starting_at') ?: -1)
72+
->map(fn ($job) => $this->decode($job));
7373
}
7474

7575
/**
@@ -87,9 +87,9 @@ protected function paginateByTag(Request $request, $tag)
8787

8888
$startingAt = $request->query('starting_at', 0);
8989

90-
return $this->jobs->getJobs($jobIds, $startingAt)->map(function ($job) {
91-
return $this->decode($job);
92-
});
90+
return $this->jobs
91+
->getJobs($jobIds, $startingAt)
92+
->map(fn ($job) => $this->decode($job));
9393
}
9494

9595
/**
@@ -100,9 +100,10 @@ protected function paginateByTag(Request $request, $tag)
100100
*/
101101
public function show($id)
102102
{
103-
return (array) $this->jobs->getJobs([$id])->map(function ($job) {
104-
return $this->decode($job);
105-
})->first();
103+
return (array) $this->jobs
104+
->getJobs([$id])
105+
->map(fn ($job) => $this->decode($job))
106+
->first();
106107
}
107108

108109
/**

src/Http/Controllers/JobMetricsController.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ public function index()
4444
*/
4545
public function show($id)
4646
{
47-
return collect($this->metrics->snapshotsForJob($id))->map(function ($record) {
48-
$record->runtime = round($record->runtime / 1000, 3);
49-
$record->throughput = (int) $record->throughput;
47+
return collect($this->metrics->snapshotsForJob($id))
48+
->map(function ($record) {
49+
$record->runtime = round($record->runtime / 1000, 3);
50+
$record->throughput = (int) $record->throughput;
5051

51-
return $record;
52-
});
52+
return $record;
53+
});
5354
}
5455
}

src/Http/Controllers/JobsController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ public function __construct(JobRepository $jobs)
3434
*/
3535
public function show($id)
3636
{
37-
return (array) $this->jobs->getJobs([$id])->map(function ($job) {
38-
return $this->decode($job);
39-
})->first();
37+
return (array) $this->jobs
38+
->getJobs([$id])
39+
->map(fn ($job) => $this->decode($job))
40+
->first();
4041
}
4142

4243
/**

src/Http/Controllers/MonitoringController.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ public function __construct(JobRepository $jobs, TagRepository $tags)
4646
*/
4747
public function index()
4848
{
49-
return collect($this->tags->monitoring())->map(function ($tag) {
50-
return [
49+
return collect($this->tags->monitoring())
50+
->map(fn ($tag) => [
5151
'tag' => $tag,
5252
'count' => $this->tags->count($tag) + $this->tags->count('failed:'.$tag),
53-
];
54-
})->sortBy('tag')->values();
53+
])
54+
->sortBy('tag')
55+
->values();
5556
}
5657

5758
/**
@@ -84,11 +85,14 @@ public function paginate(Request $request)
8485
*/
8586
protected function getJobs($jobIds, $startingAt = 0)
8687
{
87-
return $this->jobs->getJobs($jobIds, $startingAt)->map(function ($job) {
88-
$job->payload = json_decode($job->payload);
88+
return $this->jobs
89+
->getJobs($jobIds, $startingAt)
90+
->map(function ($job) {
91+
$job->payload = json_decode($job->payload);
8992

90-
return $job;
91-
})->values();
93+
return $job;
94+
})
95+
->values();
9296
}
9397

9498
/**

src/Http/Controllers/PendingJobsController.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ public function __construct(JobRepository $jobs)
3535
*/
3636
public function index(Request $request)
3737
{
38-
$jobs = $this->jobs->getPending($request->query('starting_at', -1))->map(function ($job) {
39-
$job->payload = json_decode($job->payload);
38+
$jobs = $this->jobs
39+
->getPending($request->query('starting_at', -1))
40+
->map(function ($job) {
41+
$job->payload = json_decode($job->payload);
4042

41-
return $job;
42-
})->values();
43+
return $job;
44+
})
45+
->values();
4346

4447
return [
4548
'jobs' => $jobs,

0 commit comments

Comments
 (0)