Skip to content

Commit

Permalink
[5.7] Apply square bracket syntax for array destructuring assignment (
Browse files Browse the repository at this point in the history
#25966)

Apply `square bracket syntax for array destructuring assignment`, for more information please look into https://wiki.php.net/rfc/short_list_syntax

This rfc was implemented in PHP v7.1. Laravel support php from the 7.1.3
  • Loading branch information
TBlindaruk authored and taylorotwell committed Oct 6, 2018
1 parent ea47451 commit ac74573
Show file tree
Hide file tree
Showing 53 changed files with 133 additions and 133 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Auth/Passwords/PasswordBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function validator(Closure $callback)
public function validateNewPassword(array $credentials)
{
if (isset($this->passwordValidator)) {
list($password, $confirm) = [
[$password, $confirm] = [
$credentials['password'],
$credentials['password_confirmation'],
];
Expand All @@ -167,7 +167,7 @@ public function validateNewPassword(array $credentials)
*/
protected function validatePasswordWithDefaults(array $credentials)
{
list($password, $confirm) = [
[$password, $confirm] = [
$credentials['password'],
$credentials['password_confirmation'],
];
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Cache/MemcachedConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function createMemcachedInstance($connectionId)
*/
protected function setCredentials($memcached, $credentials)
{
list($username, $password) = $credentials;
[$username, $password] = $credentials;

$memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true);

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Config/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getMany($keys)

foreach ($keys as $key => $default) {
if (is_numeric($key)) {
list($key, $default) = [$default, null];
[$key, $default] = [$default, null];
}

$config[$key] = Arr::get($this->items, $key, $default);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Console/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function __construct()
*/
protected function configureUsingFluentDefinition()
{
list($name, $arguments, $options) = Parser::parse($this->signature);
[$name, $arguments, $options] = Parser::parse($this->signature);

parent::__construct($this->name = $name);

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Console/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected static function parameters(array $tokens)
*/
protected static function parseArgument($token)
{
list($token, $description) = static::extractDescription($token);
[$token, $description] = static::extractDescription($token);

switch (true) {
case Str::endsWith($token, '?*'):
Expand All @@ -108,7 +108,7 @@ protected static function parseArgument($token)
*/
protected static function parseOption($token)
{
list($token, $description) = static::extractDescription($token);
[$token, $description] = static::extractDescription($token);

$matches = preg_split('/\s*\|\s*/', $token, 2);

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Cookie/CookieJar.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class CookieJar implements JarContract
*/
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null)
{
list($path, $domain, $secure, $sameSite) = $this->getPathAndDomain($path, $domain, $secure, $sameSite);
[$path, $domain, $secure, $sameSite] = $this->getPathAndDomain($path, $domain, $secure, $sameSite);

$time = ($minutes == 0) ? 0 : $this->availableAt($minutes * 60);

Expand Down Expand Up @@ -176,7 +176,7 @@ protected function getPathAndDomain($path, $domain, $secure = null, $sameSite =
*/
public function setDefaultPathAndDomain($path, $domain, $secure = false, $sameSite = null)
{
list($this->path, $this->domain, $this->secure, $this->sameSite) = [$path, $domain, $secure, $sameSite];
[$this->path, $this->domain, $this->secure, $this->sameSite] = [$path, $domain, $secure, $sameSite];

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Connectors/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Connector
*/
public function createConnection($dsn, array $config, array $options)
{
list($username, $password) = [
[$username, $password] = [
$config['username'] ?? null, $config['password'] ?? null,
];

Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/DatabaseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct($app, ConnectionFactory $factory)
*/
public function connection($name = null)
{
list($database, $type) = $this->parseConnectionName($name);
[$database, $type] = $this->parseConnectionName($name);

$name = $name ?: $database;

Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
*/
public function orWhere($column, $operator = null, $value = null)
{
list($value, $operator) = $this->query->prepareValueAndOperator(
[$value, $operator] = $this->query->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand Down Expand Up @@ -915,7 +915,7 @@ public function scopes(array $scopes)
// the parameter list is empty, so we will format the scope name and these
// parameters here. Then, we'll be ready to call the scope on the model.
if (is_int($scope)) {
list($scope, $parameters) = [$parameters, []];
[$scope, $parameters] = [$parameters, []];
}

// Next we'll pass the scope callback to the callScope method which will take
Expand Down Expand Up @@ -1120,7 +1120,7 @@ protected function parseWithRelations(array $relations)
if (is_numeric($name)) {
$name = $constraints;

list($name, $constraints) = Str::contains($name, ':')
[$name, $constraints] = Str::contains($name, ':')
? $this->createSelectWithConstraint($name)
: [$name, function () {
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ protected function isDateAttribute($key)
*/
public function fillJsonAttribute($key, $value)
{
list($key, $path) = explode('->', $key, 2);
[$key, $path] = explode('->', $key, 2);

$this->attributes[$key] = $this->asJson($this->getArrayAttributeWithValue(
$path, $key, $value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function morphOne($related, $name, $type = null, $id = null, $localKey =
{
$instance = $this->newRelatedInstance($related);

list($type, $id) = $this->getMorphs($name, $type, $id);
[$type, $id] = $this->getMorphs($name, $type, $id);

$table = $instance->getTable();

Expand Down Expand Up @@ -183,7 +183,7 @@ public function morphTo($name = null, $type = null, $id = null, $ownerKey = null
// use that to get both the class and foreign key that will be utilized.
$name = $name ?: $this->guessBelongsToRelation();

list($type, $id) = $this->getMorphs(
[$type, $id] = $this->getMorphs(
Str::snake($name), $type, $id
);

Expand Down Expand Up @@ -266,7 +266,7 @@ public static function getActualClassNameForMorph($class)
*/
protected function guessBelongsToRelation()
{
list($one, $two, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
[$one, $two, $caller] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);

return $caller['function'];
}
Expand Down Expand Up @@ -366,7 +366,7 @@ public function morphMany($related, $name, $type = null, $id = null, $localKey =
// Here we will gather up the morph type and ID for the relationship so that we
// can properly query the intermediate table of a relation. Finally, we will
// get the table and create the relationship instances for the developers.
list($type, $id) = $this->getMorphs($name, $type, $id);
[$type, $id] = $this->getMorphs($name, $type, $id);

$table = $instance->getTable();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function withCount($relations)
unset($alias);

if (count($segments) == 3 && Str::lower($segments[1]) == 'as') {
list($name, $alias) = [$segments[0], $segments[2]];
[$name, $alias] = [$segments[0], $segments[2]];
}

$relation = $this->getRelationWithoutConstraints($name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected function formatRecordsList(array $records)
{
return collect($records)->mapWithKeys(function ($attributes, $id) {
if (! is_array($attributes)) {
list($id, $attributes) = [$attributes, []];
[$id, $attributes] = [$attributes, []];
}

return [$id => $attributes];
Expand Down Expand Up @@ -258,7 +258,7 @@ protected function formatAttachRecords($ids, array $attributes)
*/
protected function formatAttachRecord($key, $value, $attributes, $hasTimestamps)
{
list($id, $attributes) = $this->extractAttachIdAndAttributes($key, $value, $attributes);
[$id, $attributes] = $this->extractAttachIdAndAttributes($key, $value, $attributes);

return array_merge(
$this->baseAttachRecord($id, $hasTimestamps), $this->castAttributes($attributes)
Expand Down
44 changes: 22 additions & 22 deletions src/Illuminate/Database/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function select($columns = ['*'])
*/
public function selectSub($query, $as)
{
list($query, $bindings) = $this->createSub($query);
[$query, $bindings] = $this->createSub($query);

return $this->selectRaw(
'('.$query.') as '.$this->grammar->wrap($as), $bindings
Expand Down Expand Up @@ -271,7 +271,7 @@ public function selectRaw($expression, array $bindings = [])
*/
public function fromSub($query, $as)
{
list($query, $bindings) = $this->createSub($query);
[$query, $bindings] = $this->createSub($query);

return $this->fromRaw('('.$query.') as '.$this->grammar->wrap($as), $bindings);
}
Expand Down Expand Up @@ -440,7 +440,7 @@ public function joinWhere($table, $first, $operator, $second, $type = 'inner')
*/
public function joinSub($query, $as, $first, $operator = null, $second = null, $type = 'inner', $where = false)
{
list($query, $bindings) = $this->createSub($query);
[$query, $bindings] = $this->createSub($query);

$expression = '('.$query.') as '.$this->grammar->wrap($as);

Expand Down Expand Up @@ -592,7 +592,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
// Here we will make some assumptions about the operator. If only 2 values are
// passed to the method, we will assume that the operator is an equals sign
// and keep going. Otherwise, we'll require the operator to be passed in.
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -607,7 +607,7 @@ public function where($column, $operator = null, $value = null, $boolean = 'and'
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
list($value, $operator) = [$operator, '='];
[$value, $operator] = [$operator, '='];
}

// If the value is a Closure, it means the developer is performing an entire
Expand Down Expand Up @@ -726,7 +726,7 @@ protected function invalidOperator($operator)
*/
public function orWhere($column, $operator = null, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand Down Expand Up @@ -755,7 +755,7 @@ public function whereColumn($first, $operator = null, $second = null, $boolean =
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
list($second, $operator) = [$operator, '='];
[$second, $operator] = [$operator, '='];
}

// Finally, we will add this where clause into this array of clauses that we
Expand Down Expand Up @@ -1067,7 +1067,7 @@ public function orWhereNotNull($column)
*/
public function whereDate($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1088,7 +1088,7 @@ public function whereDate($column, $operator, $value = null, $boolean = 'and')
*/
public function orWhereDate($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1106,7 +1106,7 @@ public function orWhereDate($column, $operator, $value = null)
*/
public function whereTime($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1127,7 +1127,7 @@ public function whereTime($column, $operator, $value = null, $boolean = 'and')
*/
public function orWhereTime($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1145,7 +1145,7 @@ public function orWhereTime($column, $operator, $value = null)
*/
public function whereDay($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1166,7 +1166,7 @@ public function whereDay($column, $operator, $value = null, $boolean = 'and')
*/
public function orWhereDay($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1184,7 +1184,7 @@ public function orWhereDay($column, $operator, $value = null)
*/
public function whereMonth($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1205,7 +1205,7 @@ public function whereMonth($column, $operator, $value = null, $boolean = 'and')
*/
public function orWhereMonth($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1223,7 +1223,7 @@ public function orWhereMonth($column, $operator, $value = null)
*/
public function whereYear($column, $operator, $value = null, $boolean = 'and')
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1244,7 +1244,7 @@ public function whereYear($column, $operator, $value = null, $boolean = 'and')
*/
public function orWhereYear($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand Down Expand Up @@ -1526,7 +1526,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a
{
$type = 'JsonLength';

list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand All @@ -1549,7 +1549,7 @@ public function whereJsonLength($column, $operator, $value = null, $boolean = 'a
*/
public function orWhereJsonLength($column, $operator, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand Down Expand Up @@ -1652,15 +1652,15 @@ public function having($column, $operator = null, $value = null, $boolean = 'and
// Here we will make some assumptions about the operator. If only 2 values are
// passed to the method, we will assume that the operator is an equals sign
// and keep going. Otherwise, we'll require the operator to be passed in.
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

// If the given operator is not found in the list of valid operators we will
// assume that the developer is just short-cutting the '=' operators and
// we will set the operators to '=' and set the values appropriately.
if ($this->invalidOperator($operator)) {
list($value, $operator) = [$operator, '='];
[$value, $operator] = [$operator, '='];
}

$this->havings[] = compact('type', 'column', 'operator', 'value', 'boolean');
Expand All @@ -1682,7 +1682,7 @@ public function having($column, $operator = null, $value = null, $boolean = 'and
*/
public function orHaving($column, $operator = null, $value = null)
{
list($value, $operator) = $this->prepareValueAndOperator(
[$value, $operator] = $this->prepareValueAndOperator(
$value, $operator, func_num_args() === 2
);

Expand Down
Loading

0 comments on commit ac74573

Please sign in to comment.