From 01b1669b9ce8fafe14b93d2e6bb296899d0f7118 Mon Sep 17 00:00:00 2001 From: Yunus Emre Nalbant Date: Wed, 13 Dec 2023 13:38:13 +0300 Subject: [PATCH 1/3] WEB-4311: Remove guard start internal event tracking. In this commit, the code for tracking the start of a guard event has been removed. It was assessed as unneeded, simplifying logging and event handling within the TransitionDefinition class. --- src/Definition/TransitionDefinition.php | 7 ------- src/Enums/InternalEvent.php | 2 -- 2 files changed, 9 deletions(-) diff --git a/src/Definition/TransitionDefinition.php b/src/Definition/TransitionDefinition.php index 57817db..3de8d27 100644 --- a/src/Definition/TransitionDefinition.php +++ b/src/Definition/TransitionDefinition.php @@ -158,13 +158,6 @@ public function getFirstValidTransitionBranch( $shouldLog = $guardBehavior?->shouldLog ?? false; - // Record the internal guard init event. - $state->setInternalEventBehavior( - type: InternalEvent::GUARD_START, - placeholder: $guardDefinition, - shouldLog: $shouldLog, - ); - if ($guardBehavior instanceof GuardBehavior) { $guardBehavior->validateRequiredContext($state->context); } diff --git a/src/Enums/InternalEvent.php b/src/Enums/InternalEvent.php index b094f37..f1a2324 100644 --- a/src/Enums/InternalEvent.php +++ b/src/Enums/InternalEvent.php @@ -29,8 +29,6 @@ enum InternalEvent: string case ACTION_START = '{machine}.action.{placeholder}.start'; case ACTION_FINISH = '{machine}.action.{placeholder}.finish'; - - case GUARD_START = '{machine}.guard.{placeholder}.start'; case GUARD_PASS = '{machine}.guard.{placeholder}.pass'; case GUARD_FAIL = '{machine}.guard.{placeholder}.fail'; From 030cd01ecd80d6ce37e4e93c51eafed6822e9a20 Mon Sep 17 00:00:00 2001 From: Yunus Emre Nalbant Date: Wed, 13 Dec 2023 13:38:41 +0300 Subject: [PATCH 2/3] WEB-4311: Remove unneeded guard start event logging in tests. This commit removes the logging of the start of guard events in various test classes. This change is meant to simplify event handling and reduce clutter in log files by only keeping necessary log entries. --- tests/EventStoreTest.php | 1 - tests/HistoryValidationTest.php | 3 --- tests/StateTest.php | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/EventStoreTest.php b/tests/EventStoreTest.php index d916fc8..f078426 100644 --- a/tests/EventStoreTest.php +++ b/tests/EventStoreTest.php @@ -155,7 +155,6 @@ 'in.state.active.entry.finish', 'MUT', 'in.transition.active.MUT.start', - 'in.guard.isEvenGuard.start', 'in.guard.isEvenGuard.fail', 'in.transition.active.MUT.fail', ]); diff --git a/tests/HistoryValidationTest.php b/tests/HistoryValidationTest.php index 92767a5..5197977 100644 --- a/tests/HistoryValidationTest.php +++ b/tests/HistoryValidationTest.php @@ -37,7 +37,6 @@ 'machine.state.green.entry.finish', 'TIMER', 'machine.transition.green.TIMER.start', - 'machine.guard.IsTimerValidValidationGuard.start', 'machine.guard.IsTimerValidValidationGuard.fail', 'machine.transition.green.TIMER.fail', ]); @@ -56,12 +55,10 @@ 'machine.state.green.entry.finish', 'TIMER', 'machine.transition.green.TIMER.start', - 'machine.guard.IsTimerValidValidationGuard.start', 'machine.guard.IsTimerValidValidationGuard.fail', 'machine.transition.green.TIMER.fail', 'TIMER', 'machine.transition.green.TIMER.start', - 'machine.guard.IsTimerValidValidationGuard.start', 'machine.guard.IsTimerValidValidationGuard.pass', 'machine.transition.green.TIMER.finish', 'machine.state.green.exit.start', diff --git a/tests/StateTest.php b/tests/StateTest.php index 02afc51..0e7dea6 100644 --- a/tests/StateTest.php +++ b/tests/StateTest.php @@ -38,7 +38,7 @@ test('Logs if log writing is turned on', function (): void { $machine = TrafficLightsMachine::create(); - Log::shouldReceive('debug')->times(4); + Log::shouldReceive('debug')->times(3); $machine->send(event: ['type' => 'MUT']); }); From c06092fbef1d89772de37e11e71e53233c527e5a Mon Sep 17 00:00:00 2001 From: YunusEmreNalbant Date: Wed, 13 Dec 2023 10:39:06 +0000 Subject: [PATCH 3/3] chore: Fix styling --- src/Actor/Machine.php | 6 ++--- src/Actor/State.php | 4 ++-- src/Behavior/ActionBehavior.php | 2 +- src/Behavior/EventBehavior.php | 2 +- src/Behavior/GuardBehavior.php | 2 +- src/Behavior/InvokableBehavior.php | 2 +- src/Behavior/ResultBehavior.php | 2 +- src/Behavior/ValidationGuardBehavior.php | 2 +- src/ContextManager.php | 2 +- src/Definition/MachineDefinition.php | 22 +++++++++---------- src/Definition/StateDefinition.php | 4 ++-- src/Definition/TransitionBranch.php | 2 +- src/Enums/InternalEvent.php | 6 ++--- tests/ActionTest.php | 2 +- tests/InvokableBehaviorArgumentsTest.php | 6 ++--- tests/Stubs/Actions/IsOddAction.php | 2 +- tests/Stubs/Guards/IsOddGuard.php | 2 +- .../Guards/IsTimerValidValidationGuard.php | 2 +- tests/Stubs/Guards/IsValidatedOddGuard.php | 2 +- tests/Stubs/Machines/Asd/Actions/AAction.php | 2 +- tests/Stubs/Machines/Asd/Actions/DAction.php | 2 +- tests/Stubs/Machines/Asd/Actions/SAction.php | 2 +- .../Machines/Asd/Actions/SleepAction.php | 2 +- .../Stubs/Machines/Qwerty/Actions/TAction.php | 2 +- .../Actions/AddAnotherValueAction.php | 2 +- .../TrafficLights/Actions/AddValueAction.php | 2 +- .../TrafficLights/Actions/DecrementAction.php | 2 +- .../Actions/DoNothingInsideClassAction.php | 2 +- .../TrafficLights/Actions/IncrementAction.php | 2 +- .../Actions/MultiplyByTwoAction.php | 2 +- .../Actions/SubtractValueAction.php | 2 +- .../TrafficLights/Guards/IsEvenGuard.php | 2 +- tests/Stubs/Machines/Xyz/Actions/XAction.php | 2 +- tests/Stubs/Machines/Xyz/Actions/YAction.php | 2 +- tests/Stubs/Machines/Xyz/Actions/ZAction.php | 2 +- tests/Stubs/Results/GreenResult.php | 2 +- 36 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/Actor/Machine.php b/src/Actor/Machine.php index 0055cf9..51d331e 100644 --- a/src/Actor/Machine.php +++ b/src/Actor/Machine.php @@ -107,8 +107,8 @@ public static function definition(): ?MachineDefinition * @return self The newly created and initialized machine instance. */ public static function create( - MachineDefinition|array $definition = null, - State|string $state = null, + MachineDefinition|array|null $definition = null, + State|string|null $state = null, ): self { if (is_array($definition)) { $definition = MachineDefinition::define( @@ -135,7 +135,7 @@ public static function create( * * @return self The started machine instance. */ - public function start(State|string $state = null): self + public function start(State|string|null $state = null): self { $this->state = match (true) { $state === null => $this->definition->getInitialState(), diff --git a/src/Actor/State.php b/src/Actor/State.php index a92165c..11498ac 100644 --- a/src/Actor/State.php +++ b/src/Actor/State.php @@ -82,8 +82,8 @@ public function setCurrentStateDefinition(StateDefinition $stateDefinition): sel */ public function setInternalEventBehavior( InternalEvent $type, - string $placeholder = null, - array $payload = null, + ?string $placeholder = null, + ?array $payload = null, bool $shouldLog = false, ): self { $eventDefinition = new EventDefinition( diff --git a/src/Behavior/ActionBehavior.php b/src/Behavior/ActionBehavior.php index d47a429..da139fa 100644 --- a/src/Behavior/ActionBehavior.php +++ b/src/Behavior/ActionBehavior.php @@ -24,6 +24,6 @@ abstract class ActionBehavior extends InvokableBehavior abstract public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null, + ?array $arguments = null, ): void; } diff --git a/src/Behavior/EventBehavior.php b/src/Behavior/EventBehavior.php index 6412c3d..dae3858 100644 --- a/src/Behavior/EventBehavior.php +++ b/src/Behavior/EventBehavior.php @@ -39,7 +39,7 @@ public function __construct( public null|string|Optional $type = null, public null|array|Optional $payload = null, #[WithoutValidation] - bool $isTransactional = null, + ?bool $isTransactional = null, #[WithoutValidation] mixed $actor = null, public int|Optional $version = 1, diff --git a/src/Behavior/GuardBehavior.php b/src/Behavior/GuardBehavior.php index f3f6024..b6515a0 100644 --- a/src/Behavior/GuardBehavior.php +++ b/src/Behavior/GuardBehavior.php @@ -26,6 +26,6 @@ abstract class GuardBehavior extends InvokableBehavior abstract public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null, + ?array $arguments = null, ): bool; } diff --git a/src/Behavior/InvokableBehavior.php b/src/Behavior/InvokableBehavior.php index 3513fa8..915f478 100644 --- a/src/Behavior/InvokableBehavior.php +++ b/src/Behavior/InvokableBehavior.php @@ -54,7 +54,7 @@ public function __construct( abstract public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null, + ?array $arguments = null, ); /** diff --git a/src/Behavior/ResultBehavior.php b/src/Behavior/ResultBehavior.php index c80a68f..0886773 100644 --- a/src/Behavior/ResultBehavior.php +++ b/src/Behavior/ResultBehavior.php @@ -11,6 +11,6 @@ abstract class ResultBehavior extends InvokableBehavior abstract public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null, + ?array $arguments = null, ): mixed; } diff --git a/src/Behavior/ValidationGuardBehavior.php b/src/Behavior/ValidationGuardBehavior.php index 439c2bd..ad2046c 100644 --- a/src/Behavior/ValidationGuardBehavior.php +++ b/src/Behavior/ValidationGuardBehavior.php @@ -31,6 +31,6 @@ abstract class ValidationGuardBehavior extends GuardBehavior abstract public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null, + ?array $arguments = null, ): bool; } diff --git a/src/ContextManager.php b/src/ContextManager.php index bd51e95..fd9122a 100644 --- a/src/ContextManager.php +++ b/src/ContextManager.php @@ -87,7 +87,7 @@ public function set(string $key, mixed $value): mixed * @return bool True if the key exists and (if a type is specified) * its value is of the given type. False otherwise. */ - public function has(string $key, string $type = null): bool + public function has(string $key, ?string $type = null): bool { $hasKey = match (true) { get_class($this) === self::class => Arr::has($this->data, $key), diff --git a/src/Definition/MachineDefinition.php b/src/Definition/MachineDefinition.php index 3d0924c..e0586ff 100644 --- a/src/Definition/MachineDefinition.php +++ b/src/Definition/MachineDefinition.php @@ -117,9 +117,9 @@ private function __construct( * @return self The created machine definition. */ public static function define( - array $config = null, - array $behavior = null, - array $scenarios = null, + ?array $config = null, + ?array $behavior = null, + ?array $scenarios = null, ): self { return new self( config: $config ?? null, @@ -203,7 +203,7 @@ protected function createScenarioStateDefinitions(): void * * @return ?State The initial state of the machine. */ - public function getInitialState(EventBehavior|array $event = null): ?State + public function getInitialState(EventBehavior|array|null $event = null): ?State { if (is_null($this->initialStateDefinition)) { return null; @@ -275,7 +275,7 @@ public function getInitialState(EventBehavior|array $event = null): ?State * * @return State|null The scenario state if scenario is enabled and found, otherwise returns the current state. */ - public function getScenarioStateIfAvailable(State $state, EventBehavior|array $eventBehavior = null): ?State + public function getScenarioStateIfAvailable(State $state, EventBehavior|array|null $eventBehavior = null): ?State { if ($this->scenariosEnabled === false) { return $state; @@ -310,8 +310,8 @@ public function getScenarioStateIfAvailable(State $state, EventBehavior|array $e */ protected function buildCurrentState( ContextManager $context, - StateDefinition $currentStateDefinition = null, - EventBehavior $eventBehavior = null, + ?StateDefinition $currentStateDefinition = null, + ?EventBehavior $eventBehavior = null, ): State { return new State( context: $context, @@ -348,7 +348,7 @@ protected function getCurrentStateDefinition(string|State|null $state): mixed * * @return ContextManager The initialized context manager */ - public function initializeContextFromState(State $state = null): ContextManager + public function initializeContextFromState(?State $state = null): ContextManager { // If a state is provided, use it's context if (!is_null($state)) { @@ -513,7 +513,7 @@ public function checkFinalStatesForTransitions(): void protected function findTransitionDefinition( StateDefinition $currentStateDefinition, EventBehavior $eventBehavior, - string $firstStateDefinitionId = null, + ?string $firstStateDefinitionId = null, ): ?TransitionDefinition { $transitionDefinition = $currentStateDefinition->transitionDefinitions[$eventBehavior->type] ?? null; @@ -552,7 +552,7 @@ protected function findTransitionDefinition( */ public function transition( EventBehavior|array $event, - State $state = null + ?State $state = null ): State { if ($state !== null) { $state = $this->getScenarioStateIfAvailable(state: $state, eventBehavior: $event); @@ -688,7 +688,7 @@ public function transition( public function runAction( string $actionDefinition, State $state, - EventBehavior $eventBehavior = null + ?EventBehavior $eventBehavior = null ): void { [$actionDefinition, $actionArguments] = array_pad(explode(':', $actionDefinition, 2), 2, null); $actionArguments = $actionArguments === null ? [] : explode(',', $actionArguments); diff --git a/src/Definition/StateDefinition.php b/src/Definition/StateDefinition.php index ebbee98..2cf56c0 100644 --- a/src/Definition/StateDefinition.php +++ b/src/Definition/StateDefinition.php @@ -104,7 +104,7 @@ class StateDefinition */ public function __construct( public ?array $config, - array $options = null, + ?array $options = null, ) { $this->initializeOptions($options); @@ -457,7 +457,7 @@ public function runExitActions(State $state): void * * @param \Tarfinlabs\EventMachine\Behavior\EventBehavior|null $eventBehavior The event to be processed. */ - public function runEntryActions(State $state, EventBehavior $eventBehavior = null): void + public function runEntryActions(State $state, ?EventBehavior $eventBehavior = null): void { // Record state entry start event $state->setInternalEventBehavior( diff --git a/src/Definition/TransitionBranch.php b/src/Definition/TransitionBranch.php index 4710e0c..835197b 100644 --- a/src/Definition/TransitionBranch.php +++ b/src/Definition/TransitionBranch.php @@ -169,7 +169,7 @@ protected function initializeInlineBehaviors(array $inlineBehaviors, BehaviorTyp */ public function runActions( State $state, - EventBehavior $eventBehavior = null + ?EventBehavior $eventBehavior = null ): void { if ($this->actions === null) { return; diff --git a/src/Enums/InternalEvent.php b/src/Enums/InternalEvent.php index f1a2324..ac29a9b 100644 --- a/src/Enums/InternalEvent.php +++ b/src/Enums/InternalEvent.php @@ -29,8 +29,8 @@ enum InternalEvent: string case ACTION_START = '{machine}.action.{placeholder}.start'; case ACTION_FINISH = '{machine}.action.{placeholder}.finish'; - case GUARD_PASS = '{machine}.guard.{placeholder}.pass'; - case GUARD_FAIL = '{machine}.guard.{placeholder}.fail'; + case GUARD_PASS = '{machine}.guard.{placeholder}.pass'; + case GUARD_FAIL = '{machine}.guard.{placeholder}.fail'; case EVENT_RAISED = '{machine}.event.{placeholder}.raised'; @@ -42,7 +42,7 @@ enum InternalEvent: string * * @return string The generated internal event name. */ - public function generateInternalEventName(string $machineId, string $placeholder = null): string + public function generateInternalEventName(string $machineId, ?string $placeholder = null): string { if ($placeholder !== null && class_exists($placeholder)) { $placeholder = Str::of($placeholder)->classBasename()->toString(); diff --git a/tests/ActionTest.php b/tests/ActionTest.php index e642de6..be137d4 100644 --- a/tests/ActionTest.php +++ b/tests/ActionTest.php @@ -95,7 +95,7 @@ public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): int { return $eventBehavior->payload['value'] * $eventBehavior->payload['value']; } diff --git a/tests/InvokableBehaviorArgumentsTest.php b/tests/InvokableBehaviorArgumentsTest.php index 4e46df4..963dfad 100644 --- a/tests/InvokableBehaviorArgumentsTest.php +++ b/tests/InvokableBehaviorArgumentsTest.php @@ -25,7 +25,7 @@ ], behavior: [ 'actions' => [ - 'additionAction' => function (ContextManager $context, EventDefinition $eventDefinition, array $arguments = null): void { + 'additionAction' => function (ContextManager $context, EventDefinition $eventDefinition, ?array $arguments = null): void { $context->count += array_sum($arguments); }, ], @@ -57,12 +57,12 @@ ], behavior: [ 'actions' => [ - 'additionAction' => function (ContextManager $context, EventDefinition $eventDefinition, array $arguments = null): void { + 'additionAction' => function (ContextManager $context, EventDefinition $eventDefinition, ?array $arguments = null): void { $context->count += array_sum($arguments); }, ], 'guards' => [ - 'biggerThan' => function (ContextManager $context, EventDefinition $eventDefinition, array $arguments = null): bool { + 'biggerThan' => function (ContextManager $context, EventDefinition $eventDefinition, ?array $arguments = null): bool { return $context->count > $arguments[0]; }, ], diff --git a/tests/Stubs/Actions/IsOddAction.php b/tests/Stubs/Actions/IsOddAction.php index 1c9041a..c02bc80 100644 --- a/tests/Stubs/Actions/IsOddAction.php +++ b/tests/Stubs/Actions/IsOddAction.php @@ -14,7 +14,7 @@ class IsOddAction extends ActionBehavior 'counts.oddCount' => 'integer', ]; - public function __invoke(ContextManager $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager $context, EventBehavior $eventBehavior, ?array $arguments = null): void { $context->set('counts.oddCount', 1); } diff --git a/tests/Stubs/Guards/IsOddGuard.php b/tests/Stubs/Guards/IsOddGuard.php index 1f04979..ab65705 100644 --- a/tests/Stubs/Guards/IsOddGuard.php +++ b/tests/Stubs/Guards/IsOddGuard.php @@ -18,7 +18,7 @@ class IsOddGuard extends GuardBehavior public function __invoke( TrafficLightsContext|ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): bool { return $context->count % 2 === 1; } diff --git a/tests/Stubs/Guards/IsTimerValidValidationGuard.php b/tests/Stubs/Guards/IsTimerValidValidationGuard.php index f6195c6..f392cc1 100644 --- a/tests/Stubs/Guards/IsTimerValidValidationGuard.php +++ b/tests/Stubs/Guards/IsTimerValidValidationGuard.php @@ -13,7 +13,7 @@ class IsTimerValidValidationGuard extends ValidationGuardBehavior public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): bool { $value = $eventBehavior->payload['value']; $result = $value > (int) $arguments[0]; diff --git a/tests/Stubs/Guards/IsValidatedOddGuard.php b/tests/Stubs/Guards/IsValidatedOddGuard.php index 69df16b..837a49d 100644 --- a/tests/Stubs/Guards/IsValidatedOddGuard.php +++ b/tests/Stubs/Guards/IsValidatedOddGuard.php @@ -19,7 +19,7 @@ class IsValidatedOddGuard extends ValidationGuardBehavior public function __invoke( TrafficLightsContext|ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): bool { return $context->count % 2 === 1; } diff --git a/tests/Stubs/Machines/Asd/Actions/AAction.php b/tests/Stubs/Machines/Asd/Actions/AAction.php index 1515e78..ae8f56d 100644 --- a/tests/Stubs/Machines/Asd/Actions/AAction.php +++ b/tests/Stubs/Machines/Asd/Actions/AAction.php @@ -11,7 +11,7 @@ class AAction extends ActionBehavior { - public function __invoke(ContextManager $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager $context, EventBehavior $eventBehavior, ?array $arguments = null): void { ModelA::create([ 'value' => 'lorem ipsum dolor', diff --git a/tests/Stubs/Machines/Asd/Actions/DAction.php b/tests/Stubs/Machines/Asd/Actions/DAction.php index 9b12bd3..c85e94d 100644 --- a/tests/Stubs/Machines/Asd/Actions/DAction.php +++ b/tests/Stubs/Machines/Asd/Actions/DAction.php @@ -13,7 +13,7 @@ class DAction extends ActionBehavior /** * @throws \Exception */ - public function __invoke(ContextManager $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager $context, EventBehavior $eventBehavior, ?array $arguments = null): void { throw new \Exception('error'); } diff --git a/tests/Stubs/Machines/Asd/Actions/SAction.php b/tests/Stubs/Machines/Asd/Actions/SAction.php index 79421dc..434c9cb 100644 --- a/tests/Stubs/Machines/Asd/Actions/SAction.php +++ b/tests/Stubs/Machines/Asd/Actions/SAction.php @@ -14,7 +14,7 @@ class SAction extends ActionBehavior /** * @throws \Exception */ - public function __invoke(ContextManager $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager $context, EventBehavior $eventBehavior, ?array $arguments = null): void { ModelA::first()->update([ 'value' => 'new value', diff --git a/tests/Stubs/Machines/Asd/Actions/SleepAction.php b/tests/Stubs/Machines/Asd/Actions/SleepAction.php index 0cfaf38..8ac96b3 100644 --- a/tests/Stubs/Machines/Asd/Actions/SleepAction.php +++ b/tests/Stubs/Machines/Asd/Actions/SleepAction.php @@ -13,7 +13,7 @@ class SleepAction extends ActionBehavior /** * @throws \Exception */ - public function __invoke(ContextManager $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager $context, EventBehavior $eventBehavior, ?array $arguments = null): void { sleep(1); } diff --git a/tests/Stubs/Machines/Qwerty/Actions/TAction.php b/tests/Stubs/Machines/Qwerty/Actions/TAction.php index 48456d9..9bc93f2 100644 --- a/tests/Stubs/Machines/Qwerty/Actions/TAction.php +++ b/tests/Stubs/Machines/Qwerty/Actions/TAction.php @@ -11,7 +11,7 @@ class TAction extends ActionBehavior { - public function __invoke(ContextManager $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager $context, EventBehavior $eventBehavior, ?array $arguments = null): void { $this->raise(new TEvent(actor: $eventBehavior->actor($context))); } diff --git a/tests/Stubs/Machines/TrafficLights/Actions/AddAnotherValueAction.php b/tests/Stubs/Machines/TrafficLights/Actions/AddAnotherValueAction.php index 0b39508..3e90db6 100644 --- a/tests/Stubs/Machines/TrafficLights/Actions/AddAnotherValueAction.php +++ b/tests/Stubs/Machines/TrafficLights/Actions/AddAnotherValueAction.php @@ -12,7 +12,7 @@ class AddAnotherValueAction extends ActionBehavior { - public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior|AddAnotherValueEvent $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior|AddAnotherValueEvent $eventBehavior, ?array $arguments = null): void { $context->count += $eventBehavior->value; } diff --git a/tests/Stubs/Machines/TrafficLights/Actions/AddValueAction.php b/tests/Stubs/Machines/TrafficLights/Actions/AddValueAction.php index 386c27a..58adbb0 100644 --- a/tests/Stubs/Machines/TrafficLights/Actions/AddValueAction.php +++ b/tests/Stubs/Machines/TrafficLights/Actions/AddValueAction.php @@ -11,7 +11,7 @@ class AddValueAction extends ActionBehavior { - public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, ?array $arguments = null): void { /* @var \Tarfinlabs\EventMachine\Tests\Stubs\Machines\TrafficLights\TrafficLightsContext $context */ $context->count += $eventBehavior->payload['value']; diff --git a/tests/Stubs/Machines/TrafficLights/Actions/DecrementAction.php b/tests/Stubs/Machines/TrafficLights/Actions/DecrementAction.php index 6ee6407..a7cd9fb 100644 --- a/tests/Stubs/Machines/TrafficLights/Actions/DecrementAction.php +++ b/tests/Stubs/Machines/TrafficLights/Actions/DecrementAction.php @@ -14,7 +14,7 @@ class DecrementAction extends ActionBehavior public function __invoke( ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): void { /* @var \Tarfinlabs\EventMachine\Tests\Stubs\Machines\TrafficLights\TrafficLightsContext $context */ $context->count--; diff --git a/tests/Stubs/Machines/TrafficLights/Actions/DoNothingInsideClassAction.php b/tests/Stubs/Machines/TrafficLights/Actions/DoNothingInsideClassAction.php index c2066d5..f0f0a1d 100644 --- a/tests/Stubs/Machines/TrafficLights/Actions/DoNothingInsideClassAction.php +++ b/tests/Stubs/Machines/TrafficLights/Actions/DoNothingInsideClassAction.php @@ -10,7 +10,7 @@ class DoNothingInsideClassAction extends ActionBehavior { - public function __invoke(ContextManager $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager $context, EventBehavior $eventBehavior, ?array $arguments = null): void { // Do nothing. } diff --git a/tests/Stubs/Machines/TrafficLights/Actions/IncrementAction.php b/tests/Stubs/Machines/TrafficLights/Actions/IncrementAction.php index 6f69df3..4b245bb 100644 --- a/tests/Stubs/Machines/TrafficLights/Actions/IncrementAction.php +++ b/tests/Stubs/Machines/TrafficLights/Actions/IncrementAction.php @@ -11,7 +11,7 @@ class IncrementAction extends ActionBehavior { - public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, ?array $arguments = null): void { /* @var \Tarfinlabs\EventMachine\Tests\Stubs\Machines\TrafficLights\TrafficLightsContext $context */ $context->count++; diff --git a/tests/Stubs/Machines/TrafficLights/Actions/MultiplyByTwoAction.php b/tests/Stubs/Machines/TrafficLights/Actions/MultiplyByTwoAction.php index 1367e67..4c57768 100644 --- a/tests/Stubs/Machines/TrafficLights/Actions/MultiplyByTwoAction.php +++ b/tests/Stubs/Machines/TrafficLights/Actions/MultiplyByTwoAction.php @@ -13,7 +13,7 @@ class MultiplyByTwoAction extends ActionBehavior { public bool $shouldLog = true; - public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, ?array $arguments = null): void { /* @var \Tarfinlabs\EventMachine\Tests\Stubs\Machines\TrafficLights\TrafficLightsContext $context */ $context->count *= 2; diff --git a/tests/Stubs/Machines/TrafficLights/Actions/SubtractValueAction.php b/tests/Stubs/Machines/TrafficLights/Actions/SubtractValueAction.php index 8139c9e..1d6bf97 100644 --- a/tests/Stubs/Machines/TrafficLights/Actions/SubtractValueAction.php +++ b/tests/Stubs/Machines/TrafficLights/Actions/SubtractValueAction.php @@ -11,7 +11,7 @@ class SubtractValueAction extends ActionBehavior { - public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, array $arguments = null): void + public function __invoke(ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, ?array $arguments = null): void { /* @var \Tarfinlabs\EventMachine\Tests\Stubs\Machines\TrafficLights\TrafficLightsContext $context */ $context->count -= $eventBehavior->payload['value']; diff --git a/tests/Stubs/Machines/TrafficLights/Guards/IsEvenGuard.php b/tests/Stubs/Machines/TrafficLights/Guards/IsEvenGuard.php index aa2acc0..bb20cb7 100644 --- a/tests/Stubs/Machines/TrafficLights/Guards/IsEvenGuard.php +++ b/tests/Stubs/Machines/TrafficLights/Guards/IsEvenGuard.php @@ -17,7 +17,7 @@ class IsEvenGuard extends ValidationGuardBehavior public function __invoke( ContextManager|TrafficLightsContext $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): bool { return $context->count % 2 === 0; } diff --git a/tests/Stubs/Machines/Xyz/Actions/XAction.php b/tests/Stubs/Machines/Xyz/Actions/XAction.php index 09e53e3..ee36037 100644 --- a/tests/Stubs/Machines/Xyz/Actions/XAction.php +++ b/tests/Stubs/Machines/Xyz/Actions/XAction.php @@ -13,7 +13,7 @@ class XAction extends ActionBehavior public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): void { $context->value .= 'x'; diff --git a/tests/Stubs/Machines/Xyz/Actions/YAction.php b/tests/Stubs/Machines/Xyz/Actions/YAction.php index 3b172bd..6887f84 100644 --- a/tests/Stubs/Machines/Xyz/Actions/YAction.php +++ b/tests/Stubs/Machines/Xyz/Actions/YAction.php @@ -14,7 +14,7 @@ class YAction extends ActionBehavior public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): void { $context->value .= 'y'; diff --git a/tests/Stubs/Machines/Xyz/Actions/ZAction.php b/tests/Stubs/Machines/Xyz/Actions/ZAction.php index 698f0e2..09cb7d7 100644 --- a/tests/Stubs/Machines/Xyz/Actions/ZAction.php +++ b/tests/Stubs/Machines/Xyz/Actions/ZAction.php @@ -13,7 +13,7 @@ class ZAction extends ActionBehavior public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): void { $context->value .= 'z'; diff --git a/tests/Stubs/Results/GreenResult.php b/tests/Stubs/Results/GreenResult.php index 40d67ce..c2b7262 100644 --- a/tests/Stubs/Results/GreenResult.php +++ b/tests/Stubs/Results/GreenResult.php @@ -14,7 +14,7 @@ class GreenResult extends ResultBehavior public function __invoke( ContextManager $context, EventBehavior $eventBehavior, - array $arguments = null + ?array $arguments = null ): Carbon { return now(); }