diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 1121ae1b235..facf2c1361c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -6,20 +6,8 @@ parameters: count: 1 path: src/Extension/CoreExtension.php - - # Avoid BC-break - message: '#^Constructor of class Twig\\Node\\ForNode has an unused parameter \$ifexpr\.$#' - identifier: constructor.unusedParameter - count: 1 - path: src/Node/ForNode.php - - # 2 parameters will be required message: '#^Method Twig\\Node\\IncludeNode\:\:addGetTemplate\(\) invoked with 2 parameters, 1 required\.$#' identifier: arguments.count count: 1 path: src/Node/IncludeNode.php - - - # int|string will be supported in 4.x - message: '#^PHPDoc tag @param for parameter $name with type int|string is not subtype of native type string\.$#' - identifier: parameter.phpDocType - count: 5 - path: src/Node/Node.php diff --git a/src/Environment.php b/src/Environment.php index 9bce904e09f..fa372d28f9d 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -26,6 +26,7 @@ use Twig\Loader\ArrayLoader; use Twig\Loader\ChainLoader; use Twig\Loader\LoaderInterface; +use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\Binary\AbstractBinary; use Twig\Node\Expression\Unary\AbstractUnary; use Twig\Node\ModuleNode; @@ -54,7 +55,7 @@ class Environment private LoaderInterface $loader; private bool $debug; private bool $autoReload; - private CacheInterface|string|false $cache; + private CacheInterface $cache; private ?Lexer $lexer = null; private ?Parser $parser = null; private ?Compiler $compiler = null; @@ -833,7 +834,7 @@ public function resetGlobals(): void /** * @internal * - * @return array}> + * @return array}> */ public function getUnaryOperators(): array { @@ -843,7 +844,7 @@ public function getUnaryOperators(): array /** * @internal * - * @return array, associativity: ExpressionParser::OPERATOR_*}> + * @return array, associativity: ExpressionParser::OPERATOR_*}> */ public function getBinaryOperators(): array { diff --git a/src/ExpressionParser.php b/src/ExpressionParser.php index d5fcbd01a43..8d9a9d9f11a 100644 --- a/src/ExpressionParser.php +++ b/src/ExpressionParser.php @@ -25,9 +25,7 @@ use Twig\Node\Expression\MacroReferenceExpression; use Twig\Node\Expression\TestExpression; use Twig\Node\Expression\Unary\AbstractUnary; -use Twig\Node\Expression\Unary\NegUnary; use Twig\Node\Expression\Unary\NotUnary; -use Twig\Node\Expression\Unary\PosUnary; use Twig\Node\Expression\Unary\SpreadUnary; use Twig\Node\Expression\Variable\AssignContextVariable; use Twig\Node\Expression\Variable\ContextVariable; @@ -51,9 +49,9 @@ class ExpressionParser public const OPERATOR_LEFT = 1; public const OPERATOR_RIGHT = 2; - /** @var array}> */ + /** @var array}> */ private array $unaryOperators; - /** @var array, associativity: self::OPERATOR_*}> */ + /** @var array, associativity: self::OPERATOR_*}> */ private array $binaryOperators; private array $precedenceChanges = []; private bool $deprecationCheck = true; diff --git a/src/ExtensionSet.php b/src/ExtensionSet.php index 0cc57bbc3db..d6d6d675831 100644 --- a/src/ExtensionSet.php +++ b/src/ExtensionSet.php @@ -48,9 +48,13 @@ final class ExtensionSet private array $functions; /** @var array */ private array $dynamicFunctions; - /** @var array}> */ + /** + * @var array}> + */ private array $unaryOperators; - /** @var array, associativity: ExpressionParser::OPERATOR_*}> */ + /** + * @var array, associativity: ExpressionParser::OPERATOR_*}> + */ private array $binaryOperators; /** @var array|null */ private ?array $globals = null; @@ -389,7 +393,7 @@ public function getTest(string $name): ?TwigTest } /** - * @return array}> + * @return array}> */ public function getUnaryOperators(): array { @@ -401,7 +405,7 @@ public function getUnaryOperators(): array } /** - * @return array, associativity: ExpressionParser::OPERATOR_*}> + * @return array, associativity: ExpressionParser::OPERATOR_*}> */ public function getBinaryOperators(): array { diff --git a/src/Runtime/LoopIterator.php b/src/Runtime/LoopIterator.php index af20fcfd756..db9c0ce7174 100644 --- a/src/Runtime/LoopIterator.php +++ b/src/Runtime/LoopIterator.php @@ -45,10 +45,12 @@ public function __construct($seq) $this->seq = new \ArrayIterator($seq); } elseif ($seq instanceof \IteratorAggregate) { do { + /** @var \Iterator $seq */ $seq = $seq->getIterator(); } while ($seq instanceof \IteratorAggregate); $this->seq = $seq; } elseif (is_iterable($seq)) { + /** @var \Iterator $seq */ $this->seq = $seq; } else { $this->seq = new \EmptyIterator();