summaryrefslogtreecommitdiff
path: root/tests/temporal/Workflow/ChildStubWorkflow.php
blob: 608962c21b7e729c0fb26a6b10dd44168a92681f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php

namespace Temporal\Tests\Workflow;

use Temporal\Workflow;
use Temporal\Workflow\WorkflowMethod;

#[Workflow\WorkflowInterface]
class ChildStubWorkflow
{
    #[WorkflowMethod(name: 'ChildStubWorkflow')]
    public function handler(
        string $input
    ) {
        // typed stub
        $simple = Workflow::newChildWorkflowStub(SimpleWorkflow::class);

        $result = [];
        $result[] = yield $simple->handler($input);

        // untyped
        $untyped = Workflow::newUntypedChildWorkflowStub('SimpleWorkflow');
        $result[] = yield $untyped->execute(['untyped']);

        $execution = yield $untyped->getExecution();
        assert($execution instanceof Workflow\WorkflowExecution);

        return $result;
    }
}