From 1f751d132185cb0b00d8cbaac5c0fb16af8ed5c6 Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 31 Oct 2023 09:19:11 +0100 Subject: [PATCH] Fixed condition to avoid a fatal error --- src/Plugin/Filtering/Builder/ExclusionsBuilder.php | 6 +++--- src/Plugin/Filtering/Factory/Reject.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Plugin/Filtering/Builder/ExclusionsBuilder.php b/src/Plugin/Filtering/Builder/ExclusionsBuilder.php index 694de9d9..e7cf1c3b 100644 --- a/src/Plugin/Filtering/Builder/ExclusionsBuilder.php +++ b/src/Plugin/Filtering/Builder/ExclusionsBuilder.php @@ -9,7 +9,7 @@ use PhpParser\Builder; use PhpParser\Node; -final class ExclusionsBuilder extends Builder +final class ExclusionsBuilder implements Builder { /** @var list> */ private array $exclusions = []; @@ -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) { @@ -56,6 +56,6 @@ public function getNode(): array ); } - return $statements; + return new Node; } } diff --git a/src/Plugin/Filtering/Factory/Reject.php b/src/Plugin/Filtering/Factory/Reject.php index d2028684..5d3772e2 100644 --- a/src/Plugin/Filtering/Factory/Reject.php +++ b/src/Plugin/Filtering/Factory/Reject.php @@ -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);