@@ -76,12 +76,13 @@ public function callActivity(string $name, array $args = [], ?RetryOptions $retr
7676 $ identity = $ this ->newGuid ();
7777
7878 return $ this ->createFuture (
79- fn () => $ this ->taskController ->fire (
80- AwaitResult::forEvent (
81- StateId::fromInstance ($ this ->id ),
82- WithActivity::forEvent ($ identity , ScheduleTask::forName ($ name , $ args )),
79+ fn ()
80+ => $ this ->taskController ->fire (
81+ AwaitResult::forEvent (
82+ StateId::fromInstance ($ this ->id ),
83+ WithActivity::forEvent ($ identity , ScheduleTask::forName ($ name , $ args )),
84+ ),
8385 ),
84- ),
8586 function (Event $ event , string $ eventIdentity ) use ($ identity ): array {
8687 if (($ event instanceof TaskCompleted || $ event instanceof TaskFailed) &&
8788 $ eventIdentity === $ identity ->toString ()) {
@@ -114,7 +115,7 @@ private function createFuture(
114115 ?string $ identity = null ,
115116 ): DurableFuture {
116117 $ identity ??= $ this ->history ->historicalTaskResults ->getIdentity ();
117- if (! $ this ->history ->historicalTaskResults ->hasSentIdentity ($ identity )) {
118+ if (!$ this ->history ->historicalTaskResults ->hasSentIdentity ($ identity )) {
118119 $ this ->durableLogger ->debug ('Future requested for an unsent identity ' , [$ identity ]);
119120 [$ eventId ] = $ onSent ();
120121 $ deferred = new DeferredFuture ();
@@ -141,7 +142,12 @@ public function callActivityInline(Closure $activity): DurableFuture
141142 return $ this ->createFuture (function () use ($ activity , $ identity ) {
142143 try {
143144 $ result = $ activity ();
144- $ this ->taskController ->fire (WithOrchestration::forInstance (StateId::fromInstance ($ this ->id ), TaskCompleted::forId ($ identity ->toString (), $ result )));
145+ $ this ->taskController ->fire (
146+ WithOrchestration::forInstance (
147+ StateId::fromInstance ($ this ->id ),
148+ TaskCompleted::forId ($ identity ->toString (), $ result ),
149+ ),
150+ );
145151
146152 return [$ identity ];
147153 } catch (Throwable $ exception ) {
@@ -160,7 +166,8 @@ public function callActivityInline(Closure $activity): DurableFuture
160166 return [$ identity ];
161167 }
162168 }, function (Event $ event , string $ eventIdentity ) use ($ identity ): array {
163- if (($ event instanceof TaskCompleted || $ event instanceof TaskFailed) && $ eventIdentity === $ identity ->toString ()) {
169+ if (($ event instanceof TaskCompleted || $ event instanceof TaskFailed) &&
170+ $ eventIdentity === $ identity ->toString ()) {
164171 return [$ event , true ];
165172 }
166173
@@ -189,7 +196,10 @@ public function continueAsNew(array $args = []): never
189196
190197 $ this ->history ->restartAsNew ($ args );
191198 $ this ->taskController ->fire (
192- WithOrchestration::forInstance (StateId::fromInstance ($ this ->id ), StartOrchestration::forInstance ($ this ->id )),
199+ WithOrchestration::forInstance (
200+ StateId::fromInstance ($ this ->id ),
201+ StartOrchestration::forInstance ($ this ->id ),
202+ ),
193203 );
194204 throw new Unwind ();
195205 }
@@ -204,12 +214,13 @@ public function createTimer(DateTimeImmutable|DateInterval $fireAt): DurableFutu
204214 $ identity = sha1 ($ fireAt ->format ('c ' ));
205215
206216 return $ this ->createFuture (
207- fn () => $ this ->taskController ->fire (
208- WithOrchestration::forInstance (
209- StateId::fromInstance ($ this ->id ),
210- WithDelay::forEvent ($ fireAt , RaiseEvent::forTimer ($ identity )),
217+ fn ()
218+ => $ this ->taskController ->fire (
219+ WithOrchestration::forInstance (
220+ StateId::fromInstance ($ this ->id ),
221+ WithDelay::forEvent ($ fireAt , RaiseEvent::forTimer ($ identity )),
222+ ),
211223 ),
212- ),
213224 function (Event $ event ) use ($ identity ): array {
214225 if ($ event instanceof RaiseEvent && $ event ->eventName === $ identity ) {
215226 return [$ event , true ];
@@ -300,13 +311,11 @@ public function createInterval(
300311 ?int $ seconds = null ,
301312 ?int $ microseconds = null ,
302313 ): DateInterval {
303- if (
304- empty (
305- array_filter (
306- compact ('years ' , 'months ' , 'weeks ' , 'days ' , 'hours ' , 'minutes ' , 'seconds ' , 'microseconds ' ),
307- )
314+ if (empty (
315+ array_filter (
316+ compact ('years ' , 'months ' , 'weeks ' , 'days ' , 'hours ' , 'minutes ' , 'seconds ' , 'microseconds ' ),
308317 )
309- ) {
318+ )) {
310319 throw new LogicException ('At least one interval part must be specified ' );
311320 }
312321
@@ -361,7 +370,7 @@ public function isLockedOwned(EntityId $entityId): bool
361370 public function lockEntity (EntityId ...$ entityId ): EntityLock
362371 {
363372 $ this ->durableLogger ->debug ('Locking entities ' , ['entityId ' => $ entityId ]);
364- if (! empty ($ this ->history ->locks ?? []) && ! $ this ->isReplaying ()) {
373+ if (!empty ($ this ->history ->locks ?? []) && !$ this ->isReplaying ()) {
365374 throw new LogicException ('Cannot lock an entity while holding locks ' );
366375 }
367376
@@ -375,12 +384,11 @@ public function lockEntity(EntityId ...$entityId): EntityLock
375384 WithEntity::forInstance (current ($ entityId ), RaiseEvent::forLockNotification ($ owner ->id )),
376385 );
377386 $ identity = $ this ->newGuid ()->toString ();
378- $ future =
379- $ this ->createFuture (
380- fn () => $ this ->taskController ->fire (WithLock::onEntity ($ owner , $ event , ...$ entityId )),
381- fn (Event $ event , string $ eventIdentity ) => [$ event , $ identity === $ eventIdentity ],
382- $ identity ,
383- );
387+ $ future = $ this ->createFuture (
388+ fn () => $ this ->taskController ->fire (WithLock::onEntity ($ owner , $ event , ...$ entityId )),
389+ fn (Event $ event , string $ eventIdentity ) => [$ event , $ identity === $ eventIdentity ],
390+ $ identity ,
391+ );
384392 $ this ->waitOne ($ future );
385393
386394 $ this ->history ->locks = $ entityId ;
@@ -439,17 +447,17 @@ public function waitAll(DurableFuture ...$tasks): array
439447 /**
440448 * @template T
441449 *
442- * @param class-string<T> $className
450+ * @param class-string<T> $className
443451 * @return T
444452 */
445453 public function createEntityProxy (string $ className , ?EntityId $ entityId = null ): object
446454 {
447455 if ($ entityId === null ) {
448- $ entityId = new EntityId ($ className , $ this ->newGuid ());
456+ $ entityId = EntityId ($ className , $ this ->newGuid ());
449457 }
450458
451459 $ class = new ReflectionClass ($ className );
452- if (! $ class ->isInterface ()) {
460+ if (!$ class ->isInterface ()) {
453461 throw new LogicException ('Only interfaces can be proxied ' );
454462 }
455463
@@ -569,7 +577,7 @@ public function entityOp(string|EntityId $id, Closure $operation): mixed
569577 }
570578
571579 $ name = $ type ->getName ();
572- if (! interface_exists ($ name )) {
580+ if (!interface_exists ($ name )) {
573581 throw new LogicException ('Unable to load interface: ' . $ name );
574582 }
575583
@@ -588,7 +596,7 @@ public function entityOp(string|EntityId $id, Closure $operation): mixed
588596 throw new LogicException ('Did not call an operation ' );
589597 }
590598
591- $ entityId = $ id instanceof EntityId ? $ id : new EntityId ($ name , $ id );
599+ $ entityId = $ id instanceof EntityId ? $ id : EntityId ($ name , $ id );
592600
593601 if ($ returns ) {
594602 return $ this ->waitOne ($ this ->callEntity ($ entityId , $ operationName , $ arguments ));
0 commit comments