From 21952742f50cf0ba305709f0e997b30e27d88ea2 Mon Sep 17 00:00:00 2001 From: Rob Landers Date: Sat, 26 Jul 2025 23:14:27 +0200 Subject: [PATCH] Fix undefined variables in entity delay --- src/EntityContext.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/EntityContext.php b/src/EntityContext.php index 49991dd2..91e54a6c 100644 --- a/src/EntityContext.php +++ b/src/EntityContext.php @@ -154,14 +154,21 @@ public function delay(Closure $self, DateTimeInterface $until = new DateTimeImmu throw new Exception('Cannot delay a function with parameters'); } - // create the spy proxy + // create the spy proxy and capture the invoked operation $spy = $this->spyProxy->define($interfaces[0]); + $operationName = null; + $arguments = null; $class = new $spy($operationName, $arguments); - $self->bindTo($class); + $self = $self->bindTo($class, $class); try { $self(); } catch (Throwable) { + // the spy always throws when an operation is invoked + } + + if ($operationName === null || $arguments === null) { + throw new Exception('Did not call an operation'); } $this->delayUntil($operationName, $arguments, $until);