Skip to content

Commit

Permalink
minor #3958 Remove usage of list() in favor of [] (fabpot)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Remove usage of list() in favor of []

Commits
-------

af8ec17 Remove list() usage in code
9c0897f Remove usage of list() in favor of []
  • Loading branch information
fabpot committed Jan 5, 2024
2 parents b4c3c1c + af8ec17 commit 8b4aa84
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/ExpressionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ private function parseNotTestExpression(Node $node): NotUnary
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;
Expand Down
6 changes: 3 additions & 3 deletions src/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function tokenize(Source $source): TokenStream
$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);
}

Expand Down Expand Up @@ -356,7 +356,7 @@ private function lexExpression(): void
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);
}
Expand Down Expand Up @@ -426,7 +426,7 @@ private function lexString(): void
$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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Loader/FilesystemLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ protected function findTemplate(string $name, bool $throw = true)
}

try {
list($namespace, $shortname) = $this->parseName($name);
[$namespace, $shortname] = $this->parseName($name);

$this->validateName($shortname);
} catch (LoaderError $e) {
Expand Down
2 changes: 1 addition & 1 deletion src/Node/Expression/CallExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function getArguments($callable, $arguments)
throw new \LogicException($message);
}

list($callableParameters, $isPhpVariadic) = $this->getCallableParameters($callable, $isVariadic);
[$callableParameters, $isPhpVariadic] = $this->getCallableParameters($callable, $isVariadic);
$arguments = [];
$names = [];
$missingArguments = [];
Expand Down
4 changes: 2 additions & 2 deletions src/Node/SetNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public function compile(Compiler $compiler): void
$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(', ');
}

$compiler->subcompile($node);
}
$compiler->raw(')');
$compiler->raw(']');
} else {
$compiler->subcompile($this->getNode('names'), false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Profiler/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,6 @@ public function __serialize(): array
*/
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;
}
}
2 changes: 1 addition & 1 deletion src/Test/IntegrationTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected function doIntegrationTest($file, $message, $condition, $templates, $e
}

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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/TokenParser/EmbedTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function parse(Token $token): Node

$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) {
Expand Down
2 changes: 1 addition & 1 deletion src/TokenParser/IncludeTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function parse(Token $token): Node
{
$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());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Node/SetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getTests()
$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
];

Expand Down

0 comments on commit 8b4aa84

Please sign in to comment.