Skip to content
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

[11.x] Add Laravel Pint #53835

Merged
merged 4 commits into from
Jan 22, 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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"fakerphp/faker": "^1.24",
"guzzlehttp/promises": "^2.0.3",
"guzzlehttp/psr7": "^2.4",
"laravel/pint": "^1.18",
"league/flysystem-aws-s3-v3": "^3.25.1",
"league/flysystem-ftp": "^3.25.1",
"league/flysystem-path-prefixing": "^3.25.1",
Expand Down
9 changes: 9 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"preset": "empty",
"rules": {
"method_chaining_indentation": true
},
"exclude": [
"tests"
]
}
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/DatabaseUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public function retrieveByToken($identifier, #[\SensitiveParameter] $token)
public function updateRememberToken(UserContract $user, #[\SensitiveParameter] $token)
{
$this->connection->table($this->table)
->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
->update([$user->getRememberTokenName() => $token]);
->where($user->getAuthIdentifierName(), $user->getAuthIdentifier())
->update([$user->getRememberTokenName() => $token]);
}

/**
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 @@ -55,8 +55,8 @@ public function retrieveById($identifier)
$model = $this->createModel();

return $this->newModelQuery($model)
->where($model->getAuthIdentifierName(), $identifier)
->first();
->where($model->getAuthIdentifierName(), $identifier)
->first();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected function decodePusherResponse($request, $response)
}

return response()->json(json_decode($response, true))
->withCallback($request->callback);
->withCallback($request->callback);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Bus/Batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ public function add($jobs)

return with($this->prepareBatchedChain($job), function ($chain) {
return $chain->first()
->allOnQueue($this->options['queue'] ?? null)
->allOnConnection($this->options['connection'] ?? null)
->chain($chain->slice(1)->values()->all());
->allOnQueue($this->options['queue'] ?? null)
->allOnConnection($this->options['connection'] ?? null)
->chain($chain->slice(1)->values()->all());
});
} else {
$job->withBatchId($this->id);
Expand Down
26 changes: 13 additions & 13 deletions src/Illuminate/Bus/DatabaseBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public function __construct(BatchFactory $factory, Connection $connection, strin
public function get($limit = 50, $before = null)
{
return $this->connection->table($this->table)
->orderByDesc('id')
->take($limit)
->when($before, fn ($q) => $q->where('id', '<', $before))
->get()
->map(function ($batch) {
return $this->toBatch($batch);
})
->all();
->orderByDesc('id')
->take($limit)
->when($before, fn ($q) => $q->where('id', '<', $before))
->get()
->map(function ($batch) {
return $this->toBatch($batch);
})
->all();
}

/**
Expand All @@ -77,9 +77,9 @@ public function get($limit = 50, $before = null)
public function find(string $batchId)
{
$batch = $this->connection->table($this->table)
->useWritePdo()
->where('id', $batchId)
->first();
->useWritePdo()
->where('id', $batchId)
->first();

if ($batch) {
return $this->toBatch($batch);
Expand Down Expand Up @@ -185,8 +185,8 @@ protected function updateAtomicValues(string $batchId, Closure $callback)
{
return $this->connection->transaction(function () use ($batchId, $callback) {
$batch = $this->connection->table($this->table)->where('id', $batchId)
->lockForUpdate()
->first();
->lockForUpdate()
->first();

return is_null($batch) ? [] : tap($callback($batch), function ($values) use ($batchId) {
$this->connection->table($this->table)->where('id', $batchId)->update($values);
Expand Down
10 changes: 5 additions & 5 deletions src/Illuminate/Cache/DatabaseLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ public function release()
{
if ($this->isOwnedByCurrentProcess()) {
$this->connection->table($this->table)
->where('key', $this->name)
->where('owner', $this->owner)
->delete();
->where('key', $this->name)
->where('owner', $this->owner)
->delete();

return true;
}
Expand All @@ -130,8 +130,8 @@ public function release()
public function forceRelease()
{
$this->connection->table($this->table)
->where('key', $this->name)
->delete();
->where('key', $this->name)
->delete();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/DatabaseStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ protected function incrementOrDecrement($key, $value, Closure $callback)
$prefixed = $this->prefix.$key;

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

// If there is no value in the cache, we will return false here. Otherwise the
// value will be decrypted and we will proceed with this function to either
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/MemcachedStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct($memcached, $prefix = '')
$this->memcached = $memcached;

$this->onVersionThree = (new ReflectionMethod('Memcached', 'getMulti'))
->getNumberOfParameters() == 2;
->getNumberOfParameters() == 2;
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ protected function hourBasedSchedule($minutes, $hours)
$hours = is_array($hours) ? implode(',', $hours) : $hours;

return $this->spliceIntoPosition(1, $minutes)
->spliceIntoPosition(2, $hours);
->spliceIntoPosition(2, $hours);
}

/**
Expand Down Expand Up @@ -492,8 +492,8 @@ public function sundays()
public function weekly()
{
return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, 0)
->spliceIntoPosition(5, 0);
->spliceIntoPosition(2, 0)
->spliceIntoPosition(5, 0);
}

/**
Expand All @@ -518,8 +518,8 @@ public function weeklyOn($dayOfWeek, $time = '0:0')
public function monthly()
{
return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, 0)
->spliceIntoPosition(3, 1);
->spliceIntoPosition(2, 0)
->spliceIntoPosition(3, 1);
}

/**
Expand Down Expand Up @@ -574,9 +574,9 @@ public function lastDayOfMonth($time = '0:0')
public function quarterly()
{
return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, 0)
->spliceIntoPosition(3, 1)
->spliceIntoPosition(4, '1-12/3');
->spliceIntoPosition(2, 0)
->spliceIntoPosition(3, 1)
->spliceIntoPosition(4, '1-12/3');
}

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

return $this->spliceIntoPosition(3, $dayOfQuarter)
->spliceIntoPosition(4, '1-12/3');
->spliceIntoPosition(4, '1-12/3');
}

/**
Expand All @@ -602,9 +602,9 @@ public function quarterlyOn($dayOfQuarter = 1, $time = '0:0')
public function yearly()
{
return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, 0)
->spliceIntoPosition(3, 1)
->spliceIntoPosition(4, 1);
->spliceIntoPosition(2, 0)
->spliceIntoPosition(3, 1)
->spliceIntoPosition(4, 1);
}

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

return $this->spliceIntoPosition(3, $dayOfMonth)
->spliceIntoPosition(4, $month);
->spliceIntoPosition(4, $month);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public function cursor($query, $bindings = [], $useReadPdo = true)
// mode and prepare the bindings for the query. Once that's done we will be
// ready to execute the query against the database and return the cursor.
$statement = $this->prepared($this->getPdoForSelect($useReadPdo)
->prepare($query));
->prepare($query));

$this->bindValues(
$statement, $this->prepareBindings($bindings)
Expand Down
8 changes: 4 additions & 4 deletions src/Illuminate/Database/Console/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ protected function schemaState(Connection $connection)
$migrationTable = is_array($migrations) ? ($migrations['table'] ?? 'migrations') : $migrations;

return $connection->getSchemaState()
->withMigrationTable($migrationTable)
->handleOutputUsing(function ($type, $buffer) {
$this->output->write($buffer);
});
->withMigrationTable($migrationTable)
->handleOutputUsing(function ($type, $buffer) {
$this->output->write($buffer);
});
}

/**
Expand Down
20 changes: 10 additions & 10 deletions src/Illuminate/Database/Console/Migrations/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,19 @@ public function handle()
protected function getStatusFor(array $ran, array $batches)
{
return (new Collection($this->getAllMigrationFiles()))
->map(function ($migration) use ($ran, $batches) {
$migrationName = $this->migrator->getMigrationName($migration);
->map(function ($migration) use ($ran, $batches) {
$migrationName = $this->migrator->getMigrationName($migration);

$status = in_array($migrationName, $ran)
? '<fg=green;options=bold>Ran</>'
: '<fg=yellow;options=bold>Pending</>';
$status = in_array($migrationName, $ran)
? '<fg=green;options=bold>Ran</>'
: '<fg=yellow;options=bold>Pending</>';

if (in_array($migrationName, $ran)) {
$status = '['.$batches[$migrationName].'] '.$status;
}
if (in_array($migrationName, $ran)) {
$status = '['.$batches[$migrationName].'] '.$status;
}

return [$migrationName, $status];
});
return [$migrationName, $status];
});
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Console/Seeds/SeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ protected function getSeeder()
}

return $this->laravel->make($class)
->setContainer($this->laravel)
->setCommand($this);
->setContainer($this->laravel)
->setCommand($this);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/Illuminate/Database/Console/WipeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public function handle()
protected function dropAllTables($database)
{
$this->laravel['db']->connection($database)
->getSchemaBuilder()
->dropAllTables();
->getSchemaBuilder()
->dropAllTables();
}

/**
Expand All @@ -82,8 +82,8 @@ protected function dropAllTables($database)
protected function dropAllViews($database)
{
$this->laravel['db']->connection($database)
->getSchemaBuilder()
->dropAllViews();
->getSchemaBuilder()
->dropAllViews();
}

/**
Expand All @@ -95,8 +95,8 @@ protected function dropAllViews($database)
protected function dropAllTypes($database)
{
$this->laravel['db']->connection($database)
->getSchemaBuilder()
->dropAllTypes();
->getSchemaBuilder()
->dropAllTypes();
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Database/DatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ protected function configuration($name)
}

return (new ConfigurationUrlParser)
->parseConfiguration($config);
->parseConfiguration($config);
}

/**
Expand Down Expand Up @@ -374,8 +374,8 @@ protected function refreshPdoConnections($name)
);

return $this->connections[$name]
->setPdo($fresh->getRawPdo())
->setReadPdo($fresh->getRawReadPdo());
->setPdo($fresh->getRawPdo())
->setReadPdo($fresh->getRawReadPdo());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ protected function isGuardableColumn($key)

if (! isset(static::$guardableColumns[get_class($this)])) {
$columns = $this->getConnection()
->getSchemaBuilder()
->getColumnListing($this->getTable());
->getSchemaBuilder()
->getColumnListing($this->getTable());

if (empty($columns)) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function hasMorph($relation, $types, $operator = '>=', $count = 1, $boole
}

$query->where($this->qualifyColumn($relation->getMorphType()), '=', (new $type)->getMorphClass())
->whereHas($belongsTo, $callback, $operator, $count);
->whereHas($belongsTo, $callback, $operator, $count);
});
}
}, null, null, $boolean);
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Database/Eloquent/Factories/HasFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public static function factory($count = null, $state = [])
$factory = static::newFactory() ?? Factory::factoryForModel(static::class);

return $factory
->count(is_numeric($count) ? $count : null)
->state(is_callable($count) || is_array($count) ? $count : $state);
->count(is_numeric($count) ? $count : null)
->state(is_callable($count) || is_array($count) ? $count : $state);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public function is($model)

if ($match && $this instanceof SupportsPartialRelations && $this->isOneOfMany()) {
return $this->query
->whereKey($model->getKey())
->exists();
->whereKey($model->getKey())
->exists();
}

return $match;
Expand Down
Loading