diff --git a/extra/string-extra/StringExtension.php b/extra/string-extra/StringExtension.php index 8ae2a0f53..2849b4e3a 100644 --- a/extra/string-extra/StringExtension.php +++ b/extra/string-extra/StringExtension.php @@ -82,6 +82,7 @@ final class StringExtension extends AbstractExtension if (!class_exists(SpanishInflector::class)) { throw new RuntimeError('SpanishInflector is not available.'); } + return $this->spanishInflector ?? $this->spanishInflector = new SpanishInflector(); case 'fr': return $this->frenchInflector ?? $this->frenchInflector = new FrenchInflector(); diff --git a/src/ExpressionParser.php b/src/ExpressionParser.php index b2dea77df..124c51d73 100644 --- a/src/ExpressionParser.php +++ b/src/ExpressionParser.php @@ -814,10 +814,8 @@ class ExpressionParser $token = $stream->next(); if ( Token::NAME_TYPE == $token->getType() - || - Token::NUMBER_TYPE == $token->getType() - || - (Token::OPERATOR_TYPE == $token->getType() && preg_match(Lexer::REGEX_NAME, $token->getValue())) + || Token::NUMBER_TYPE == $token->getType() + || (Token::OPERATOR_TYPE == $token->getType() && preg_match(Lexer::REGEX_NAME, $token->getValue())) ) { $attribute = new ConstantExpression($token->getValue(), $token->getLine()); } else { @@ -835,8 +833,7 @@ class ExpressionParser && ( null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name')) - || - '_self' === $node->getAttribute('name') && $attribute instanceof ConstantExpression + || '_self' === $node->getAttribute('name') && $attribute instanceof ConstantExpression ) ) { return new MacroReferenceExpression(new TemplateVariable($node->getAttribute('name'), $node->getTemplateLine()), 'macro_'.$attribute->getAttribute('value'), $arguments, $node->getTemplateLine()); diff --git a/src/Extension/CoreExtension.php b/src/Extension/CoreExtension.php index a814582e1..13f3ff948 100644 --- a/src/Extension/CoreExtension.php +++ b/src/Extension/CoreExtension.php @@ -528,8 +528,8 @@ final class CoreExtension extends AbstractExtension * {# do something #} * {% endif %} * - * @param \DateTimeInterface|string|int|null $date A date, a timestamp or null to use the current time - * @param \DateTimeZone|string|false|null $timezone The target timezone, null to use the default, false to leave unchanged + * @param \DateTimeInterface|string|int|null $date A date, a timestamp or null to use the current time + * @param \DateTimeZone|string|false|null $timezone The target timezone, null to use the default, false to leave unchanged */ public function convertDate($date = null, $timezone = null): \DateTimeImmutable { @@ -778,9 +778,9 @@ final class CoreExtension extends AbstractExtension * {{ [1, 2, 3]|join }} * {# returns 123 #} * - * @param iterable|array|string|float|int|bool|null $value An array - * @param string $glue The separator - * @param string|null $and The separator for the last pair + * @param iterable|array|string|float|int|bool|null $value An array + * @param string $glue The separator + * @param string|null $and The separator for the last pair * * @internal */ diff --git a/src/Loader/FilesystemLoader.php b/src/Loader/FilesystemLoader.php index 23add4401..05708416f 100644 --- a/src/Loader/FilesystemLoader.php +++ b/src/Loader/FilesystemLoader.php @@ -35,7 +35,7 @@ class FilesystemLoader implements LoaderInterface /** * @param string|string[] $paths A path or an array of paths where to look for templates - * @param string|null $rootPath The root path common to all relative paths (null for getcwd()) + * @param string|null $rootPath The root path common to all relative paths (null for getcwd()) */ public function __construct($paths = [], ?string $rootPath = null) { diff --git a/src/Node/Expression/OperatorEscapeInterface.php b/src/Node/Expression/OperatorEscapeInterface.php index 7b1e43e35..06db6c616 100644 --- a/src/Node/Expression/OperatorEscapeInterface.php +++ b/src/Node/Expression/OperatorEscapeInterface.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ - namespace Twig\Node\Expression; +namespace Twig\Node\Expression; /** * Interface implemented by n-ary operators for n > 1. diff --git a/src/Node/ModuleNode.php b/src/Node/ModuleNode.php index b13884240..fb3c9f441 100644 --- a/src/Node/ModuleNode.php +++ b/src/Node/ModuleNode.php @@ -237,9 +237,9 @@ final class ModuleNode extends Node ->string($key) ->raw(\sprintf(']; unset($_trait_%s_blocks[', $i)) ->string($key) - ->raw("]); \$this->traitAliases[") + ->raw(']); $this->traitAliases[') ->subcompile($value) - ->raw("] = ") + ->raw('] = ') ->string($key) ->raw(";\n\n") ; diff --git a/tests/LexerTest.php b/tests/LexerTest.php index d2d586ba2..0578d8bef 100644 --- a/tests/LexerTest.php +++ b/tests/LexerTest.php @@ -197,7 +197,7 @@ class LexerTest extends TestCase EOF, "\x6", ]; - yield [ + yield [ <<<'EOF' {{ '\065\x64' }} EOF, diff --git a/tests/Node/NodeTest.php b/tests/Node/NodeTest.php index 58e7429d3..d6c189ce9 100644 --- a/tests/Node/NodeTest.php +++ b/tests/Node/NodeTest.php @@ -124,4 +124,4 @@ EOF class NodeForTest extends Node { -} \ No newline at end of file +}