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 Oct 31, 2023
1 parent b06361e commit 1f751d1
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): 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 1f751d1

Please sign in to comment.