1 | <?php |
||
6 | abstract class Socket implements TransportInterface |
||
7 | { |
||
8 | |||
9 | /** |
||
10 | * @var resource|null|false |
||
11 | */ |
||
12 | protected $socket; |
||
13 | |||
14 | /** @var string - udp:// tcp:// */ |
||
15 | protected $socketPrefix = ''; |
||
16 | |||
17 | protected $errorNumber = 0; |
||
18 | protected $errorMessage = ''; |
||
19 | |||
20 | /** @var Writer */ |
||
21 | protected $writer; |
||
22 | |||
23 | public function __construct(Writer $writer = null) |
||
27 | |||
28 | /** |
||
29 | * @param string $address |
||
30 | * @param int $port |
||
31 | * @param array $options |
||
32 | * |
||
33 | * @return TransportInterface |
||
34 | */ |
||
35 | public function connect(string $address, int $port = 0, array $options = []): TransportInterface |
||
43 | |||
44 | /** |
||
45 | * @param string $buffer |
||
46 | * @param int|null $length - записать число байт в сокет |
||
47 | * |
||
48 | * @return false|int число записанных байт или false |
||
49 | */ |
||
50 | public function write(string $buffer, int $length = null): int |
||
54 | |||
55 | public function isConnected(): bool |
||
59 | |||
60 | public function close(): void |
||
65 | } |
||
66 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.