1 | <?php |
||
12 | class SocketError extends RuntimeException { |
||
13 | |||
14 | /** |
||
15 | * Extra data, if any. The specific contents are documented where the error is thrown. |
||
16 | * |
||
17 | * @var mixed |
||
18 | */ |
||
19 | protected $extra; |
||
20 | |||
21 | /** |
||
22 | * Retrieves and clears the socket error. |
||
23 | * For resources, this favors `SO_ERROR`, then falls back to the error number set by PHP. |
||
24 | * Both error codes are cleared. |
||
25 | * |
||
26 | * @see https://php.net/socket_last_error |
||
27 | * @see https://php.net/socket_clear_error |
||
28 | * |
||
29 | * @param resource $resource PHP socket resource, or `null` for the global error. |
||
30 | * @return int If the resource is closed or not a socket, `SOCKET_EBADF` is returned. |
||
31 | */ |
||
32 | public static function getLast ($resource = null) { |
||
48 | |||
49 | /** |
||
50 | * Initializes the error based on a mixed subject. |
||
51 | * |
||
52 | * PHP's core socket functions like to return `false` without setting `errno` in some places. |
||
53 | * |
||
54 | * To account for that scenario, a fallback code can be given. |
||
55 | * |
||
56 | * When the fallback code is used, PHP's last suppressed warning message is used. |
||
57 | * |
||
58 | * All scenarios within this library have been meticulously cross-checked with the PHP C source code |
||
59 | * for cases where a fallback code is necessary. |
||
60 | * |
||
61 | * @param int|resource|null $subject Error constant, resource to check, or `NULL` to use the global socket error. |
||
62 | * @param int $fallback Code to assume if one can't be found via the subject. |
||
63 | * @param SocketError|null $previous Slippage of a prior error. |
||
64 | */ |
||
65 | public function __construct ($subject = null, $fallback = 0, SocketError $previous = null) { |
||
76 | |||
77 | /** |
||
78 | * @return mixed |
||
79 | */ |
||
80 | public function getExtra () { |
||
83 | |||
84 | /** |
||
85 | * @param mixed $extra |
||
86 | * @return $this |
||
87 | */ |
||
88 | public function setExtra ($extra) { |
||
92 | |||
93 | } |
||
94 |