Skip to content

Commit 76c7976

Browse files
authored
Merge pull request #4743 from samsonasik/rector-list-to-aray-destruct
[Rector] Apply Rector : ListToArrayDestructRector
2 parents 5eb219e + ed5aa8c commit 76c7976

15 files changed

Lines changed: 27 additions & 25 deletions

File tree

rector.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
2424
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
2525
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
26+
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
2627
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
2728
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
2829
use Rector\Set\ValueObject\SetList;
@@ -88,4 +89,5 @@
8889
$services->set(RemoveUnusedPrivatePropertyRector::class);
8990
$services->set(RemoveErrorSuppressInTryCatchStmtsRector::class);
9091
$services->set(TernaryToNullCoalescingRector::class);
92+
$services->set(ListToArrayDestructRector::class);
9193
};

system/Cache/Handlers/MemcachedHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public function getMetaData(string $key)
351351
return false; // This will return null in a future release
352352
}
353353

354-
list($data, $time, $limit) = $stored;
354+
[$data, $time, $limit] = $stored;
355355

356356
// Calculate the remaining time to live from the original limit
357357
$ttl = time() - $time - $limit;

system/Config/DotEnv.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function parse(): ?array
9090
// If there is an equal sign, then we know we are assigning a variable.
9191
if (strpos($line, '=') !== false)
9292
{
93-
list($name, $value) = $this->normaliseVariable($line);
93+
[$name, $value] = $this->normaliseVariable($line);
9494
$vars[$name] = $value;
9595
$this->setVariable($name, $value);
9696
}
@@ -143,7 +143,7 @@ public function normaliseVariable(string $name, string $value = ''): array
143143
// Split our compound string into its parts.
144144
if (strpos($name, '=') !== false)
145145
{
146-
list($name, $value) = explode('=', $name, 2);
146+
[$name, $value] = explode('=', $name, 2);
147147
}
148148

149149
$name = trim($name);

system/Cookie/Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public static function fromHeaderString(string $cookie, bool $raw = false)
184184
{
185185
if (strpos($part, '=') !== false)
186186
{
187-
list($attr, $val) = explode('=', $part);
187+
[$attr, $val] = explode('=', $part);
188188
}
189189
else
190190
{

system/Filters/Filters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ public function enableFilter(string $name, string $when = 'before')
358358
// Get parameters and clean name
359359
if (strpos($name, ':') !== false)
360360
{
361-
list($name, $params) = explode(':', $name);
361+
[$name, $params] = explode(':', $name);
362362

363363
$params = explode(',', $params);
364364
array_walk($params, function (&$item) {

system/HTTP/Negotiate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ public function matchTypes(array $acceptable, array $supported): bool
391391
{
392392
// PHPDocumentor v2 cannot parse yet the shorter list syntax,
393393
// causing no API generation for the file.
394-
list($aType, $aSubType) = explode('/', $acceptable['value']);
395-
list($sType, $sSubType) = explode('/', $supported['value']);
394+
[$aType, $aSubType] = explode('/', $acceptable['value']);
395+
[$sType, $sSubType] = explode('/', $supported['value']);
396396

397397
// If the types don't match, we're done.
398398
if ($aType !== $sType)

system/I18n/Time.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ public function setSecond($value)
758758
*/
759759
protected function setValue(string $name, $value)
760760
{
761-
list($year, $month, $day, $hour, $minute, $second) = explode('-', $this->format('Y-n-j-G-i-s'));
761+
[$year, $month, $day, $hour, $minute, $second] = explode('-', $this->format('Y-n-j-G-i-s'));
762762
$$name = $value;
763763

764764
return Time::create(

system/Images/Handlers/BaseHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,14 +638,14 @@ public function fit(int $width, int $height = null, string $position = 'center')
638638
$origWidth = $this->image()->origWidth;
639639
$origHeight = $this->image()->origHeight;
640640

641-
list($cropWidth, $cropHeight) = $this->calcAspectRatio($width, $height, $origWidth, $origHeight);
641+
[$cropWidth, $cropHeight] = $this->calcAspectRatio($width, $height, $origWidth, $origHeight);
642642

643643
if (is_null($height))
644644
{
645645
$height = ceil(($width / $cropWidth) * $cropHeight);
646646
}
647647

648-
list($x, $y) = $this->calcCropCoords($cropWidth, $cropHeight, $origWidth, $origHeight, $position);
648+
[$x, $y] = $this->calcCropCoords($cropWidth, $cropHeight, $origWidth, $origHeight, $position);
649649

650650
return $this->crop($cropWidth, $cropHeight, $x, $y)
651651
->resize($width, $height);

system/Images/Handlers/ImageMagickHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ protected function _text(string $text, array $options = [])
450450
// Color
451451
if (isset($options['color']))
452452
{
453-
list($r, $g, $b) = sscanf("#{$options['color']}", '#%02x%02x%02x');
453+
[$r, $g, $b] = sscanf("#{$options['color']}", '#%02x%02x%02x');
454454

455455
$cmd .= " -fill 'rgba({$r},{$g},{$b},{$options['opacity']})'";
456456
}

system/Language/Language.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,23 @@ public function getLine(string $line, array $args = [])
115115

116116
// Parse out the file name and the actual alias.
117117
// Will load the language file and strings.
118-
list($file, $parsedLine) = $this->parseLine($line, $this->locale);
118+
[$file, $parsedLine] = $this->parseLine($line, $this->locale);
119119

120120
$output = $this->getTranslationOutput($this->locale, $file, $parsedLine);
121121

122122
if ($output === null && strpos($this->locale, '-'))
123123
{
124-
list($locale) = explode('-', $this->locale, 2);
124+
[$locale] = explode('-', $this->locale, 2);
125125

126-
list($file, $parsedLine) = $this->parseLine($line, $locale);
126+
[$file, $parsedLine] = $this->parseLine($line, $locale);
127127

128128
$output = $this->getTranslationOutput($locale, $file, $parsedLine);
129129
}
130130

131131
// if still not found, try English
132132
if ($output === null)
133133
{
134-
list($file, $parsedLine) = $this->parseLine($line, 'en');
134+
[$file, $parsedLine] = $this->parseLine($line, 'en');
135135

136136
$output = $this->getTranslationOutput('en', $file, $parsedLine);
137137
}

0 commit comments

Comments
 (0)