1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace WyriHaximus\React\ChildProcess\Messenger\Messages; |
||
6 | |||
7 | use JsonSerializable; |
||
8 | use Throwable; |
||
9 | |||
10 | use function WyriHaximus\throwable_encode; |
||
11 | |||
12 | final class Error implements JsonSerializable, ActionableMessageInterface |
||
13 | { |
||
14 | protected Throwable $payload; |
||
15 | |||
16 | public function __construct(Throwable $payload) |
||
17 | { |
||
18 | 3 | $this->payload = $payload; |
|
19 | } |
||
20 | 3 | ||
21 | 3 | public function getPayload(): Throwable |
|
22 | { |
||
23 | return $this->payload; |
||
24 | } |
||
25 | |||
26 | 2 | /** |
|
27 | * @return array<string,string|array<mixed>> |
||
28 | 2 | */ |
|
29 | public function jsonSerialize(): array |
||
30 | { |
||
31 | return [ |
||
32 | 'type' => 'error', |
||
33 | 'payload' => throwable_encode($this->payload), |
||
34 | 2 | ]; |
|
35 | } |
||
36 | |||
37 | 2 | public function handle(object $bindTo, string $source): void |
|
38 | 2 | { |
|
39 | $cb = function (Throwable $payload): void { |
||
40 | /** |
||
41 | * @psalm-suppress UndefinedMethod |
||
42 | */ |
||
43 | $this->emit('error', [ /** @phpstan-ignore-line */ |
||
0 ignored issues
–
show
|
|||
44 | $payload, |
||
45 | $this, |
||
46 | ]); |
||
47 | }; |
||
48 | 1 | $cb = $cb->bindTo($bindTo); |
|
49 | 1 | /** |
|
50 | 1 | * @psalm-suppress PossiblyInvalidFunctionCall |
|
51 | 1 | */ |
|
52 | $cb($this->payload); |
||
53 | 1 | } |
|
54 | } |
||
55 |
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.