Skip to content

Commit

Permalink
Simplify phpdoc for Workflow::registerQuery(), Workflow::registerSign…
Browse files Browse the repository at this point in the history
…al(), Workflow::registerUpdate()
  • Loading branch information
roxblnfk committed Sep 10, 2024
1 parent b9a2a1b commit 4507c30
Showing 1 changed file with 18 additions and 37 deletions.
55 changes: 18 additions & 37 deletions src/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,17 +332,12 @@ public static function getLastCompletionResult($type = null)
}

/**
* A method that allows you to dynamically register additional query
* handler in a workflow during the execution of a workflow.
* Register a Query handler in the Workflow.
*
* ```php
* #[WorkflowMethod]
* public function handler()
* {
* Workflow::registerQuery('query', function(string $argument) {
* echo sprintf('Executed query "query" with argument "%s"', $argument);
* });
* }
* Workflow::registerQuery('query', function(string $argument) {
* echo sprintf('Executed query "query" with argument "%s"', $argument);
* });
* ```
*
* The same method ({@see WorkflowStubInterface::query()}) should be used
Expand All @@ -359,19 +354,12 @@ public static function registerQuery(string $queryType, callable $handler): Scop
}

/**
* Registers a query with an additional signal handler.
*
* The method is similar to the {@see Workflow::registerQuery()}, but it
* registers an additional signal handler.
* Registers a Signal handler in the Workflow.
*
* ```php
* #[WorkflowMethod]
* public function handler()
* {
* Workflow::registerSignal('signal', function(string $argument) {
* echo sprintf('Executed signal "signal" with argument "%s"', $argument);
* });
* }
* Workflow::registerSignal('signal', function(string $argument) {
* echo sprintf('Executed signal "signal" with argument "%s"', $argument);
* });
* ```
*
* The same method ({@see WorkflowStubInterface::signal()}) should be used
Expand All @@ -391,33 +379,26 @@ public static function registerSignal(string $queryType, callable $handler): Sco
* Registers an Update method in the Workflow.
*
* ```php
* #[WorkflowMethod]
* public function handler()
* {
* Workflow::registerUpdate(
* 'my-update',
* fn(Task $task) => $this->queue->push($task),
* );
* }
* Workflow::registerUpdate(
* 'pushTask',
* fn(Task $task) => $this->queue->push($task),
* );
* ```
*
* Register an Update method with a validator:
*
* ```php
* #[WorkflowMethod]
* public function handler()
* {
* Workflow::registerUpdate(
* 'my-update',
* fn(Task $task) => $this->queue->push($task),
* fn(Task $task) => $this->isValidTask($task) or throw new \InvalidArgumentException('Invalid task'),
* );
* }
* Workflow::registerUpdate(
* 'pushTask',
* fn(Task $task) => $this->queue->push($task),
* fn(Task $task) => $this->isValidTask($task) or throw new \InvalidArgumentException('Invalid task'),
* );
* ```
*
* Note that the validator must have the same signature as the Update method:
*
* @param non-empty-string $name
* @throws OutOfContextException in the absence of the workflow execution context.
*/
public static function registerUpdate(
string $name,
Expand Down

0 comments on commit 4507c30

Please sign in to comment.