@@ -5,7 +5,6 @@ |
||
| 5 | 5 | use mpyw\Co\Internal\CoOption; |
| 6 | 6 | use mpyw\Co\Internal\GeneratorContainer; |
| 7 | 7 | use mpyw\Co\Internal\CURLPool; |
| 8 | - |
|
| 9 | 8 | use React\Promise\Deferred; |
| 10 | 9 | use React\Promise\PromiseInterface; |
| 11 | 10 | use function React\Promise\all; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | if (!self::$self) { |
| 84 | 84 | throw new \BadMethodCallException( |
| 85 | - 'Co::async() must be called along with Co::wait(). ' . |
|
| 85 | + 'Co::async() must be called along with Co::wait(). '. |
|
| 86 | 86 | 'This method is mainly expected to be used in CURLOPT_WRITEFUNCTION callback.' |
| 87 | 87 | ); |
| 88 | 88 | } |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | $return = $exception = null; |
| 106 | 106 | $deferred = new Deferred; |
| 107 | 107 | $deferred->promise()->then( |
| 108 | - function ($r) use (&$return) { |
|
| 108 | + function($r) use (&$return) { |
|
| 109 | 109 | $return = $r; |
| 110 | 110 | }, |
| 111 | - function ($e) use (&$exception) { |
|
| 111 | + function($e) use (&$exception) { |
|
| 112 | 112 | $exception = $e; |
| 113 | 113 | } |
| 114 | 114 | ); |
| 115 | 115 | // For convenience, all values are wrapped into generator |
| 116 | - $genfunc = function () use ($value) { |
|
| 116 | + $genfunc = function() use ($value) { |
|
| 117 | 117 | yield CoInterface::RETURN_WITH => (yield $value); |
| 118 | 118 | }; |
| 119 | 119 | $con = Utils::normalize($genfunc, $this->options); |
@@ -170,9 +170,9 @@ discard block |
||
| 170 | 170 | if ($gc->key() === CoInterface::DELAY) { |
| 171 | 171 | $dfd = new Deferred; |
| 172 | 172 | $this->pool->addDelay($gc->current(), $dfd); |
| 173 | - $dfd->promise()->then(function () use ($gc) { |
|
| 173 | + $dfd->promise()->then(function() use ($gc) { |
|
| 174 | 174 | $gc->send(null); |
| 175 | - })->always(function () use ($gc, $deferred) { |
|
| 175 | + })->always(function() use ($gc, $deferred) { |
|
| 176 | 176 | $this->processGeneratorContainer($gc, $deferred); |
| 177 | 177 | }); |
| 178 | 178 | return; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $this->promiseAll($yieldables, $gc->throwAcceptable())->then( |
| 203 | 203 | self::getApplier($yielded, $yieldables, [$gc, 'send']), |
| 204 | 204 | [$gc, 'throw_'] |
| 205 | - )->always(function () use ($gc, $deferred) { |
|
| 205 | + )->always(function() use ($gc, $deferred) { |
|
| 206 | 206 | // Continue |
| 207 | 207 | $this->processGeneratorContainer($gc, $deferred); |
| 208 | 208 | }); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | private static function getApplier($yielded, $yieldables, callable $next) |
| 218 | 218 | { |
| 219 | - return function (array $results) use ($yielded, $yieldables, $next) { |
|
| 219 | + return function(array $results) use ($yielded, $yieldables, $next) { |
|
| 220 | 220 | foreach ($results as $hash => $resolved) { |
| 221 | 221 | $current = &$yielded; |
| 222 | 222 | foreach ($yieldables[$hash]['keylist'] as $key) { |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | if (!$throw_acceptable) { |
| 246 | 246 | $original_dfd = $dfd; |
| 247 | 247 | $dfd = new Deferred; |
| 248 | - $absorber = function ($any) use ($original_dfd) { |
|
| 248 | + $absorber = function($any) use ($original_dfd) { |
|
| 249 | 249 | $original_dfd->resolve($any); |
| 250 | 250 | }; |
| 251 | 251 | $dfd->promise()->then($absorber, $absorber); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Constructor. |
| 35 | - * @param Generator $g |
|
| 35 | + * @param \Generator $g |
|
| 36 | 36 | * @param CoOption $options |
| 37 | 37 | * @param mixed $yield_key |
| 38 | 38 | */ |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | /** |
| 126 | 126 | * Throw exception into generator. |
| 127 | - * @param RuntimeException $e |
|
| 127 | + * @param \RuntimeException $e |
|
| 128 | 128 | * @NOTE: This method returns nothing, |
| 129 | 129 | * while original generator returns something. |
| 130 | 130 | */ |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | } |
| 69 | 69 | $errno = curl_multi_add_handle($this->mh, $ch); |
| 70 | 70 | if ($errno !== CURLM_OK) { |
| 71 | - $msg = curl_multi_strerror($errno) . ": $ch"; |
|
| 71 | + $msg = curl_multi_strerror($errno).": $ch"; |
|
| 72 | 72 | $deferred->reject(new \RuntimeException($msg)); |
| 73 | 73 | return; |
| 74 | 74 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public function offsetGet($offset) |
| 89 | 89 | { |
| 90 | 90 | if (!isset($this->options[$offset])) { |
| 91 | - throw new \DomainException('Undefined field: ' + $offset); |
|
| 91 | + throw new \DomainException('Undefined field: ' +$offset); |
|
| 92 | 92 | } |
| 93 | 93 | return $this->options[$offset]; |
| 94 | 94 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | if (!isset(self::$types[$key])) { |
| 126 | 126 | throw new \InvalidArgumentException("Unknown option: $key"); |
| 127 | 127 | } |
| 128 | - $validator = [__CLASS__, 'validate' . self::$types[$key]]; |
|
| 128 | + $validator = [__CLASS__, 'validate'.self::$types[$key]]; |
|
| 129 | 129 | $options[$key] = $validator($key, $value); |
| 130 | 130 | } |
| 131 | 131 | return $options; |