Skip to content

Commit ce9eea3

Browse files
committed
Fix set_stream_options arguments
1 parent 76e0c5f commit ce9eea3

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/VCR/Util/StreamProcessor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -493,14 +493,14 @@ public function stream_lock(int $operation): bool
493493
*
494494
* @codeCoverageIgnore
495495
*
496-
* @param int $option one of STREAM_OPTION_BLOCKING, STREAM_OPTION_READ_TIMEOUT, STREAM_OPTION_WRITE_BUFFER
497-
* @param int $arg1 depending on option
498-
* @param int $arg2 depending on option
496+
* @param int $option one of STREAM_OPTION_BLOCKING, STREAM_OPTION_READ_TIMEOUT, STREAM_OPTION_WRITE_BUFFER
497+
* @param int $arg1 depending on option
498+
* @param int|null $arg2 depending on option
499499
*
500500
* @return bool Returns TRUE on success or FALSE on failure. If option is not implemented,
501501
* FALSE should be returned.
502502
*/
503-
public function stream_set_option(int $option, int $arg1, int $arg2): bool
503+
public function stream_set_option(int $option, int $arg1, ?int $arg2 = null): bool
504504
{
505505
if (false === $this->resource) {
506506
return false;

tests/Unit/Util/StreamProcessorTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ public function testFlockWithFilePutContents(): void
2727
$this->assertEquals(\strlen($testData), $res);
2828
}
2929

30+
public function testSetStreamOptions(): void
31+
{
32+
$processor = new StreamProcessor();
33+
$processor->intercept();
34+
35+
$handle = fopen('tests/fixtures/file_put_contents', 'w');
36+
37+
self::assertTrue(stream_set_blocking($handle, true));
38+
self::assertFalse(stream_set_timeout($handle, 10));
39+
self::assertFalse(stream_set_timeout($handle, 5, 2));
40+
self::assertSame(-1, stream_set_write_buffer($handle, 0));
41+
self::assertSame(0, stream_set_read_buffer($handle, 0));
42+
43+
fclose($handle);
44+
45+
$processor->restore();
46+
}
47+
3048
/**
3149
* @dataProvider streamOpenAppendFilterProvider
3250
*/

0 commit comments

Comments
 (0)