mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 20:06:31 +00:00
Remove compat code
This commit is contained in:
@@ -11,14 +11,6 @@
|
||||
|
||||
namespace Twig\ExpressionParser;
|
||||
|
||||
/**
|
||||
* @method list<string> getOperatorTokens() Returns the operator token strings that this expression parser handles.
|
||||
* These are the strings that should be recognized as operator tokens by the Lexer,
|
||||
* and used to look up the parser in the registry.
|
||||
* For most parsers, this returns the name and aliases. Parsers that don't handle
|
||||
* operator tokens (like LiteralExpressionParser) should return an empty array.
|
||||
* This method will be added to the interface in Twig 4.0.
|
||||
*/
|
||||
interface ExpressionParserInterface
|
||||
{
|
||||
public function __toString(): string;
|
||||
@@ -33,4 +25,17 @@ interface ExpressionParserInterface
|
||||
* @return array<string>
|
||||
*/
|
||||
public function getAliases(): array;
|
||||
|
||||
/**
|
||||
* Returns the operator token strings that this expression parser handles.
|
||||
*
|
||||
* These are the strings that should be recognized as operator tokens by the Lexer,
|
||||
* and used to look up the parser in the registry.
|
||||
*
|
||||
* For most parsers, this returns the name and aliases. Parsers that don't handle
|
||||
* operator tokens should return an empty array.
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public function getOperatorTokens(): array;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ final class ExpressionParsers implements \IteratorAggregate
|
||||
}
|
||||
$interface = $parser instanceof PrefixExpressionParserInterface ? PrefixExpressionParserInterface::class : InfixExpressionParserInterface::class;
|
||||
$this->parsersByClass[$parser::class] = $parser;
|
||||
foreach (self::getOperatorTokensFor($parser) as $token) {
|
||||
foreach ($parser->getOperatorTokens() as $token) {
|
||||
$this->parsersByName[$interface][$token] = $parser;
|
||||
}
|
||||
}
|
||||
@@ -135,20 +135,4 @@ final class ExpressionParsers implements \IteratorAggregate
|
||||
|
||||
return $this->precedenceChanges;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function getOperatorTokensFor(ExpressionParserInterface $parser): array
|
||||
{
|
||||
if (method_exists($parser, 'getOperatorTokens')) {
|
||||
return $parser->getOperatorTokens();
|
||||
}
|
||||
|
||||
trigger_deprecation('twig/twig', '3.24', 'Not implementing the "getOperatorTokens()" method in "%s" is deprecated. This method will be part of the "%s" interface in 4.0.', $parser::class, ExpressionParserInterface::class);
|
||||
|
||||
return [$parser->getName(), ...$parser->getAliases()];
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -536,7 +536,7 @@ class Lexer
|
||||
{
|
||||
$expressionParsers = [];
|
||||
foreach ($this->env->getExpressionParsers() as $expressionParser) {
|
||||
$expressionParsers = array_merge($expressionParsers, ExpressionParsers::getOperatorTokensFor($expressionParser));
|
||||
$expressionParsers = array_merge($expressionParsers, $expressionParser->getOperatorTokens());
|
||||
}
|
||||
|
||||
$expressionParsers = array_combine($expressionParsers, array_map('strlen', $expressionParsers));
|
||||
|
||||
Reference in New Issue
Block a user