1 | <?php declare(strict_types=1); |
||
14 | final class AsyncClient |
||
15 | { |
||
16 | const DEFAULT_DELAY = 200; |
||
17 | const NO_ACTIVITY_TIMEOUT = 120; |
||
18 | const NO_PING_RESPONSE_TIMEOUT = 30; |
||
19 | |||
20 | /** |
||
21 | * @var Observable |
||
22 | */ |
||
23 | private $messages; |
||
24 | |||
25 | /** |
||
26 | * @var array |
||
27 | */ |
||
28 | private $channels = []; |
||
29 | |||
30 | /** |
||
31 | * @var int |
||
32 | */ |
||
33 | private $delay = self::DEFAULT_DELAY; |
||
34 | |||
35 | /** |
||
36 | * @var Subject |
||
37 | */ |
||
38 | private $client; |
||
39 | |||
40 | /** |
||
41 | * @var Observable |
||
42 | */ |
||
43 | private $connected; |
||
44 | |||
45 | /** |
||
46 | * @internal |
||
47 | * @param Subject $client |
||
48 | * @throws \InvalidArgumentException |
||
49 | */ |
||
50 | 14 | public function __construct(Subject $client) |
|
82 | |||
83 | /** |
||
84 | * @param LoopInterface $loop |
||
85 | * @param string $app Application ID |
||
86 | * @param Resolver $resolver Optional DNS resolver |
||
87 | * @throws \InvalidArgumentException |
||
88 | * @return AsyncClient |
||
89 | */ |
||
90 | public static function create(LoopInterface $loop, string $app, Resolver $resolver = null): AsyncClient |
||
91 | { |
||
92 | try { |
||
93 | 4 | Scheduler::setDefaultFactory(function () use ($loop) { |
|
94 | 3 | return new Scheduler\EventLoopScheduler($loop); |
|
|
|||
95 | 4 | }); |
|
96 | 2 | } catch (Throwable $t) { |
|
97 | } |
||
98 | |||
99 | 4 | return new self( |
|
100 | 4 | new WebSocket(ApiSettings::createUrl($app), false, [], $loop, $resolver) |
|
101 | ); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Listen on a channel. |
||
106 | * |
||
107 | * @param string $channel Channel to listen on |
||
108 | * @throws \InvalidArgumentException |
||
109 | * @return Observable |
||
110 | */ |
||
111 | 11 | public function channel(string $channel): Observable |
|
146 | |||
147 | /** |
||
148 | * Send a message through the client. |
||
149 | * |
||
150 | * @param array $message Message to send, will be json encoded |
||
151 | * |
||
152 | */ |
||
153 | 11 | public function send(array $message) |
|
157 | |||
158 | /** |
||
159 | * Returns an observable of TimeoutException. |
||
160 | * The timeout observable will get cancelled every time a new event is received. |
||
161 | * |
||
162 | * @param Observable $events |
||
163 | * @return Observable |
||
164 | */ |
||
165 | public function timeout(Observable $events): Observable |
||
193 | |||
194 | /** |
||
195 | * Handle errors as described at https://pusher.com/docs/pusher_protocol#error-codes. |
||
196 | * @param Throwable $throwable |
||
197 | * @return Observable |
||
198 | */ |
||
199 | 4 | private function handleLowLevelError(Throwable $throwable): Observable |
|
232 | } |
||
233 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: