Skip to content

Commit

Permalink
Merge branch '3.x' into 4.x
Browse files Browse the repository at this point in the history
* 3.x:
  Update phpdoc for operators
  • Loading branch information
fabpot committed Nov 29, 2024
2 parents 5ad1aca + 3eed037 commit 223ddb5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ public function resetGlobals(): void
/**
* @internal
*
* @return array<string, array{precedence: int, class: class-string<AbstractUnary>}>
* @return array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class: class-string<AbstractUnary>}>
*/
public function getUnaryOperators(): array
{
Expand All @@ -843,7 +843,7 @@ public function getUnaryOperators(): array
/**
* @internal
*
* @return array<string, array{precedence: int, class: class-string<AbstractBinary>, associativity: ExpressionParser::OPERATOR_*}>
* @return array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class: class-string<AbstractBinary>, associativity: ExpressionParser::OPERATOR_*}>
*/
public function getBinaryOperators(): array
{
Expand Down
7 changes: 4 additions & 3 deletions src/Extension/ExtensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
namespace Twig\Extension;

use Twig\ExpressionParser;
use Twig\Node\Expression\AbstractExpression;
use Twig\Node\Expression\Binary\AbstractBinary;
use Twig\Node\Expression\Unary\AbstractUnary;
use Twig\NodeVisitor\NodeVisitorInterface;
use Twig\OperatorPrecedenceChange;
use Twig\TokenParser\TokenParserInterface;
Expand Down Expand Up @@ -68,8 +69,8 @@ public function getFunctions(): array;
* @return array<array> First array of unary operators, second array of binary operators
*
* @psalm-return array{
* array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class: class-string<AbstractExpression>}>,
* array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class?: class-string<AbstractExpression>, associativity: ExpressionParser::OPERATOR_*}>
* array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class: class-string<AbstractUnary>}>,
* array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class?: class-string<AbstractBinary>, associativity: ExpressionParser::OPERATOR_*}>
* }
*/
public function getOperators(): array;
Expand Down
11 changes: 6 additions & 5 deletions src/ExtensionSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
use Twig\Extension\ExtensionInterface;
use Twig\Extension\GlobalsInterface;
use Twig\Extension\StagingExtension;
use Twig\Node\Expression\AbstractExpression;
use Twig\Node\Expression\Binary\AbstractBinary;
use Twig\Node\Expression\Unary\AbstractUnary;
use Twig\NodeVisitor\NodeVisitorInterface;
use Twig\TokenParser\TokenParserInterface;

Expand Down Expand Up @@ -48,9 +49,9 @@ final class ExtensionSet
private array $functions;
/** @var array<string, TwigFunction> */
private array $dynamicFunctions;
/** @var array<string, array{precedence: int, class: class-string<AbstractExpression>}> */
/** @var array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class: class-string<AbstractUnary>}> */
private array $unaryOperators;
/** @var array<string, array{precedence: int, class?: class-string<AbstractExpression>, associativity: ExpressionParser::OPERATOR_*}> */
/** @var array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class?: class-string<AbstractBinary>, associativity: ExpressionParser::OPERATOR_*}> */
private array $binaryOperators;
/** @var array<string, mixed>|null */
private ?array $globals = null;
Expand Down Expand Up @@ -389,7 +390,7 @@ public function getTest(string $name): ?TwigTest
}

/**
* @return array<string, array{precedence: int, class: class-string<AbstractExpression>}>
* @return array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class: class-string<AbstractUnary>}>
*/
public function getUnaryOperators(): array
{
Expand All @@ -401,7 +402,7 @@ public function getUnaryOperators(): array
}

/**
* @return array<string, array{precedence: int, class?: class-string<AbstractExpression>, associativity: ExpressionParser::OPERATOR_*}>
* @return array<string, array{precedence: int, precedence_change?: OperatorPrecedenceChange, class?: class-string<AbstractBinary>, associativity: ExpressionParser::OPERATOR_*}>
*/
public function getBinaryOperators(): array
{
Expand Down

0 comments on commit 223ddb5

Please sign in to comment.