From 5456f35439c3117005b34bb1b3751880d39321fb Mon Sep 17 00:00:00 2001 From: Kurt Thiemann Date: Tue, 19 Nov 2024 13:51:57 +0100 Subject: [PATCH] fix notices in tests --- phpunit.xml | 2 ++ src/Psr7/Stream/Stream.php | 4 ++-- src/Psr7/Uri.php | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 165b475..c7930e9 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -10,6 +10,8 @@ beStrictAboutOutputDuringTests="true" displayDetailsOnPhpunitDeprecations="true" failOnPhpunitDeprecation="true" + displayDetailsOnTestsThatTriggerNotices="true" + displayDetailsOnTestsThatTriggerDeprecations="true" failOnRisky="true" failOnWarning="true"> diff --git a/src/Psr7/Stream/Stream.php b/src/Psr7/Stream/Stream.php index 54fbc87..a51dc71 100644 --- a/src/Psr7/Stream/Stream.php +++ b/src/Psr7/Stream/Stream.php @@ -172,7 +172,7 @@ public function write(string $string): int if (!$this->isWritable()) { throw new RuntimeException("Stream is not writable"); } - $result = fwrite($this->resource, $string); + $result = @fwrite($this->resource, $string); if ($result === false) { throw new RuntimeException("Failed to write to stream"); } @@ -198,7 +198,7 @@ public function read(int $length): string if ($length <= 0) { return ""; } - $result = fread($this->resource, $length); + $result = @fread($this->resource, $length); if ($result === false) { throw new RuntimeException("Failed to read from stream"); } diff --git a/src/Psr7/Uri.php b/src/Psr7/Uri.php index 0c42271..7c73bb1 100644 --- a/src/Psr7/Uri.php +++ b/src/Psr7/Uri.php @@ -139,7 +139,7 @@ protected function setUserInfo(string $user, ?string $password): void } $this->user = $this->encode($user, $pattern); - if ($password === null && strlen($password) === 0) { + if ($password === null || strlen($password) === 0) { $this->password = null; return; } @@ -330,7 +330,7 @@ public function withUserInfo(string $user, ?string $password = null): UriInterfa return $this; } - if (strlen($password) === 0) { + if ($password === null || strlen($password) === 0) { $password = null; }