This commit is contained in:
Fabien Potencier
2024-11-30 09:42:13 +01:00
parent 44516133e2
commit 14fc89ebea
10 changed files with 16 additions and 22 deletions
+1
View File
@@ -88,6 +88,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();
+4 -8
View File
@@ -931,10 +931,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 {
@@ -949,11 +947,9 @@ class ExpressionParser
if (
$node instanceof NameExpression
&&
(
&& (
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());
+5 -6
View File
@@ -55,7 +55,6 @@ use Twig\Node\Expression\Filter\DefaultFilter;
use Twig\Node\Expression\FunctionNode\EnumCasesFunction;
use Twig\Node\Expression\FunctionNode\EnumFunction;
use Twig\Node\Expression\GetAttrExpression;
use Twig\Node\Expression\NullCoalesceExpression;
use Twig\Node\Expression\ParentExpression;
use Twig\Node\Expression\Test\ConstantTest;
use Twig\Node\Expression\Test\DefinedTest;
@@ -533,8 +532,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
*
* @return \DateTime|\DateTimeImmutable
*/
@@ -785,9 +784,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
*/
+1 -1
View File
@@ -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)
{
@@ -13,7 +13,6 @@
namespace Twig\Node\Expression;
use Twig\Compiler;
use Twig\Node\Expression\OperatorEscapeInterface;
use Twig\Node\Expression\Ternary\ConditionalTernary;
class ConditionalExpression extends AbstractExpression implements OperatorEscapeInterface
@@ -18,7 +18,6 @@ use Twig\Template;
class GetAttrExpression extends AbstractExpression
{
/**
* @param ArrayExpression|NameExpression|null $arguments
*/
@@ -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.
+2 -2
View File
@@ -244,9 +244,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")
;
+1 -1
View File
@@ -201,7 +201,7 @@ class LexerTest extends TestCase
EOF,
"\x6",
];
yield [
yield [
<<<'EOF'
{{ '\065\x64' }}
EOF,
+1 -1
View File
@@ -134,4 +134,4 @@ EOF
class NodeForTest extends Node
{
}
}