Skip to content

Commit

Permalink
Ensure $view is an instance of Stringable
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
koriym committed Nov 20, 2024
1 parent 6a9cbbe commit 4b4f57d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/IntegrateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use BEAR\Streamer\Resource\Page\StreamArray;
use PHPUnit\Framework\TestCase;
use Ray\Di\Injector;
use Stringable;

use function assert;
use function method_exists;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 4b4f57d

Please sign in to comment.