@@ -13,7 +13,7 @@ class Socket
1313 /**
1414 * reference to actual socket resource
1515 *
16- * @var resource
16+ * @var \Socket| resource
1717 */
1818 private $ resource ;
1919
@@ -22,7 +22,7 @@ class Socket
2222 *
2323 * should usually not be called manually, see Factory
2424 *
25- * @param resource $resource
25+ * @param \Socket| resource $resource
2626 * @see Factory as the preferred (and simplest) way to construct socket instances
2727 */
2828 public function __construct ($ resource )
@@ -33,7 +33,7 @@ public function __construct($resource)
3333 /**
3434 * get actual socket resource
3535 *
36- * @return resource
36+ * @return \Socket| resource returns the socket resource (a `Socket` object as of PHP 8)
3737 */
3838 public function getResource ()
3939 {
@@ -45,6 +45,7 @@ public function getResource()
4545 *
4646 * @return \Socket\Raw\Socket new connected socket used for communication
4747 * @throws Exception on error, if this is not a listening socket or there's no connection pending
48+ * @throws \Error PHP 8 only: throws \Error when socket is invalid
4849 * @see self::selectRead() to check if this listening socket can accept()
4950 * @see Factory::createServer() to create a listening socket
5051 * @see self::listen() has to be called first
@@ -67,6 +68,7 @@ public function accept()
6768 * @param string $address either of IPv4:port, hostname:port, [IPv6]:port, unix-path
6869 * @return self $this (chainable)
6970 * @throws Exception on error
71+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
7072 * @uses socket_bind()
7173 */
7274 public function bind ($ address )
@@ -85,6 +87,7 @@ public function bind($address)
8587 * its socket resource remains closed and most further operations will fail!
8688 *
8789 * @return self $this (chainable)
90+ * @throws \Error PHP 8 only: throws \Error when socket is invalid
8891 * @see self::shutdown() should be called before closing socket
8992 * @uses socket_close()
9093 */
@@ -100,6 +103,7 @@ public function close()
100103 * @param string $address either of IPv4:port, hostname:port, [IPv6]:port, unix-path
101104 * @return self $this (chainable)
102105 * @throws Exception on error
106+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
103107 * @uses socket_connect()
104108 */
105109 public function connect ($ address )
@@ -126,6 +130,7 @@ public function connect($address)
126130 * @param float $timeout maximum time to wait (in seconds)
127131 * @return self $this (chainable)
128132 * @throws Exception on error
133+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
129134 * @uses self::setBlocking() to enable non-blocking mode
130135 * @uses self::connect() to initiate the connection
131136 * @uses self::selectWrite() to wait for the connection to complete
@@ -166,6 +171,7 @@ public function connectTimeout($address, $timeout)
166171 * @param int $optname
167172 * @return mixed
168173 * @throws Exception on error
174+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
169175 * @uses socket_get_option()
170176 */
171177 public function getOption ($ level , $ optname )
@@ -182,6 +188,7 @@ public function getOption($level, $optname)
182188 *
183189 * @return string
184190 * @throws Exception on error
191+ * @throws \Error PHP 8 only: throws \Error when socket is invalid
185192 * @uses socket_getpeername()
186193 */
187194 public function getPeerName ()
@@ -198,6 +205,7 @@ public function getPeerName()
198205 *
199206 * @return string
200207 * @throws Exception on error
208+ * @throws \Error PHP 8 only: throws \Error when socket is invalid
201209 * @uses socket_getsockname()
202210 */
203211 public function getSockName ()
@@ -215,6 +223,7 @@ public function getSockName()
215223 * @param int $backlog maximum number of incoming connections to be queued
216224 * @return self $this (chainable)
217225 * @throws Exception on error
226+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
218227 * @see self::bind() has to be called first to bind name to socket
219228 * @uses socket_listen()
220229 */
@@ -237,6 +246,7 @@ public function listen($backlog = 0)
237246 * @param int $type either of PHP_BINARY_READ (the default) or PHP_NORMAL_READ
238247 * @return string
239248 * @throws Exception on error
249+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
240250 * @see self::recv() if you need to pass flags
241251 * @uses socket_read()
242252 */
@@ -256,6 +266,7 @@ public function read($length, $type = PHP_BINARY_READ)
256266 * @param int $flags
257267 * @return string
258268 * @throws Exception on error
269+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
259270 * @see self::read() if you do not need to pass $flags
260271 * @see self::recvFrom() if your socket is not connect()ed
261272 * @uses socket_recv()
@@ -277,6 +288,7 @@ public function recv($length, $flags)
277288 * @param string $remote reference will be filled with remote/peer address/path
278289 * @return string
279290 * @throws Exception on error
291+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
280292 * @see self::recv() if your socket is connect()ed
281293 * @uses socket_recvfrom()
282294 */
@@ -296,6 +308,7 @@ public function recvFrom($length, $flags, &$remote)
296308 * @param float|NULL $sec maximum time to wait (in seconds), 0 = immediate polling, null = no limit
297309 * @return boolean true = socket ready (read will not block), false = timeout expired, socket is not ready
298310 * @throws Exception on error
311+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
299312 * @uses socket_select()
300313 */
301314 public function selectRead ($ sec = 0 )
@@ -315,6 +328,7 @@ public function selectRead($sec = 0)
315328 * @param float|NULL $sec maximum time to wait (in seconds), 0 = immediate polling, null = no limit
316329 * @return boolean true = socket ready (write will not block), false = timeout expired, socket is not ready
317330 * @throws Exception on error
331+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
318332 * @uses socket_select()
319333 */
320334 public function selectWrite ($ sec = 0 )
@@ -335,6 +349,7 @@ public function selectWrite($sec = 0)
335349 * @param int $flags
336350 * @return int number of bytes actually written (make sure to check against given buffer length!)
337351 * @throws Exception on error
352+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
338353 * @see self::write() if you do not need to pass $flags
339354 * @see self::sendTo() if your socket is not connect()ed
340355 * @uses socket_send()
@@ -356,6 +371,7 @@ public function send($buffer, $flags)
356371 * @param string $remote remote/peer address/path
357372 * @return int number of bytes actually written
358373 * @throws Exception on error
374+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
359375 * @see self::send() if your socket is connect()ed
360376 * @uses socket_sendto()
361377 */
@@ -374,6 +390,7 @@ public function sendTo($buffer, $flags, $remote)
374390 * @param boolean $toggle
375391 * @return self $this (chainable)
376392 * @throws Exception on error
393+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
377394 * @uses socket_set_block()
378395 * @uses socket_set_nonblock()
379396 */
@@ -394,6 +411,7 @@ public function setBlocking($toggle = true)
394411 * @param mixed $optval
395412 * @return self $this (chainable)
396413 * @throws Exception on error
414+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
397415 * @see self::getOption()
398416 * @uses socket_set_option()
399417 */
@@ -412,6 +430,7 @@ public function setOption($level, $optname, $optval)
412430 * @param int $how 0 = shutdown reading, 1 = shutdown writing, 2 = shutdown reading and writing
413431 * @return self $this (chainable)
414432 * @throws Exception on error
433+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
415434 * @see self::close()
416435 * @uses socket_shutdown()
417436 */
@@ -430,6 +449,7 @@ public function shutdown($how = 2)
430449 * @param string $buffer
431450 * @return int number of bytes actually written
432451 * @throws Exception on error
452+ * @throws \Error PHP 8 only: throws \Error when socket or arguments are invalid
433453 * @see self::send() if you need to pass flags
434454 * @uses socket_write()
435455 */
@@ -447,6 +467,7 @@ public function write($buffer)
447467 *
448468 * @return int usually either SOCK_STREAM or SOCK_DGRAM
449469 * @throws Exception on error
470+ * @throws \Error PHP 8 only: throws \Error when socket is invalid
450471 * @uses self::getOption()
451472 */
452473 public function getType ()
@@ -469,6 +490,7 @@ public function getType()
469490 *
470491 * @return self $this (chainable)
471492 * @throws Exception if error code is not 0
493+ * @throws \Error PHP 8 only: throws \Error when socket is invalid
472494 * @uses self::getOption() to retrieve and clear current error code
473495 * @uses self::getErrorMessage() to translate error code to
474496 */
0 commit comments