diff --git a/src/Step.php b/src/Step.php index e854342f..8ca10804 100644 --- a/src/Step.php +++ b/src/Step.php @@ -16,6 +16,8 @@ public function __construct( /** * Execute this step. + * + * @param array $responses */ public function run(array $responses): mixed { @@ -27,15 +29,17 @@ public function run(array $responses): mixed */ public function canRevert(): bool { - return $this->previous?->revert !== false; + return $this->previous?->revert instanceof Closure; } /** * Revert to the previous step. + * + * @param array $responses */ public function revert(array $responses): void { - if ($this->canRevert()) { + if ($this->previous?->revert instanceof Closure) { ($this->previous->revert)($responses); } } diff --git a/src/StepBuilder.php b/src/StepBuilder.php index 8aba74b1..390e1dc8 100644 --- a/src/StepBuilder.php +++ b/src/StepBuilder.php @@ -8,18 +8,22 @@ class StepBuilder { /** * Each step that should be executed. + * + * @var array */ protected array $steps = []; /** * The responses provided by each step. + * + * @var array */ protected array $responses = []; /** * Add a new step. */ - public function add(Closure $step, Closure|false|null $revert = null, ?string $key = null) + public function add(Closure $step, Closure|false|null $revert = null, ?string $key = null): self { if ($revert === null) { $revert = fn () => null; @@ -33,6 +37,8 @@ public function add(Closure $step, Closure|false|null $revert = null, ?string $k /** * Run all of the given steps. + * + * @return array */ public function run(): array {