From f9b7966495f7d485da937a7be4f18b20a09c045d Mon Sep 17 00:00:00 2001 From: JanHuang <384099566@qq.com> Date: Tue, 27 Oct 2026 17:03:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix(stream):=20=E6=89=93=E5=BC=80=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E7=94=B1=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E8=A7=A6=E5=8F=91=20E=5FWARNING?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Stream/Stream.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stream/Stream.php b/src/Stream/Stream.php index 6ba3cb1..855656c 100644 --- a/src/Stream/Stream.php +++ b/src/Stream/Stream.php @@ -42,7 +42,7 @@ class Stream implements StreamInterface, Stringable */ public function __construct(protected string $stream = 'php://memory', protected string $mode = 'w+b') { - $this->resource = fopen($stream, $this->mode); + $this->resource = @fopen($stream, $this->mode); if (!$this->resource) { throw new RuntimeException("Unable to open stream: $stream with mode: $mode"); From 1f462bfdb471776e45cc0fcede476523301f04b5 Mon Sep 17 00:00:00 2001 From: JanHuang <384099566@qq.com> Date: Tue, 27 Oct 2026 17:06:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?test:=20=E6=98=BE=E5=BC=8F=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E6=97=A0=E6=9C=9F=E6=9C=9B=20mock=EF=BC=8C=E6=B8=85?= =?UTF-8?q?=E7=90=86=20PHPUnit=20notice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/request/SwooleServerRequestTest.php | 3 +++ tests/request/UploadedFileTest.php | 2 ++ 2 files changed, 5 insertions(+) diff --git a/tests/request/SwooleServerRequestTest.php b/tests/request/SwooleServerRequestTest.php index 8594d99..5a73ff1 100644 --- a/tests/request/SwooleServerRequestTest.php +++ b/tests/request/SwooleServerRequestTest.php @@ -5,6 +5,7 @@ use FastD\Http\Request\SwooleServerRequest; use FastD\Http\Request\ServerRequest; use FastD\Http\Stream\Stream; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\TestCase; /** @@ -55,6 +56,7 @@ public function testCanInstantiate() /** * 验证SwooleServerRequest扩展了ServerRequest */ + #[AllowMockObjectsWithoutExpectations] public function testExtendsServerRequest() { // 由于SwooleServerRequest继承自ServerRequest,我们验证继承关系 @@ -149,6 +151,7 @@ public function testInheritedMethods() /** * 测试类的不可变性 - with方法应该返回新实例 */ + #[AllowMockObjectsWithoutExpectations] public function testImmutableWithMethods() { // 创建一个模拟的SwooleServerRequest实例(通过反射绕过Swoole依赖) diff --git a/tests/request/UploadedFileTest.php b/tests/request/UploadedFileTest.php index 40fee53..8475f99 100644 --- a/tests/request/UploadedFileTest.php +++ b/tests/request/UploadedFileTest.php @@ -3,6 +3,7 @@ declare(strict_types=1); use FastD\Http\Request\UploadedFile; +use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations; use PHPUnit\Framework\TestCase; use Psr\Http\Message\StreamInterface; @@ -781,6 +782,7 @@ public function testVariousMediaTypes(): void // ===== 构造函数带Stream测试 ===== + #[AllowMockObjectsWithoutExpectations] public function testConstructorWithProvidedStream(): void { $mockStream = $this->createMock(StreamInterface::class);