| @@ 121-134 (lines=14) @@ | ||
| 118 | } |
|
| 119 | if (is_callable($func)) { |
|
| 120 | $this->logCallable($func, $args, $depth); |
|
| 121 | $args[] = function ($error, $result) use ($flow, $callback, $depth) { |
|
| 122 | if ($error) { |
|
| 123 | if ($this->logger) { |
|
| 124 | $this->logger->error((string)$error, compact('depth')); |
|
| 125 | } |
|
| 126 | if (is_callable($callback)) { |
|
| 127 | $callback($error); |
|
| 128 | } |
|
| 129 | ||
| 130 | return; |
|
| 131 | } |
|
| 132 | $flow->send($result); |
|
| 133 | ($this->exec)($flow, $callback, $depth); |
|
| 134 | }; |
|
| 135 | call_user_func_array($func, $args); |
|
| 136 | } elseif ($value instanceof Generator) { |
|
| 137 | $this->logGenerator($value, $depth); |
|
| @@ 138-151 (lines=14) @@ | ||
| 135 | call_user_func_array($func, $args); |
|
| 136 | } elseif ($value instanceof Generator) { |
|
| 137 | $this->logGenerator($value, $depth); |
|
| 138 | ($this->exec)($value, function ($error, $result) use ($flow, $callback, $depth) { |
|
| 139 | if ($error) { |
|
| 140 | if ($this->logger) { |
|
| 141 | $this->logger->error((string)$error); |
|
| 142 | } |
|
| 143 | if (is_callable($callback)) { |
|
| 144 | $callback($error); |
|
| 145 | } |
|
| 146 | ||
| 147 | return; |
|
| 148 | } |
|
| 149 | $flow->send($result); |
|
| 150 | ($this->exec)($flow, $callback, $depth); |
|
| 151 | }, $depth + 1); |
|
| 152 | } elseif (is_a($value, static::PROMISE_REACT)) { |
|
| 153 | $this->handlePromise($flow, $callback, $depth, $value); |
|
| 154 | } elseif (is_a($value, static::PROMISE_GUZZLE) || is_a($value, static::PROMISE_HTTP)) { |
|
| @@ 162-175 (lines=14) @@ | ||
| 159 | $this->logger->info('await $promise;'); |
|
| 160 | } |
|
| 161 | $value->onResolve( |
|
| 162 | function ($error, $result) use ($flow, $callback, $depth) { |
|
| 163 | if ($error) { |
|
| 164 | if ($this->logger) { |
|
| 165 | $this->logger->error((string)$error); |
|
| 166 | } |
|
| 167 | if (is_callable($callback)) { |
|
| 168 | $callback($error); |
|
| 169 | } |
|
| 170 | ||
| 171 | return; |
|
| 172 | } |
|
| 173 | $flow->send($result); |
|
| 174 | ($this->exec)($flow, $callback, $depth); |
|
| 175 | } |
|
| 176 | ); |
|
| 177 | } else { |
|
| 178 | $flow->send($value); |
|