@@ -71,11 +71,12 @@ function (ReflectionParameter $param) {
7171 $ value = '[] ' ;
7272 }
7373 $ hookName = str_replace ('$ ' , '\$ ' , $ hookName );
74+
7475 return <<<EOT
7576 {$ name } {
7677 \$this->operation = " {$ hookName }";
7778 \$this->arguments = {$ value };
78- throw new \Exception('Not implemented ');
79+ throw new \Bottledcode\DurablePhp\Proxy\SpyException('do not call outside of context ');
7980 }
8081 EOT ;
8182 }
@@ -84,7 +85,7 @@ function (ReflectionParameter $param) {
8485 public function {$ name }( {$ params }) {$ return } {
8586 \$this->operation = " {$ name }";
8687 \$this->arguments = func_get_args();
87- throw new \Exception('Not implemented ');
88+ throw new \Bottledcode\DurablePhp\Proxy\SpyException('do not call outside of context ');
8889 }
8990 EOT ;
9091 }
@@ -102,7 +103,24 @@ protected function impureSignal(ReflectionMethod $method): string
102103 protected function preamble (ReflectionClass $ class ): string
103104 {
104105 return <<<'EOT'
105- public function __construct(private string|null &$operation = null, private array|null &$arguments = null) {}
106+ private string|null $operation {
107+ get => $this->op;
108+ set {
109+ if ($this->op !== null) {
110+ throw new \LogicException('Can only send one signal at a time');
111+ }
112+ }
113+ }
114+ private array|null $arguments {
115+ get => $this->args;
116+ set {
117+ if ($this->args !== null) {
118+ throw new \LogicException('Can only send one signal at a time');
119+ }
120+ }
121+ }
122+
123+ public function __construct(private string|null &$op = null, private array|null &$args = null) {}
106124 EOT;
107125 }
108126}
0 commit comments