From dd1ba1de1234e5e8939809bbd9e103e7aeebf0d5 Mon Sep 17 00:00:00 2001 From: Tracerneo <660285+Tracerneo@users.noreply.github.com> Date: Sun, 26 May 2019 14:43:51 +0200 Subject: [PATCH] Change minimal port number to 0 (unix socket) (#270) --- src/Uri.php | 4 ++-- tests/UriTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Uri.php b/src/Uri.php index 2085ab73..825a25ee 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -628,9 +628,9 @@ private function filterPort($port) } $port = (int) $port; - if (1 > $port || 0xffff < $port) { + if (0 > $port || 0xffff < $port) { throw new \InvalidArgumentException( - sprintf('Invalid port: %d. Must be between 1 and 65535', $port) + sprintf('Invalid port: %d. Must be between 0 and 65535', $port) ); } diff --git a/tests/UriTest.php b/tests/UriTest.php index 8a9141eb..b9fb7e81 100644 --- a/tests/UriTest.php +++ b/tests/UriTest.php @@ -117,7 +117,7 @@ public function getInvalidUris() /** * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid port: 100000. Must be between 1 and 65535 + * @expectedExceptionMessage Invalid port: 100000. Must be between 0 and 65535 */ public function testPortMustBeValid() { @@ -126,11 +126,11 @@ public function testPortMustBeValid() /** * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid port: 0. Must be between 1 and 65535 + * @expectedExceptionMessage Invalid port: -1. Must be between 0 and 65535 */ - public function testWithPortCannotBeZero() + public function testWithPortCannotBeNegative() { - (new Uri())->withPort(0); + (new Uri())->withPort(-1); } /**