diff --git a/composer.json b/composer.json index 4b6280b..50b74f2 100644 --- a/composer.json +++ b/composer.json @@ -57,7 +57,7 @@ "@composer run build", "@php vendor/bin/testbench serve" ], - "analyse": "vendor/bin/phpstan analyse", + "analyse": "php -d memory_limit=2G vendor/bin/phpstan analyse --memory-limit=2G", "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest --coverage", "format": "vendor/bin/pint" diff --git a/src/Abstracts/AbstractTransitionSuccessJob.php b/src/Abstracts/AbstractTransitionSuccessJob.php index f506a5a..a8a5274 100644 --- a/src/Abstracts/AbstractTransitionSuccessJob.php +++ b/src/Abstracts/AbstractTransitionSuccessJob.php @@ -19,6 +19,7 @@ public function __construct( public StateableModelContract&Model $model, public string $from, public string $to, + /** @var array */ public array $parameters = []) {} /** diff --git a/src/ArFlowService.php b/src/ArFlowService.php index 0ebd07e..d67d1fa 100755 --- a/src/ArFlowService.php +++ b/src/ArFlowService.php @@ -2,7 +2,6 @@ namespace AuroraWebSoftware\ArFlow; -use AuroraWebSoftware\ArFlow\Exceptions\StateNotFoundException; use AuroraWebSoftware\ArFlow\Exceptions\WorkflowNotFoundException; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; @@ -10,6 +9,7 @@ class ArFlowService { + /** @var array, initial_state: string, transitions?: array, to: string|array, guards?: array}>, actions?: array}>, success_metadata?: array, success_jobs?: array}>}>}> */ private array $workflows; public function __construct() @@ -21,18 +21,20 @@ public function __construct() * @return array * * @throws WorkflowNotFoundException - * @throws StateNotFoundException */ public function getStates(string $workflow): array { foreach ($this->workflows as $workflowKey => $workflowValues) { if ($workflowKey == $workflow) { - return $workflowValues['states'] ?? throw new StateNotFoundException; + return $workflowValues['states']; } } throw new WorkflowNotFoundException; } + /** + * @return array + */ public function getSupportedModelTypes(string $workflow): array { return []; diff --git a/src/Collections/TransitionGuardResultCollection.php b/src/Collections/TransitionGuardResultCollection.php index 4eed45c..90a163c 100644 --- a/src/Collections/TransitionGuardResultCollection.php +++ b/src/Collections/TransitionGuardResultCollection.php @@ -6,7 +6,7 @@ use Illuminate\Support\Collection; /** - * @extends Collection> + * @extends Collection> */ class TransitionGuardResultCollection extends Collection { diff --git a/src/Contacts/StateableModelContract.php b/src/Contacts/StateableModelContract.php index 8431290..3204e28 100644 --- a/src/Contacts/StateableModelContract.php +++ b/src/Contacts/StateableModelContract.php @@ -69,21 +69,27 @@ public function currentState(): string; public function currentStateMetadata(): array; /** + * @param array|null $withoutGuards * @return TransitionGuardResultCollection> * * @throws WorkflowNotFoundException */ public function transitionGuardResults(string $toState, ?array $withoutGuards = null): TransitionGuardResultCollection; + /** + * @param array|null $withoutGuards + */ public function canTransitionTo(string $toState, ?array $withoutGuards = null): bool; /** + * @param array|null $withoutGuards * @return array|null */ public function definedTransitionKeys(?array $withoutGuards = null): ?array; /** * @param array|null $withoutGuards + * @return array|null * * @throws WorkflowNotFoundException * @throws Throwable @@ -91,12 +97,14 @@ public function definedTransitionKeys(?array $withoutGuards = null): ?array; public function allowedTransitionKeys(?array $withoutGuards = null): ?array; /** + * @param array|null $withoutGuards * @return array|null */ public function definedTransitionStates(?array $withoutGuards = null): ?array; /** * @param array|null $withoutGuards + * @return array|null * * @throws WorkflowNotFoundException * @throws Throwable @@ -108,6 +116,7 @@ public function lastUpdatedTime(): ?DateTime; /** * @param class-string|null $actorModelType * @param array|null $withoutGuards + * @param array|null $metadata * * @throws StateNotFoundException * @throws TransitionActionException diff --git a/src/Contacts/TransitionActionContract.php b/src/Contacts/TransitionActionContract.php index 4afec77..daff78c 100644 --- a/src/Contacts/TransitionActionContract.php +++ b/src/Contacts/TransitionActionContract.php @@ -8,6 +8,9 @@ interface TransitionActionContract { + /** + * @param array $parameters + */ public function boot(StateableModelContract&Model $model, string $from, string $to, array $parameters = []): void; /** diff --git a/src/Contacts/TransitionGuardContract.php b/src/Contacts/TransitionGuardContract.php index 09ff810..23552be 100644 --- a/src/Contacts/TransitionGuardContract.php +++ b/src/Contacts/TransitionGuardContract.php @@ -9,6 +9,9 @@ interface TransitionGuardContract { + /** + * @param array $parameters + */ public function boot(StateableModelContract&Model $model, string $from, string $to, array $parameters): void; /** diff --git a/src/StateTransition.php b/src/StateTransition.php index 6fb3cf1..3f9b499 100644 --- a/src/StateTransition.php +++ b/src/StateTransition.php @@ -22,6 +22,7 @@ class StateTransition extends Model public string $comment; + /** @var array */ public array $metadata; public int $model_id; diff --git a/src/Traits/HasState.php b/src/Traits/HasState.php index 59d040e..538cca3 100644 --- a/src/Traits/HasState.php +++ b/src/Traits/HasState.php @@ -24,6 +24,9 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Config; +/** + * @phpstan-ignore-next-line + */ trait HasState { public function getId(): int|string diff --git a/src/TransitionActions/LogHistoryTransitionAction.php b/src/TransitionActions/LogHistoryTransitionAction.php index 23edf72..0974909 100644 --- a/src/TransitionActions/LogHistoryTransitionAction.php +++ b/src/TransitionActions/LogHistoryTransitionAction.php @@ -9,6 +9,7 @@ class LogHistoryTransitionAction implements TransitionActionContract { + /** @var array */ private array $parameters; private StateableModelContract&Model $model; @@ -17,6 +18,9 @@ class LogHistoryTransitionAction implements TransitionActionContract private string $to; + /** + * @param array $parameters + */ public function boot(StateableModelContract&Model $model, string $from, string $to, array $parameters = []): void { $this->model = $model; diff --git a/tests/TransitionActions/TestSuccessTransitionAction.php b/tests/TransitionActions/TestSuccessTransitionAction.php index f2367ac..8b2646c 100644 --- a/tests/TransitionActions/TestSuccessTransitionAction.php +++ b/tests/TransitionActions/TestSuccessTransitionAction.php @@ -8,8 +8,12 @@ class TestSuccessTransitionAction implements TransitionActionContract { + /** @var array */ public array $parameters; + /** + * @param array $parameters + */ public function boot(StateableModelContract&Model $model, string $from, string $to, array $parameters = []): void { $this->parameters = $parameters;