From ee8f12c0af759eed9834e322e7457825c8bdaeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Mon, 1 Feb 2021 08:36:17 +0100 Subject: [PATCH] Socket address of closed socket should be null (support PHP 8) Refs https://github.com/reactphp/socket/pull/246 --- .github/workflows/ci.yml | 1 + README.md | 2 +- src/Socket.php | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d321f38..cf214c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ jobs: strategy: matrix: php: + - 8.0 - 7.4 - 7.3 - 7.2 diff --git a/README.md b/README.md index 159459d..b0eaf30 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ $ composer require react/datagram:^1.5 See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. This project aims to run on any platform and thus does not require any PHP -extensions and supports running on legacy PHP 5.3 through current PHP 7+ and +extensions and supports running on legacy PHP 5.3 through current PHP 8+ and HHVM. It's *highly recommended to use PHP 7+* for this project. diff --git a/src/Socket.php b/src/Socket.php index 8a1d294..e06723c 100644 --- a/src/Socket.php +++ b/src/Socket.php @@ -36,11 +36,19 @@ public function __construct(LoopInterface $loop, $socket, Buffer $buffer = null) public function getLocalAddress() { + if ($this->socket === false) { + return null; + } + return $this->sanitizeAddress(@\stream_socket_get_name($this->socket, false)); } public function getRemoteAddress() { + if ($this->socket === false) { + return null; + } + return $this->sanitizeAddress(@\stream_socket_get_name($this->socket, true)); }