Skip to content

Commit

Permalink
Fixed condition to avoid a fatal error
Browse files Browse the repository at this point in the history
  • Loading branch information
sebprt committed Jun 25, 2024
1 parent cdd5e47 commit 354388c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Plugin/Filtering/Builder/ExclusionsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PhpParser\Builder;
use PhpParser\Node;

final class ExclusionsBuilder extends Builder
final class ExclusionsBuilder implements Builder
{
/** @var list<list<Node\Expr>> */
private array $exclusions = [];
Expand All @@ -24,7 +24,7 @@ public function withCondition(Node\Expr $condition, ?Node\Expr $reason = null):s
return $this;
}

public function getNode(): array
public function getNode(): Node
{
$statements = [];
foreach ($this->exclusions as $exclusion) {
Expand Down Expand Up @@ -56,6 +56,6 @@ public function getNode(): array
);
}

return $statements;
return new Node;

Check failure on line 59 in src/Plugin/Filtering/Builder/ExclusionsBuilder.php

View workflow job for this annotation

GitHub Actions / phpstan

Cannot instantiate interface PhpParser\Node.
}
}
2 changes: 1 addition & 1 deletion src/Plugin/Filtering/Factory/Reject.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function compile(array $config): Filtering\Factory\Repository\Reject
$exclusionBuilder
->withCondition(
compileExpression($interpreter, $condition['when']),
compileValueWhenExpression($interpreter, $condition['reason']) ?: null,
\array_key_exists('reason', $condition) ? compileValueWhenExpression($interpreter, $condition['reason']) : null,
);
}
$builder->withExclusions($exclusionBuilder);
Expand Down

0 comments on commit 354388c

Please sign in to comment.