Skip to content

Commit b0b23c7

Browse files
committed
Stream now throws a RuntimeException.
See http-interop/http-factory-tests@c29f9c5 Signed-off-by: ADmad <[email protected]>
1 parent e104115 commit b0b23c7

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/Exception/RuntimeException.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
/**
4+
* @see https://github.com/laminas/laminas-diactoros for the canonical source repository
5+
* @copyright https://github.com/laminas/laminas-diactoros/blob/master/COPYRIGHT.md
6+
* @license https://github.com/laminas/laminas-diactoros/blob/master/LICENSE.md New BSD License
7+
*/
8+
9+
declare(strict_types=1);
10+
11+
namespace Laminas\Diactoros\Exception;
12+
13+
class RuntimeException extends \RuntimeException implements ExceptionInterface
14+
{
15+
}

src/Stream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ private function setStream($stream, string $mode = 'r') : void
347347
}
348348

349349
if ($error) {
350-
throw new Exception\InvalidArgumentException('Invalid stream reference provided');
350+
throw new Exception\RuntimeException('Invalid stream reference provided');
351351
}
352352

353353
if (! $this->isValidStreamResourceType($resource)) {

test/StreamTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,6 @@ public function invalidResources()
477477
'true' => [ true ],
478478
'int' => [ 1 ],
479479
'float' => [ 1.1 ],
480-
'string-non-resource' => [ 'foo-bar-baz' ],
481480
'array' => [ [ fopen($this->tmpnam, 'r+') ] ],
482481
'object' => [ (object) [ 'resource' => fopen($this->tmpnam, 'r+') ] ],
483482
];
@@ -494,6 +493,14 @@ public function testAttachWithNonStringNonResourceRaisesException($resource)
494493
$this->stream->attach($resource);
495494
}
496495

496+
public function testAttachWithInvalidStringResourceRaisesException()
497+
{
498+
$this->expectException(\RuntimeException::class);
499+
$this->expectExceptionMessage('Invalid stream');
500+
501+
$this->stream->attach('foo-bar-baz');
502+
}
503+
497504
public function testAttachWithResourceAttachesResource()
498505
{
499506
$this->tmpnam = tempnam(sys_get_temp_dir(), 'diac');

0 commit comments

Comments
 (0)