minor #3958 Remove usage of list() in favor of [] (fabpot)

This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Remove usage of list() in favor of []

Commits
-------

af8ec178 Remove list() usage in code
9c0897fa Remove usage of list() in favor of []
This commit is contained in:
Fabien Potencier
2024-01-05 18:52:53 +01:00
10 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -704,7 +704,7 @@ class ExpressionParser
private function parseTestExpression(Node $node): TestExpression
{
$stream = $this->parser->getStream();
list($name, $test) = $this->getTest($node->getTemplateLine());
[$name, $test] = $this->getTest($node->getTemplateLine());
$class = $this->getTestNodeClass($test);
$arguments = null;
+3 -3
View File
@@ -210,7 +210,7 @@ class Lexer
$this->pushToken(/* Token::EOF_TYPE */ -1);
if (!empty($this->brackets)) {
list($expect, $lineno) = array_pop($this->brackets);
[$expect, $lineno] = array_pop($this->brackets);
throw new SyntaxError(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
}
@@ -356,7 +356,7 @@ class Lexer
throw new SyntaxError(sprintf('Unexpected "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
}
list($expect, $lineno) = array_pop($this->brackets);
[$expect, $lineno] = array_pop($this->brackets);
if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
throw new SyntaxError(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
}
@@ -426,7 +426,7 @@ class Lexer
$this->pushToken(/* Token::STRING_TYPE */ 7, stripcslashes($match[0]));
$this->moveCursor($match[0]);
} elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, 0, $this->cursor)) {
list($expect, $lineno) = array_pop($this->brackets);
[$expect, $lineno] = array_pop($this->brackets);
if ('"' != $this->code[$this->cursor]) {
throw new SyntaxError(sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
}
+1 -1
View File
@@ -183,7 +183,7 @@ class FilesystemLoader implements LoaderInterface
}
try {
list($namespace, $shortname) = $this->parseName($name);
[$namespace, $shortname] = $this->parseName($name);
$this->validateName($shortname);
} catch (LoaderError $e) {
+1 -1
View File
@@ -140,7 +140,7 @@ abstract class CallExpression extends AbstractExpression
throw new \LogicException($message);
}
list($callableParameters, $isPhpVariadic) = $this->getCallableParameters($callable, $isVariadic);
[$callableParameters, $isPhpVariadic] = $this->getCallableParameters($callable, $isVariadic);
$arguments = [];
$names = [];
$missingArguments = [];
+2 -2
View File
@@ -48,7 +48,7 @@ class SetNode extends Node implements NodeCaptureInterface
$compiler->addDebugInfo($this);
if (\count($this->getNode('names')) > 1) {
$compiler->write('list(');
$compiler->write('[');
foreach ($this->getNode('names') as $idx => $node) {
if ($idx) {
$compiler->raw(', ');
@@ -56,7 +56,7 @@ class SetNode extends Node implements NodeCaptureInterface
$compiler->subcompile($node);
}
$compiler->raw(')');
$compiler->raw(']');
} else {
$compiler->subcompile($this->getNode('names'), false);
}
+1 -1
View File
@@ -176,6 +176,6 @@ final class Profile implements \IteratorAggregate, \Serializable
*/
public function __unserialize(array $data): void
{
list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = $data;
[$this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles] = $data;
}
}
+1 -1
View File
@@ -234,7 +234,7 @@ abstract class IntegrationTestCase extends TestCase
}
if (false !== $exception) {
list($class) = explode(':', $exception);
[$class] = explode(':', $exception);
$constraintClass = class_exists('PHPUnit\Framework\Constraint\Exception') ? 'PHPUnit\Framework\Constraint\Exception' : 'PHPUnit_Framework_Constraint_Exception';
$this->assertThat(null, new $constraintClass($class));
}
+1 -1
View File
@@ -30,7 +30,7 @@ final class EmbedTokenParser extends IncludeTokenParser
$parent = $this->parser->getExpressionParser()->parseExpression();
list($variables, $only, $ignoreMissing) = $this->parseArguments();
[$variables, $only, $ignoreMissing] = $this->parseArguments();
$parentToken = $fakeParentToken = new Token(/* Token::STRING_TYPE */ 7, '__parent__', $token->getLine());
if ($parent instanceof ConstantExpression) {
+1 -1
View File
@@ -31,7 +31,7 @@ class IncludeTokenParser extends AbstractTokenParser
{
$expr = $this->parser->getExpressionParser()->parseExpression();
list($variables, $only, $ignoreMissing) = $this->parseArguments();
[$variables, $only, $ignoreMissing] = $this->parseArguments();
return new IncludeNode($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
}
+1 -1
View File
@@ -78,7 +78,7 @@ EOF
$node = new SetNode(false, $names, $values, 1);
$tests[] = [$node, <<<EOF
// line 1
list(\$context["foo"], \$context["bar"]) = ["foo", {$this->getVariableGetter('bar')}];
[\$context["foo"], \$context["bar"]] = ["foo", {$this->getVariableGetter('bar')}];
EOF
];