@@ -8,10 +8,10 @@ discard block |
||
| 8 | 8 | echo '------------------------------------------', PHP_EOL; |
| 9 | 9 | echo $message, PHP_EOL; |
| 10 | 10 | echo '------------------------------------------', PHP_EOL; |
| 11 | - echo 'Current memory usage: ', \memory_get_usage() / MB, 'MB', PHP_EOL; |
|
| 12 | - echo 'Peak memory usage: ', \memory_get_peak_usage() / MB, 'MB', PHP_EOL; |
|
| 13 | - echo 'Current real memory usage: ', \memory_get_usage(true) / MB, 'MB', PHP_EOL; |
|
| 14 | - echo 'Peak real memory usage: ', \memory_get_peak_usage(true) / MB, 'MB', PHP_EOL; |
|
| 11 | + echo 'Current memory usage: ', \memory_get_usage() / MB, 'MB', PHP_EOL; |
|
| 12 | + echo 'Peak memory usage: ', \memory_get_peak_usage() / MB, 'MB', PHP_EOL; |
|
| 13 | + echo 'Current real memory usage: ', \memory_get_usage(true) / MB, 'MB', PHP_EOL; |
|
| 14 | + echo 'Peak real memory usage: ', \memory_get_peak_usage(true) / MB, 'MB', PHP_EOL; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | show_memory('Bare init'); |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $loop = EventLoopFactory::create(); |
| 30 | 30 | |
| 31 | -MessengerFactory::parentFromClass(\WyriHaximus\React\ChildProcess\Messenger\ReturnChild::class, $loop)->then(function (Messenger $messenger) use ($loop) { |
|
| 32 | - $messenger->on('error', function ($e) { |
|
| 31 | +MessengerFactory::parentFromClass(\WyriHaximus\React\ChildProcess\Messenger\ReturnChild::class, $loop)->then(function(Messenger $messenger) use ($loop) { |
|
| 32 | + $messenger->on('error', function($e) { |
|
| 33 | 33 | echo 'Error: ', \var_export($e, true), PHP_EOL; |
| 34 | 34 | }); |
| 35 | 35 | |
| 36 | 36 | $i = 0; |
| 37 | - $loop->addPeriodicTimer(0.00001, function (TimerInterface $timer) use (&$i, $messenger, $loop) { |
|
| 37 | + $loop->addPeriodicTimer(0.00001, function(TimerInterface $timer) use (&$i, $messenger, $loop) { |
|
| 38 | 38 | if ($i >= I) { |
| 39 | 39 | $loop->cancelTimer($timer); |
| 40 | 40 | $messenger->softTerminate(); |
| 41 | 41 | |
| 42 | 42 | show_memory('Completed messaging'); |
| 43 | 43 | |
| 44 | - $loop->addTimer(5, function () { |
|
| 44 | + $loop->addTimer(5, function() { |
|
| 45 | 45 | }); |
| 46 | 46 | |
| 47 | 47 | return; |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | |
| 45 | 45 | public function handle(MessengerInterface $bindTo, string $source): void |
| 46 | 46 | { |
| 47 | - $cb = Closure::fromCallable(function (Throwable $payload, string $uniqid): void { |
|
| 47 | + $cb = Closure::fromCallable(function(Throwable $payload, string $uniqid): void { |
|
| 48 | 48 | /** |
| 49 | 49 | * @psalm-suppress UndefinedMethod |
| 50 | 50 | */ |
@@ -36,11 +36,11 @@ |
||
| 36 | 36 | |
| 37 | 37 | public function handle(object $bindTo, string $source): void |
| 38 | 38 | { |
| 39 | - $cb = function (Throwable $payload): void { |
|
| 39 | + $cb = function(Throwable $payload): void { |
|
| 40 | 40 | /** |
| 41 | 41 | * @psalm-suppress UndefinedMethod |
| 42 | 42 | */ |
| 43 | - $this->emit('error', [ /** @phpstan-ignore-line */ |
|
| 43 | + $this->emit('error', [/** @phpstan-ignore-line */ |
|
| 44 | 44 | $payload, |
| 45 | 45 | $this, |
| 46 | 46 | ]); |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | public function handle(object $bindTo, string $source): void |
| 54 | 54 | { |
| 55 | - $cb = Closure::fromCallable(function (string $target, Payload $payload, string $uniqid): void { |
|
| 55 | + $cb = Closure::fromCallable(function(string $target, Payload $payload, string $uniqid): void { |
|
| 56 | 56 | /** |
| 57 | 57 | * @psalm-suppress UndefinedMethod |
| 58 | 58 | */ |
| 59 | - if (! $this->hasRpc($target)) { /** @phpstan-ignore-line */ |
|
| 59 | + if (!$this->hasRpc($target)) { /** @phpstan-ignore-line */ |
|
| 60 | 60 | $this->write($this->createLine(Factory::rpcError($uniqid, new Exception(sprintf('Rpc target <%s> doesn\'t exist', $target))))); /** @phpstan-ignore-line */ |
| 61 | 61 | |
| 62 | 62 | return; |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * @psalm-suppress UndefinedMethod |
| 67 | 67 | */ |
| 68 | - $this->callRpc($target, $payload)->done( /** @phpstan-ignore-line */ |
|
| 69 | - function (array $payload) use ($uniqid): void { |
|
| 68 | + $this->callRpc($target, $payload)->done(/** @phpstan-ignore-line */ |
|
| 69 | + function(array $payload) use ($uniqid): void { |
|
| 70 | 70 | /** |
| 71 | 71 | * @psalm-suppress UndefinedMethod |
| 72 | 72 | */ |
| 73 | 73 | $this->write($this->createLine(Factory::rpcSuccess($uniqid, $payload))); /** @phpstan-ignore-line */ |
| 74 | 74 | }, |
| 75 | - function (Throwable $error) use ($uniqid): void { |
|
| 75 | + function(Throwable $error) use ($uniqid): void { |
|
| 76 | 76 | /** |
| 77 | 77 | * @psalm-suppress UndefinedMethod |
| 78 | 78 | */ |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | $throwables = []; |
| 38 | 38 | $line = Hash::flatten($line); |
| 39 | 39 | foreach ($line as $key => $value) { |
| 40 | - if (! ($value instanceof Throwable)) { |
|
| 40 | + if (!($value instanceof Throwable)) { |
|
| 41 | 41 | continue; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | |
| 40 | 40 | public function handle(MessengerInterface $bindTo, string $source): void |
| 41 | 41 | { |
| 42 | - $cb = Closure::fromCallable(function (Payload $payload, string $uniqid): void { |
|
| 42 | + $cb = Closure::fromCallable(function(Payload $payload, string $uniqid): void { |
|
| 43 | 43 | /** |
| 44 | 44 | * @psalm-suppress UndefinedMethod |
| 45 | 45 | */ |
@@ -33,11 +33,11 @@ |
||
| 33 | 33 | |
| 34 | 34 | public function handle(object $bindTo, string $source): void |
| 35 | 35 | { |
| 36 | - $cb = function (Payload $payload): void { |
|
| 36 | + $cb = function(Payload $payload): void { |
|
| 37 | 37 | /** |
| 38 | 38 | * @psalm-suppress UndefinedMethod |
| 39 | 39 | */ |
| 40 | - $this->emit('message', [ /** @phpstan-ignore-line */ |
|
| 40 | + $this->emit('message', [/** @phpstan-ignore-line */ |
|
| 41 | 41 | $payload, |
| 42 | 42 | $this, |
| 43 | 43 | ]); |
@@ -65,12 +65,12 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $this->outstandingRpcCalls = new OutstandingCalls(); |
| 67 | 67 | |
| 68 | - $this->connection->on('data', function (string $data): void { |
|
| 68 | + $this->connection->on('data', function(string $data): void { |
|
| 69 | 69 | $this->buffer .= $data; |
| 70 | 70 | $this->emit('data', [$data]); |
| 71 | 71 | $this->handleData(); |
| 72 | 72 | }); |
| 73 | - $this->connection->on('close', function (): void { |
|
| 73 | + $this->connection->on('close', function(): void { |
|
| 74 | 74 | $calls = $this->outstandingRpcCalls->getCalls(); |
| 75 | 75 | if (count($calls) === 0) { |
| 76 | 76 | return; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | public function rpc(Rpc $rpc): PromiseInterface |
| 129 | 129 | { |
| 130 | - $callReference = $this->outstandingRpcCalls->newCall(function (): void {}); // phpcs:disabled |
|
| 130 | + $callReference = $this->outstandingRpcCalls->newCall(function(): void {}); // phpcs:disabled |
|
| 131 | 131 | |
| 132 | 132 | $this->write($this->createLine($rpc->setUniqid($callReference->getUniqid()))); |
| 133 | 133 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * @psalm-suppress InvalidCast |
| 143 | 143 | */ |
| 144 | - return (string) new $lineCLass($line, $this->options['lineOptions']); |
|
| 144 | + return (string)new $lineCLass($line, $this->options['lineOptions']); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public function softTerminate(): PromiseInterface |
@@ -16,10 +16,10 @@ |
||
| 16 | 16 | /** @phpstan-ignore-next-line */ |
| 17 | 17 | private function __construct(Messenger $messenger, LoopInterface $loop) |
| 18 | 18 | { |
| 19 | - $messenger->registerRpc('return', static function (Payload $payload): PromiseInterface { |
|
| 19 | + $messenger->registerRpc('return', static function(Payload $payload): PromiseInterface { |
|
| 20 | 20 | return resolve($payload->getPayload()); |
| 21 | 21 | }); |
| 22 | - $messenger->on('message', static function (Payload $payload) use ($messenger): void { |
|
| 22 | + $messenger->on('message', static function(Payload $payload) use ($messenger): void { |
|
| 23 | 23 | $messenger->message(MessagesFactory::message($payload->getPayload())); |
| 24 | 24 | }); |
| 25 | 25 | } |