1 | <?php |
||||
2 | |||||
3 | require \dirname(\dirname(__DIR__)) . '/vendor/autoload.php'; |
||||
4 | |||||
5 | use React\EventLoop\Factory; |
||||
6 | use WyriHaximus\React\ChildProcess\Messenger\Factory as MessengerFactory; |
||||
7 | use WyriHaximus\React\ChildProcess\Messenger\Messages\Factory as MessageFactory; |
||||
8 | use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload; |
||||
9 | use WyriHaximus\React\ChildProcess\Messenger\Messenger; |
||||
10 | |||||
11 | $loop = Factory::create(); |
||||
0 ignored issues
–
show
|
|||||
12 | |||||
13 | $prime = isset($argv[1]) ? (int)$argv[1] : \mt_rand(1, 1337); |
||||
14 | |||||
15 | echo 'Checking if ', $prime, ' is a prime or not', PHP_EOL; |
||||
16 | |||||
17 | MessengerFactory::parentFromClass(ExamplesChildProcess::class, $loop)->then(function (Messenger $messenger) use ($prime) { |
||||
18 | return $messenger->rpc( |
||||
19 | MessageFactory::rpc('isPrime', ['number' => $prime]) |
||||
20 | )->always(function () use ($messenger) { |
||||
0 ignored issues
–
show
The method
always() does not exist on React\Promise\PromiseInterface . It seems like you code against a sub-type of said class. However, the method does not exist in React\Promise\CancellablePromiseInterface . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
21 | $messenger->softTerminate(); |
||||
22 | }); |
||||
23 | })->done(function (Payload $result) { |
||||
24 | if ($result['isPrime']) { |
||||
25 | echo 'Prime', PHP_EOL; |
||||
26 | |||||
27 | return; |
||||
28 | } |
||||
29 | |||||
30 | echo 'Not a prime', PHP_EOL; |
||||
31 | }); |
||||
32 | |||||
33 | $loop->run(); |
||||
34 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.