Skip to content

Commit

Permalink
Cleanup; prepare to PR interceptors into master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Oct 23, 2023
1 parent b5a52f0 commit 24c4fc7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 72 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.6.x-dev"
"dev-master": "2.7.x-dev"
}
},
"config": {
Expand Down
16 changes: 0 additions & 16 deletions src/Exception/InterceptorCallException.php

This file was deleted.

11 changes: 3 additions & 8 deletions src/Internal/Interceptor/Pipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Temporal\Internal\Interceptor;

use Closure;
use Temporal\Exception\InterceptorCallException;

/**
* Pipeline is a processor for interceptors chain.
Expand Down Expand Up @@ -96,14 +95,10 @@ public function __invoke(mixed ...$arguments): mixed
return ($this->last)(...$arguments);
}

try {
$next = $this->next();
$arguments[] = $next;
$next = $this->next();
$arguments[] = $next;

return $interceptor->{$this->method}(...$arguments);
} catch (\Throwable $e) {
throw new InterceptorCallException(previous: $e);
}
return $interceptor->{$this->method}(...$arguments);
}

private function next(): self
Expand Down
54 changes: 8 additions & 46 deletions src/Internal/Workflow/ChildWorkflowProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,70 +21,31 @@

final class ChildWorkflowProxy extends Proxy
{
/**
* @var string
*/
private const ERROR_UNDEFINED_WORKFLOW_METHOD =
'The given stub class "%s" does not contain a workflow method named "%s"';

/**
* @var string
*/
private const ERROR_UNDEFINED_METHOD =
'The given stub class "%s" does not contain a workflow or signal method named "%s"';

/**
* @var string
*/
private const ERROR_UNSUPPORTED_METHOD =
'The method named "%s" (%s) cannot be executed from a child workflow stub. ' .
'Only workflow and signal methods are allowed';

/**
* @var string
*/
private string $class;

/**
* @var ChildWorkflowOptions
*/
private ChildWorkflowOptions $options;

/**
* @var ChildWorkflowStubInterface|null
*/
private ?ChildWorkflowStubInterface $stub = null;

/**
* @var WorkflowContextInterface
*/
private WorkflowContextInterface $context;

/**
* @var WorkflowPrototype
*/
private WorkflowPrototype $workflow;

/**
* @param string $class
* @param WorkflowPrototype $workflow
* @param ChildWorkflowOptions $options
* @param WorkflowContextInterface $context
* @param class-string $class
*/
public function __construct(
string $class,
WorkflowPrototype $workflow,
ChildWorkflowOptions $options,
WorkflowContextInterface $context,
private readonly string $class,
private readonly WorkflowPrototype $workflow,
private readonly ChildWorkflowOptions $options,
private readonly WorkflowContextInterface $context,
) {
$this->class = $class;
$this->workflow = $workflow;
$this->options = $options;
$this->context = $context;
}

/**
* @param string $method
* @param non-empty-string $method
* @param array $args
* @return CompletableResultInterface
*/
Expand Down Expand Up @@ -155,7 +116,8 @@ private function resolveReturnType(WorkflowPrototype $prototype): ?Type
}

/**
* @return bool
* @psalm-assert-if-true ChildWorkflowStubInterface $this->stub
* @psalm-assert-if-false null $this->stub
*/
private function isRunning(): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Workflow/ChildWorkflowStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function start(... $args): PromiseInterface

$started = $this->request(new GetChildWorkflowExecution($this->request))
->then(
function (ValuesInterface $values) {
function (ValuesInterface $values): mixed {
$execution = $values->getValue(0, WorkflowExecution::class);
$this->execution->resolve($execution);

Expand Down

0 comments on commit 24c4fc7

Please sign in to comment.