From 354388cb413a5df74ec446833ce6848a98f894a4 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 fef62f8c..91391d6c 100644 --- a/src/Plugin/Filtering/Factory/Reject.php +++ b/src/Plugin/Filtering/Factory/Reject.php @@ -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);