@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | $data = 1337; |
| 20 | 20 | $result = $this->await( |
| 21 | - childProcessPromiseClosure(Loop::get(), static function () use ($data): array { |
|
| 21 | + childProcessPromiseClosure(Loop::get(), static function() use ($data): array { |
|
| 22 | 22 | return [$data]; |
| 23 | 23 | }) |
| 24 | 24 | ); |
@@ -1,17 +1,17 @@ |
||
| 1 | 1 | <?php declare(strict_types=1); |
| 2 | -require \dirname(__DIR__) . '/vendor/autoload.php'; |
|
| 2 | +require \dirname(__DIR__).'/vendor/autoload.php'; |
|
| 3 | 3 | |
| 4 | 4 | use React\EventLoop\Factory as EventLoopFactory; |
| 5 | 5 | use function WyriHaximus\React\childProcessPromiseClosure; |
| 6 | 6 | |
| 7 | 7 | $loop = EventLoopFactory::create(); |
| 8 | 8 | |
| 9 | -childProcessPromiseClosure($loop, function () { |
|
| 9 | +childProcessPromiseClosure($loop, function() { |
|
| 10 | 10 | return ['time'=>\time()]; |
| 11 | -})->done(function ($time): void { |
|
| 11 | +})->done(function($time): void { |
|
| 12 | 12 | echo $time['time'], \PHP_EOL; |
| 13 | -}, function (Throwable $throwable): void { |
|
| 14 | - echo (string)$throwable; |
|
| 13 | +}, function(Throwable $throwable): void { |
|
| 14 | + echo (string) $throwable; |
|
| 15 | 15 | }); |
| 16 | 16 | |
| 17 | 17 | $loop->run(); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php declare(strict_types=1); |
| 2 | -require \dirname(__DIR__) . '/vendor/autoload.php'; |
|
| 2 | +require \dirname(__DIR__).'/vendor/autoload.php'; |
|
| 3 | 3 | |
| 4 | 4 | use React\EventLoop\Factory as EventLoopFactory; |
| 5 | 5 | use function WyriHaximus\React\childProcessPromiseClosure; |
@@ -9,14 +9,14 @@ discard block |
||
| 9 | 9 | for ($i = 1; $i < 31; $i++) { |
| 10 | 10 | $delay = $i; |
| 11 | 11 | echo \time(), ': ', $delay, \PHP_EOL; |
| 12 | - childProcessPromiseClosure($loop, function () use ($delay) { |
|
| 12 | + childProcessPromiseClosure($loop, function() use ($delay) { |
|
| 13 | 13 | \sleep($delay * 2); |
| 14 | 14 | |
| 15 | 15 | return ['time'=>\time()]; |
| 16 | - })->done(function ($time): void { |
|
| 16 | + })->done(function($time): void { |
|
| 17 | 17 | echo \time(), ': ', $time['time'], \PHP_EOL; |
| 18 | - }, function (Throwable $throwable): void { |
|
| 19 | - echo (string)$throwable; |
|
| 18 | + }, function(Throwable $throwable): void { |
|
| 19 | + echo (string) $throwable; |
|
| 20 | 20 | }); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -6,6 +6,6 @@ |
||
| 6 | 6 | |
| 7 | 7 | use function function_exists; |
| 8 | 8 | |
| 9 | -if (! function_exists('WyriHaximus\React\childProcessPromiseClosure')) { |
|
| 10 | - require __DIR__ . '/functions.php'; |
|
| 9 | +if (!function_exists('WyriHaximus\React\childProcessPromiseClosure')) { |
|
| 10 | + require __DIR__.'/functions.php'; |
|
| 11 | 11 | } |
@@ -26,17 +26,17 @@ |
||
| 26 | 26 | /** |
| 27 | 27 | * @psalm-suppress TooManyTemplateParams |
| 28 | 28 | */ |
| 29 | - return Factory::parentFromClass(ClosureChild::class, $loop)->then(static function (Messenger $messenger) use ($closure): PromiseInterface { |
|
| 29 | + return Factory::parentFromClass(ClosureChild::class, $loop)->then(static function(Messenger $messenger) use ($closure): PromiseInterface { |
|
| 30 | 30 | $deferred = new Deferred(); |
| 31 | - $messenger->on('error', static function (Throwable $throwable) use ($deferred, $messenger): void { |
|
| 31 | + $messenger->on('error', static function(Throwable $throwable) use ($deferred, $messenger): void { |
|
| 32 | 32 | $deferred->reject($throwable); |
| 33 | 33 | $messenger->softTerminate(); |
| 34 | 34 | }); |
| 35 | 35 | |
| 36 | - $messenger->rpc(MessageFactory::rpc($closure))->then(static function (Payload $payload) use ($deferred, $messenger): void { |
|
| 36 | + $messenger->rpc(MessageFactory::rpc($closure))->then(static function(Payload $payload) use ($deferred, $messenger): void { |
|
| 37 | 37 | $deferred->resolve($payload->getPayload()); |
| 38 | 38 | $messenger->softTerminate(); |
| 39 | - }, static function (Throwable $throwable) use ($deferred, $messenger): void { |
|
| 39 | + }, static function(Throwable $throwable) use ($deferred, $messenger): void { |
|
| 40 | 40 | $deferred->reject($throwable); |
| 41 | 41 | $messenger->softTerminate(); |
| 42 | 42 | }); |