Codebase list php-react-promise / 56271a5
CS fixes Jan Sorgalla 9 years ago
9 changed file(s) with 45 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
4949
5050 public function always(callable $onFulfilledOrRejected)
5151 {
52 return $this->then(function($value) use ($onFulfilledOrRejected) {
52 return $this->then(function ($value) use ($onFulfilledOrRejected) {
5353 return resolve($onFulfilledOrRejected())->then(function () use ($value) {
5454 return $value;
5555 });
6565
6666 public function always(callable $onFulfilledOrRejected)
6767 {
68 return $this->then(function($value) use ($onFulfilledOrRejected) {
68 return $this->then(function ($value) use ($onFulfilledOrRejected) {
6969 return resolve($onFulfilledOrRejected())->then(function () use ($value) {
7070 return $value;
7171 });
140140 $result = $promise;
141141
142142 if (!$result instanceof ExtendedPromiseInterface) {
143 $result = new static(function($resolve, $reject, $notify) use ($promise) {
143 $result = new static(function ($resolve, $reject, $notify) use ($promise) {
144144 $promise->then($resolve, $reject, $notify);
145145 });
146146 }
327327
328328 $this->setExpectedException('\Exception', 'UnhandledRejectionException');
329329
330 $this->assertNull($adapter->promise()->done(null, null, function() {
330 $this->assertNull($adapter->promise()->done(null, null, function () {
331331 throw new \Exception('UnhandledRejectionException');
332332 }));
333333 $adapter->notify(1);
198198 $this->setExpectedException('\Exception', 'UnhandledRejectionException');
199199
200200 $adapter->resolve(1);
201 $this->assertNull($adapter->promise()->done(function() {
201 $this->assertNull($adapter->promise()->done(function () {
202202 throw new \Exception('UnhandledRejectionException');
203203 }));
204204 }
211211 $this->setExpectedException('React\\Promise\\UnhandledRejectionException');
212212
213213 $adapter->resolve(1);
214 $this->assertNull($adapter->promise()->done(function() {
214 $this->assertNull($adapter->promise()->done(function () {
215215 return \React\Promise\reject();
216216 }));
217217 }
240240
241241 $adapter->resolve($value);
242242 $adapter->promise()
243 ->always(function() {})
243 ->always(function () {})
244244 ->then($mock);
245245 }
246246
259259
260260 $adapter->resolve($value);
261261 $adapter->promise()
262 ->always(function() {
262 ->always(function () {
263263 return 1;
264264 })
265265 ->then($mock);
280280
281281 $adapter->resolve($value);
282282 $adapter->promise()
283 ->always(function() {
283 ->always(function () {
284284 return \React\Promise\resolve(1);
285285 })
286286 ->then($mock);
301301
302302 $adapter->resolve(1);
303303 $adapter->promise()
304 ->always(function() use($exception) {
304 ->always(function () use ($exception) {
305305 throw $exception;
306306 })
307307 ->then(null, $mock);
322322
323323 $adapter->resolve(1);
324324 $adapter->promise()
325 ->always(function() use($exception) {
325 ->always(function () use ($exception) {
326326 return \React\Promise\reject($exception);
327327 })
328328 ->then(null, $mock);
5454 {
5555 $adapter = $this->getPromiseTestAdapter();
5656
57 $this->assertInstanceOf('React\\Promise\\PromiseInterface', $adapter->promise()->always(function(){}));
57 $this->assertInstanceOf('React\\Promise\\PromiseInterface', $adapter->promise()->always(function () {}));
5858 }
5959 }
205205 $this->setExpectedException('\Exception', 'UnhandledRejectionException');
206206
207207 $adapter->reject(1);
208 $this->assertNull($adapter->promise()->done(null, function() {
208 $this->assertNull($adapter->promise()->done(null, function () {
209209 throw new \Exception('UnhandledRejectionException');
210210 }));
211211 }
229229 $this->setExpectedException('React\\Promise\\UnhandledRejectionException');
230230
231231 $adapter->reject(1);
232 $this->assertNull($adapter->promise()->done(null, function() {
232 $this->assertNull($adapter->promise()->done(null, function () {
233233 return \React\Promise\reject();
234234 }));
235235 }
242242 $this->setExpectedException('\Exception', 'UnhandledRejectionException');
243243
244244 $adapter->reject(1);
245 $this->assertNull($adapter->promise()->done(null, function() {
245 $this->assertNull($adapter->promise()->done(null, function () {
246246 return \React\Promise\reject(new \Exception('UnhandledRejectionException'));
247247 }));
248248 }
268268 $d = new Deferred();
269269 $d->resolve();
270270
271 $result = \React\Promise\resolve(\React\Promise\resolve($d->promise()->then(function () use($exception) {
271 $result = \React\Promise\resolve(\React\Promise\resolve($d->promise()->then(function () use ($exception) {
272272 $d = new Deferred();
273273 $d->resolve();
274274
288288 $adapter = $this->getPromiseTestAdapter();
289289
290290 $adapter->reject(new \Exception('UnhandledRejectionException'));
291 $this->assertNull($adapter->promise()->done(null, function(\Exception $e) {
291 $this->assertNull($adapter->promise()->done(null, function (\Exception $e) {
292292
293293 }));
294294 }
323323
324324 $adapter->reject($exception);
325325 $adapter->promise()
326 ->otherwise(function(\InvalidArgumentException $reason) use ($mock) {
326 ->otherwise(function (\InvalidArgumentException $reason) use ($mock) {
327327 $mock($reason);
328328 });
329329 }
339339
340340 $adapter->reject($exception);
341341 $adapter->promise()
342 ->otherwise(function(\InvalidArgumentException $reason) use ($mock) {
342 ->otherwise(function (\InvalidArgumentException $reason) use ($mock) {
343343 $mock($reason);
344344 });
345345 }
359359
360360 $adapter->reject($exception);
361361 $adapter->promise()
362 ->always(function() {})
362 ->always(function () {})
363363 ->then(null, $mock);
364364 }
365365
378378
379379 $adapter->reject($exception);
380380 $adapter->promise()
381 ->always(function() {
381 ->always(function () {
382382 return 1;
383383 })
384384 ->then(null, $mock);
399399
400400 $adapter->reject($exception);
401401 $adapter->promise()
402 ->always(function() {
402 ->always(function () {
403403 return \React\Promise\resolve(1);
404404 })
405405 ->then(null, $mock);
421421
422422 $adapter->reject($exception1);
423423 $adapter->promise()
424 ->always(function() use ($exception2) {
424 ->always(function () use ($exception2) {
425425 throw $exception2;
426426 })
427427 ->then(null, $mock);
443443
444444 $adapter->reject($exception1);
445445 $adapter->promise()
446 ->always(function() use ($exception2) {
446 ->always(function () use ($exception2) {
447447 return \React\Promise\reject($exception2);
448448 })
449449 ->then(null, $mock);
3232 $adapter = $this->getPromiseTestAdapter();
3333
3434 $adapter->settle();
35 $this->assertNull($adapter->promise()->done(null, function() {}));
35 $this->assertNull($adapter->promise()->done(null, function () {}));
3636 }
3737
3838 /** @test */
4141 $adapter = $this->getPromiseTestAdapter();
4242
4343 $adapter->settle();
44 $this->assertNull($adapter->promise()->done(null, function() {}, null));
44 $this->assertNull($adapter->promise()->done(null, function () {}, null));
4545 }
4646
4747 /** @test */
6060 $adapter = $this->getPromiseTestAdapter();
6161
6262 $adapter->settle();
63 $this->assertInstanceOf('React\\Promise\\PromiseInterface', $adapter->promise()->always(function(){}));
63 $this->assertInstanceOf('React\\Promise\\PromiseInterface', $adapter->promise()->always(function () {}));
6464 }
6565 }
145145
146146 $this->setExpectedException('\Exception', 'UnhandledRejectionException');
147147
148 $this->assertNull($adapter->promise()->done(null, function() {
148 $this->assertNull($adapter->promise()->done(null, function () {
149149 throw new \Exception('UnhandledRejectionException');
150150 }));
151151 $adapter->reject(1);
169169
170170 $this->setExpectedException('React\\Promise\\UnhandledRejectionException');
171171
172 $this->assertNull($adapter->promise()->done(null, function() {
172 $this->assertNull($adapter->promise()->done(null, function () {
173173 return \React\Promise\reject();
174174 }));
175175 $adapter->reject(1);
182182
183183 $this->setExpectedException('\Exception', 'UnhandledRejectionException');
184184
185 $this->assertNull($adapter->promise()->done(null, function() {
185 $this->assertNull($adapter->promise()->done(null, function () {
186186 return \React\Promise\reject(new \Exception('UnhandledRejectionException'));
187187 }));
188188 $adapter->reject(1);
198198 $d = new Deferred();
199199 $promise = $d->promise();
200200
201 $this->assertNull($adapter->promise()->done(null, function() use ($promise) {
201 $this->assertNull($adapter->promise()->done(null, function () use ($promise) {
202202 return $promise;
203203 }));
204204 $adapter->reject(1);
225225
226226 $d = new Deferred();
227227
228 $result = \React\Promise\resolve(\React\Promise\resolve($d->promise()->then(function () use($exception) {
228 $result = \React\Promise\resolve(\React\Promise\resolve($d->promise()->then(function () use ($exception) {
229229 $d = new Deferred();
230230 $d->resolve();
231231
246246 {
247247 $adapter = $this->getPromiseTestAdapter();
248248
249 $this->assertNull($adapter->promise()->done(null, function(\Exception $e) {
249 $this->assertNull($adapter->promise()->done(null, function (\Exception $e) {
250250
251251 }));
252252 $adapter->reject(new \Exception('UnhandledRejectionException'));
266266 ->with($this->identicalTo($exception));
267267
268268 $adapter->promise()
269 ->always(function() {})
269 ->always(function () {})
270270 ->then(null, $mock);
271271
272272 $adapter->reject($exception);
286286 ->with($this->identicalTo($exception));
287287
288288 $adapter->promise()
289 ->always(function() {
289 ->always(function () {
290290 return 1;
291291 })
292292 ->then(null, $mock);
308308 ->with($this->identicalTo($exception));
309309
310310 $adapter->promise()
311 ->always(function() {
311 ->always(function () {
312312 return \React\Promise\resolve(1);
313313 })
314314 ->then(null, $mock);
330330 ->with($this->identicalTo($exception));
331331
332332 $adapter->promise()
333 ->always(function() use($exception) {
333 ->always(function () use ($exception) {
334334 throw $exception;
335335 })
336336 ->then(null, $mock);
352352 ->with($this->identicalTo($exception));
353353
354354 $adapter->promise()
355 ->always(function() use($exception) {
355 ->always(function () use ($exception) {
356356 return \React\Promise\reject($exception);
357357 })
358358 ->then(null, $mock);
128128
129129 $this->setExpectedException('\Exception', 'UnhandledRejectionException');
130130
131 $this->assertNull($adapter->promise()->done(function() {
131 $this->assertNull($adapter->promise()->done(function () {
132132 throw new \Exception('UnhandledRejectionException');
133133 }));
134134 $adapter->resolve(1);
141141
142142 $this->setExpectedException('React\\Promise\\UnhandledRejectionException');
143143
144 $this->assertNull($adapter->promise()->done(function() {
144 $this->assertNull($adapter->promise()->done(function () {
145145 return \React\Promise\reject();
146146 }));
147147 $adapter->resolve(1);
161161 ->with($this->identicalTo($value));
162162
163163 $adapter->promise()
164 ->always(function() {})
164 ->always(function () {})
165165 ->then($mock);
166166
167167 $adapter->resolve($value);
181181 ->with($this->identicalTo($value));
182182
183183 $adapter->promise()
184 ->always(function() {
184 ->always(function () {
185185 return 1;
186186 })
187187 ->then($mock);
203203 ->with($this->identicalTo($value));
204204
205205 $adapter->promise()
206 ->always(function() {
206 ->always(function () {
207207 return \React\Promise\resolve(1);
208208 })
209209 ->then($mock);
225225 ->with($this->identicalTo($exception));
226226
227227 $adapter->promise()
228 ->always(function() use($exception) {
228 ->always(function () use ($exception) {
229229 throw $exception;
230230 })
231231 ->then(null, $mock);
247247 ->with($this->identicalTo($exception));
248248
249249 $adapter->promise()
250 ->always(function() use($exception) {
250 ->always(function () use ($exception) {
251251 return \React\Promise\reject($exception);
252252 })
253253 ->then(null, $mock);