From c844cdbe64a776b60fdfe351f81aa439be14eb5e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 3 Apr 2019 16:03:21 +0200 Subject: [PATCH] fixed CS --- CHANGELOG | 2 +- src/ExpressionParser.php | 4 ++-- src/Extension/CoreExtension.php | 25 ++++++++++++------------- src/Node/Expression/CallExpression.php | 2 +- src/Template.php | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7c782bd64..dfdb17c0c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 2.8.0 (2019-XX-XX) - * add "column" filter + * added the "column" filter * 2.7.4 (2019-03-23) diff --git a/src/ExpressionParser.php b/src/ExpressionParser.php index 38cbdd8a2..18eecf414 100644 --- a/src/ExpressionParser.php +++ b/src/ExpressionParser.php @@ -13,6 +13,7 @@ namespace Twig; use Twig\Error\SyntaxError; +use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\ArrayExpression; use Twig\Node\Expression\AssignNameExpression; use Twig\Node\Expression\Binary\ConcatBinary; @@ -23,12 +24,11 @@ use Twig\Node\Expression\GetAttrExpression; use Twig\Node\Expression\MethodCallExpression; use Twig\Node\Expression\NameExpression; use Twig\Node\Expression\ParentExpression; +use Twig\Node\Expression\TestExpression; use Twig\Node\Expression\Unary\NegUnary; use Twig\Node\Expression\Unary\NotUnary; use Twig\Node\Expression\Unary\PosUnary; use Twig\Node\Node; -use Twig\Node\Expression\AbstractExpression; -use Twig\Node\Expression\TestExpression; /** * Parses expressions. diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index 09ae1bd81..3d0bba536 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -1319,11 +1319,11 @@ function twig_to_array($seq, $preserveKeys = true) return iterator_to_array($seq, $preserveKeys); } - if (!is_array($seq)) { + if (!\is_array($seq)) { return (array) $seq; } - if(!$preserveKeys) { + if (!$preserveKeys) { return array_values($seq); } @@ -1484,7 +1484,7 @@ function twig_array_batch($items, $size, $fill = null, $preserveKeys = true) if (null !== $fill && $result) { $last = \count($result) - 1; if ($fillCount = $size - \count($result[$last])) { - for ($i = 0; $i < $fillCount; $i++) { + for ($i = 0; $i < $fillCount; ++$i) { $result[$last][] = $fill; } } @@ -1687,7 +1687,7 @@ function twig_get_attribute(Environment $env, Source $source, $object, $item, ar } /** - * Return the values from a single column in the input array. + * Returns the values from a single column in the input array. * *
  *  {% set items = [{ 'fruit' : 'apple'}, {'fruit' : 'orange' }] %}
@@ -1697,20 +1697,19 @@ function twig_get_attribute(Environment $env, Source $source, $object, $item, ar
  *  {# fruits now contains ['apple', 'orange'] #}
  * 
* - * @param array|Traversable $arr An array - * @param mixed $column_key The column key + * @param array|Traversable $array An array + * @param mixed $name The column name * * @return array The array of values */ -function twig_array_column($arr, $column_key) +function twig_array_column($array, $name): array { - if ($arr instanceof Traversable) { - $arr = \iterator_to_array($arr); - } elseif (!\is_array($arr)) { - throw new RuntimeError(sprintf('The column filter only works with arrays or "Traversable", got "%s" as first argument.', \gettype($arr))); + if ($array instanceof Traversable) { + $array = iterator_to_array($array); + } elseif (!\is_array($array)) { + throw new RuntimeError(sprintf('The column filter only works with arrays or "Traversable", got "%s" as first argument.', \gettype($array))); } - return \array_column($arr, $column_key); + return array_column($array, $name); } - } diff --git a/src/Node/Expression/CallExpression.php b/src/Node/Expression/CallExpression.php index 131d78e46..64de6ae4f 100644 --- a/src/Node/Expression/CallExpression.php +++ b/src/Node/Expression/CallExpression.php @@ -257,7 +257,7 @@ abstract class CallExpression extends AbstractExpression $argument = end($parameters); if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && [] === $argument->getDefaultValue()) { array_pop($parameters); - } else if ($argument && $argument->isVariadic()) { + } elseif ($argument && $argument->isVariadic()) { array_pop($parameters); $isPhpVariadic = true; } else { diff --git a/src/Template.php b/src/Template.php index c28f2b5a0..9cf96952d 100644 --- a/src/Template.php +++ b/src/Template.php @@ -310,7 +310,7 @@ abstract class Template } if ($template === $this->getTemplateName()) { - $class = get_class($this); + $class = \get_class($this); if (false !== $pos = strrpos($class, '___', -1)) { $class = substr($class, 0, $pos); }