GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Process::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 18
rs 9.9332
cc 2
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace WyriHaximus\React\ChildProcess\Messenger\ChildProcess;
6
7
use React\EventLoop\LoopInterface;
8
use React\Promise\PromiseInterface;
9
use Throwable;
10
use WyriHaximus\React\ChildProcess\Messenger\ChildInterface;
11
use WyriHaximus\React\ChildProcess\Messenger\Factory as MessengerFactory;
12
use WyriHaximus\React\ChildProcess\Messenger\Messages\Payload;
13
use WyriHaximus\React\ChildProcess\Messenger\Messenger;
14
15
use function is_subclass_of;
16
use function React\Promise\resolve;
17
18
final class Process
19
{
20
    private LoopInterface $loop;
21
22
    private Messenger $messenger;
23
24
    private function __construct(LoopInterface $loop, Messenger $messenger)
25
    {
26
        $this->loop      = $loop;
27
        $this->messenger = $messenger;
28
        $this->messenger->registerRpc(
29
            MessengerFactory::PROCESS_REGISTER,
30
            function (Payload $payload): PromiseInterface {
31
                /**
32
                 * @psalm-suppress PossiblyNullArgument
33
                 */
34
                if (! is_subclass_of($payload['className'], ChildInterface::class)) {
35
                    throw DoesNotImplementChildInterfaceException::create($payload['className'] ?? '');
36
                }
37
38
                ($payload['className'])::create($this->messenger, $this->loop);
0 ignored issues
show
Bug introduced by
The method create() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
                ($payload['className'])::/** @scrutinizer ignore-call */ 
39
                                         create($this->messenger, $this->loop);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
                $this->deregisterRpc();
40
41
                return resolve([]);
42
            }
43
        );
44
    }
45
46
    public static function create(LoopInterface $loop, Messenger $messenger): void
47
    {
48
        $reject = static function (Throwable $exeption) use ($loop): void {
0 ignored issues
show
Unused Code introduced by
The parameter $exeption is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

48
        $reject = static function (/** @scrutinizer ignore-unused */ Throwable $exeption) use ($loop): void {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
49
//            $messenger->error(MessagesFactory::error($exeption->getFile()));
50
            $loop->addTimer(1, static function () use ($loop): void {
51
                $loop->stop();
52
            });
53
        };
54
55
        try {
56
            new Process($loop, $messenger);
57
        } catch (Throwable $throwable) { /** @phpstan-ignore-line */
58
            $reject($throwable);
59
        }
60
    }
61
62
    private function deregisterRpc(): void
63
    {
64
        $this->loop->futureTick(function (): void {
65
            $this->messenger->deregisterRpc(MessengerFactory::PROCESS_REGISTER);
66
        });
67
    }
68
}
69