From 805de3f6b0987c3181ceaba028d6ef53aeacfec1 Mon Sep 17 00:00:00 2001 From: Akihito Koriyama Date: Wed, 20 Nov 2024 11:25:34 +0900 Subject: [PATCH] Ensure $view is an instance of Stringable Add an assertion to verify that $view implements the Stringable interface before casting it to a string. This enhances type safety and prevents potential runtime errors. --- tests/IntegrateTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/IntegrateTest.php b/tests/IntegrateTest.php index 61672c9..f2420dd 100644 --- a/tests/IntegrateTest.php +++ b/tests/IntegrateTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Ray\Di\Injector; +use Stringable; use function assert; use function method_exists; use function ob_get_clean; @@ -78,7 +79,8 @@ public function testRender(string $uri, string $expected): void $ro->setRenderer($this->renderer); assert(method_exists($ro, 'onGet')); $view = $ro->onGet(); - $stream = $this->streamer->getStream((string) $view); // @phpstan-ignore-line + assert($view instanceof Stringable); + $stream = $this->streamer->getStream((string) $view); rewind($stream); $view = stream_get_contents($stream); $this->assertSame($expected, $view);