Skip to content

Commit

Permalink
PHPStan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Nov 29, 2024
1 parent 223ddb5 commit 0cb1728
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
12 changes: 0 additions & 12 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,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;
Expand Down
2 changes: 0 additions & 2 deletions src/ExpressionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
use Twig\Node\Expression\Ternary\ConditionalTernary;
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;
Expand Down
2 changes: 2 additions & 0 deletions src/Runtime/LoopIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ public function __construct($seq)
$this->seq = new \ArrayIterator($seq);
} elseif ($seq instanceof \IteratorAggregate) {
do {
/** @var \Iterator<TKey, TValue> $seq */
$seq = $seq->getIterator();
} while ($seq instanceof \IteratorAggregate);
$this->seq = $seq;
} elseif (is_iterable($seq)) {
/** @var \Iterator<TKey, TValue> $seq */
$this->seq = $seq;
} else {
$this->seq = new \EmptyIterator();
Expand Down

0 comments on commit 0cb1728

Please sign in to comment.