Skip to content

Commit cc0365c

Browse files
[11.x] Add Laravel Pint (#53835)
* install Pint with custom configuration - use an empty preset - set 1 explicit rule - ignore `/tests` (for now) * run Pint this rule ensures all chained methods on a new line are indented exactly once. this avoids arbitrarily aligning with some character or pattern in the first line line, while still giving us the readability of aligned subsequent lines. --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent c2c35e9 commit cc0365c

File tree

69 files changed

+311
-301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+311
-301
lines changed

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"fakerphp/faker": "^1.24",
105105
"guzzlehttp/promises": "^2.0.3",
106106
"guzzlehttp/psr7": "^2.4",
107+
"laravel/pint": "^1.18",
107108
"league/flysystem-aws-s3-v3": "^3.25.1",
108109
"league/flysystem-ftp": "^3.25.1",
109110
"league/flysystem-path-prefixing": "^3.25.1",

pint.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"preset": "empty",
3+
"rules": {
4+
"method_chaining_indentation": true
5+
},
6+
"exclude": [
7+
"tests"
8+
]
9+
}

src/Illuminate/Auth/DatabaseUserProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public function retrieveByToken($identifier, #[\SensitiveParameter] $token)
8787
public function updateRememberToken(UserContract $user, #[\SensitiveParameter] $token)
8888
{
8989
$this->connection->table($this->table)
90-
->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
91-
->update([$user->getRememberTokenName() => $token]);
90+
->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
91+
->update([$user->getRememberTokenName() => $token]);
9292
}
9393

9494
/**

src/Illuminate/Auth/EloquentUserProvider.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function retrieveById($identifier)
5555
$model = $this->createModel();
5656

5757
return $this->newModelQuery($model)
58-
->where($model->getAuthIdentifierName(), $identifier)
59-
->first();
58+
->where($model->getAuthIdentifierName(), $identifier)
59+
->first();
6060
}
6161

6262
/**

src/Illuminate/Broadcasting/Broadcasters/PusherBroadcaster.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ protected function decodePusherResponse($request, $response)
135135
}
136136

137137
return response()->json(json_decode($response, true))
138-
->withCallback($request->callback);
138+
->withCallback($request->callback);
139139
}
140140

141141
/**

src/Illuminate/Bus/Batch.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ public function add($jobs)
171171

172172
return with($this->prepareBatchedChain($job), function ($chain) {
173173
return $chain->first()
174-
->allOnQueue($this->options['queue'] ?? null)
175-
->allOnConnection($this->options['connection'] ?? null)
176-
->chain($chain->slice(1)->values()->all());
174+
->allOnQueue($this->options['queue'] ?? null)
175+
->allOnConnection($this->options['connection'] ?? null)
176+
->chain($chain->slice(1)->values()->all());
177177
});
178178
} else {
179179
$job->withBatchId($this->id);

src/Illuminate/Bus/DatabaseBatchRepository.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ public function __construct(BatchFactory $factory, Connection $connection, strin
5858
public function get($limit = 50, $before = null)
5959
{
6060
return $this->connection->table($this->table)
61-
->orderByDesc('id')
62-
->take($limit)
63-
->when($before, fn ($q) => $q->where('id', '<', $before))
64-
->get()
65-
->map(function ($batch) {
66-
return $this->toBatch($batch);
67-
})
68-
->all();
61+
->orderByDesc('id')
62+
->take($limit)
63+
->when($before, fn ($q) => $q->where('id', '<', $before))
64+
->get()
65+
->map(function ($batch) {
66+
return $this->toBatch($batch);
67+
})
68+
->all();
6969
}
7070

7171
/**
@@ -77,9 +77,9 @@ public function get($limit = 50, $before = null)
7777
public function find(string $batchId)
7878
{
7979
$batch = $this->connection->table($this->table)
80-
->useWritePdo()
81-
->where('id', $batchId)
82-
->first();
80+
->useWritePdo()
81+
->where('id', $batchId)
82+
->first();
8383

8484
if ($batch) {
8585
return $this->toBatch($batch);
@@ -185,8 +185,8 @@ protected function updateAtomicValues(string $batchId, Closure $callback)
185185
{
186186
return $this->connection->transaction(function () use ($batchId, $callback) {
187187
$batch = $this->connection->table($this->table)->where('id', $batchId)
188-
->lockForUpdate()
189-
->first();
188+
->lockForUpdate()
189+
->first();
190190

191191
return is_null($batch) ? [] : tap($callback($batch), function ($values) use ($batchId) {
192192
$this->connection->table($this->table)->where('id', $batchId)->update($values);

src/Illuminate/Cache/DatabaseLock.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ public function release()
112112
{
113113
if ($this->isOwnedByCurrentProcess()) {
114114
$this->connection->table($this->table)
115-
->where('key', $this->name)
116-
->where('owner', $this->owner)
117-
->delete();
115+
->where('key', $this->name)
116+
->where('owner', $this->owner)
117+
->delete();
118118

119119
return true;
120120
}
@@ -130,8 +130,8 @@ public function release()
130130
public function forceRelease()
131131
{
132132
$this->connection->table($this->table)
133-
->where('key', $this->name)
134-
->delete();
133+
->where('key', $this->name)
134+
->delete();
135135
}
136136

137137
/**

src/Illuminate/Cache/DatabaseStore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ protected function incrementOrDecrement($key, $value, Closure $callback)
263263
$prefixed = $this->prefix.$key;
264264

265265
$cache = $this->table()->where('key', $prefixed)
266-
->lockForUpdate()->first();
266+
->lockForUpdate()->first();
267267

268268
// If there is no value in the cache, we will return false here. Otherwise the
269269
// value will be decrypted and we will proceed with this function to either

src/Illuminate/Cache/MemcachedStore.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct($memcached, $prefix = '')
4545
$this->memcached = $memcached;
4646

4747
$this->onVersionThree = (new ReflectionMethod('Memcached', 'getMulti'))
48-
->getNumberOfParameters() == 2;
48+
->getNumberOfParameters() == 2;
4949
}
5050

5151
/**

src/Illuminate/Console/Scheduling/ManagesFrequencies.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ protected function hourBasedSchedule($minutes, $hours)
391391
$hours = is_array($hours) ? implode(',', $hours) : $hours;
392392

393393
return $this->spliceIntoPosition(1, $minutes)
394-
->spliceIntoPosition(2, $hours);
394+
->spliceIntoPosition(2, $hours);
395395
}
396396

397397
/**
@@ -492,8 +492,8 @@ public function sundays()
492492
public function weekly()
493493
{
494494
return $this->spliceIntoPosition(1, 0)
495-
->spliceIntoPosition(2, 0)
496-
->spliceIntoPosition(5, 0);
495+
->spliceIntoPosition(2, 0)
496+
->spliceIntoPosition(5, 0);
497497
}
498498

499499
/**
@@ -518,8 +518,8 @@ public function weeklyOn($dayOfWeek, $time = '0:0')
518518
public function monthly()
519519
{
520520
return $this->spliceIntoPosition(1, 0)
521-
->spliceIntoPosition(2, 0)
522-
->spliceIntoPosition(3, 1);
521+
->spliceIntoPosition(2, 0)
522+
->spliceIntoPosition(3, 1);
523523
}
524524

525525
/**
@@ -574,9 +574,9 @@ public function lastDayOfMonth($time = '0:0')
574574
public function quarterly()
575575
{
576576
return $this->spliceIntoPosition(1, 0)
577-
->spliceIntoPosition(2, 0)
578-
->spliceIntoPosition(3, 1)
579-
->spliceIntoPosition(4, '1-12/3');
577+
->spliceIntoPosition(2, 0)
578+
->spliceIntoPosition(3, 1)
579+
->spliceIntoPosition(4, '1-12/3');
580580
}
581581

582582
/**
@@ -591,7 +591,7 @@ public function quarterlyOn($dayOfQuarter = 1, $time = '0:0')
591591
$this->dailyAt($time);
592592

593593
return $this->spliceIntoPosition(3, $dayOfQuarter)
594-
->spliceIntoPosition(4, '1-12/3');
594+
->spliceIntoPosition(4, '1-12/3');
595595
}
596596

597597
/**
@@ -602,9 +602,9 @@ public function quarterlyOn($dayOfQuarter = 1, $time = '0:0')
602602
public function yearly()
603603
{
604604
return $this->spliceIntoPosition(1, 0)
605-
->spliceIntoPosition(2, 0)
606-
->spliceIntoPosition(3, 1)
607-
->spliceIntoPosition(4, 1);
605+
->spliceIntoPosition(2, 0)
606+
->spliceIntoPosition(3, 1)
607+
->spliceIntoPosition(4, 1);
608608
}
609609

610610
/**
@@ -620,7 +620,7 @@ public function yearlyOn($month = 1, $dayOfMonth = 1, $time = '0:0')
620620
$this->dailyAt($time);
621621

622622
return $this->spliceIntoPosition(3, $dayOfMonth)
623-
->spliceIntoPosition(4, $month);
623+
->spliceIntoPosition(4, $month);
624624
}
625625

626626
/**

src/Illuminate/Database/Connection.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ public function cursor($query, $bindings = [], $useReadPdo = true)
467467
// mode and prepare the bindings for the query. Once that's done we will be
468468
// ready to execute the query against the database and return the cursor.
469469
$statement = $this->prepared($this->getPdoForSelect($useReadPdo)
470-
->prepare($query));
470+
->prepare($query));
471471

472472
$this->bindValues(
473473
$statement, $this->prepareBindings($bindings)

src/Illuminate/Database/Console/DumpCommand.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ protected function schemaState(Connection $connection)
7777
$migrationTable = is_array($migrations) ? ($migrations['table'] ?? 'migrations') : $migrations;
7878

7979
return $connection->getSchemaState()
80-
->withMigrationTable($migrationTable)
81-
->handleOutputUsing(function ($type, $buffer) {
82-
$this->output->write($buffer);
83-
});
80+
->withMigrationTable($migrationTable)
81+
->handleOutputUsing(function ($type, $buffer) {
82+
$this->output->write($buffer);
83+
});
8484
}
8585

8686
/**

src/Illuminate/Database/Console/Migrations/StatusCommand.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ public function handle()
101101
protected function getStatusFor(array $ran, array $batches)
102102
{
103103
return (new Collection($this->getAllMigrationFiles()))
104-
->map(function ($migration) use ($ran, $batches) {
105-
$migrationName = $this->migrator->getMigrationName($migration);
104+
->map(function ($migration) use ($ran, $batches) {
105+
$migrationName = $this->migrator->getMigrationName($migration);
106106

107-
$status = in_array($migrationName, $ran)
108-
? '<fg=green;options=bold>Ran</>'
109-
: '<fg=yellow;options=bold>Pending</>';
107+
$status = in_array($migrationName, $ran)
108+
? '<fg=green;options=bold>Ran</>'
109+
: '<fg=yellow;options=bold>Pending</>';
110110

111-
if (in_array($migrationName, $ran)) {
112-
$status = '['.$batches[$migrationName].'] '.$status;
113-
}
111+
if (in_array($migrationName, $ran)) {
112+
$status = '['.$batches[$migrationName].'] '.$status;
113+
}
114114

115-
return [$migrationName, $status];
116-
});
115+
return [$migrationName, $status];
116+
});
117117
}
118118

119119
/**

src/Illuminate/Database/Console/Seeds/SeedCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ protected function getSeeder()
9696
}
9797

9898
return $this->laravel->make($class)
99-
->setContainer($this->laravel)
100-
->setCommand($this);
99+
->setContainer($this->laravel)
100+
->setCommand($this);
101101
}
102102

103103
/**

src/Illuminate/Database/Console/WipeCommand.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public function handle()
6969
protected function dropAllTables($database)
7070
{
7171
$this->laravel['db']->connection($database)
72-
->getSchemaBuilder()
73-
->dropAllTables();
72+
->getSchemaBuilder()
73+
->dropAllTables();
7474
}
7575

7676
/**
@@ -82,8 +82,8 @@ protected function dropAllTables($database)
8282
protected function dropAllViews($database)
8383
{
8484
$this->laravel['db']->connection($database)
85-
->getSchemaBuilder()
86-
->dropAllViews();
85+
->getSchemaBuilder()
86+
->dropAllViews();
8787
}
8888

8989
/**
@@ -95,8 +95,8 @@ protected function dropAllViews($database)
9595
protected function dropAllTypes($database)
9696
{
9797
$this->laravel['db']->connection($database)
98-
->getSchemaBuilder()
99-
->dropAllTypes();
98+
->getSchemaBuilder()
99+
->dropAllTypes();
100100
}
101101

102102
/**

src/Illuminate/Database/DatabaseManager.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ protected function configuration($name)
228228
}
229229

230230
return (new ConfigurationUrlParser)
231-
->parseConfiguration($config);
231+
->parseConfiguration($config);
232232
}
233233

234234
/**
@@ -374,8 +374,8 @@ protected function refreshPdoConnections($name)
374374
);
375375

376376
return $this->connections[$name]
377-
->setPdo($fresh->getRawPdo())
378-
->setReadPdo($fresh->getRawReadPdo());
377+
->setPdo($fresh->getRawPdo())
378+
->setReadPdo($fresh->getRawReadPdo());
379379
}
380380

381381
/**

src/Illuminate/Database/Eloquent/Concerns/GuardsAttributes.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ protected function isGuardableColumn($key)
220220

221221
if (! isset(static::$guardableColumns[get_class($this)])) {
222222
$columns = $this->getConnection()
223-
->getSchemaBuilder()
224-
->getColumnListing($this->getTable());
223+
->getSchemaBuilder()
224+
->getColumnListing($this->getTable());
225225

226226
if (empty($columns)) {
227227
return true;

src/Illuminate/Database/Eloquent/Concerns/QueriesRelationships.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boole
257257
}
258258

259259
$query->where($this->qualifyColumn($relation->getMorphType()), '=', (new $type)->getMorphClass())
260-
->whereHas($belongsTo, $callback, $operator, $count);
260+
->whereHas($belongsTo, $callback, $operator, $count);
261261
});
262262
}
263263
}, null, null, $boolean);

src/Illuminate/Database/Eloquent/Factories/HasFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public static function factory($count = null, $state = [])
2121
$factory = static::newFactory() ?? Factory::factoryForModel(static::class);
2222

2323
return $factory
24-
->count(is_numeric($count) ? $count : null)
25-
->state(is_callable($count) || is_array($count) ? $count : $state);
24+
->count(is_numeric($count) ? $count : null)
25+
->state(is_callable($count) || is_array($count) ? $count : $state);
2626
}
2727

2828
/**

src/Illuminate/Database/Eloquent/Relations/Concerns/ComparesRelatedModels.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public function is($model)
2222

2323
if ($match && $this instanceof SupportsPartialRelations && $this->isOneOfMany()) {
2424
return $this->query
25-
->whereKey($model->getKey())
26-
->exists();
25+
->whereKey($model->getKey())
26+
->exists();
2727
}
2828

2929
return $match;

0 commit comments

Comments
 (0)