8000 Add stream_set_option method with required structure. But without rea… · symfony/symfony@1e94e73 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1e94e73

Browse files
committed
Add stream_set_option method with required structure. But without real implementations
1 parent a6d1567 commit 1e94e73

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

src/Symfony/Component/HttpClient/Response/StreamWrapper.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,56 @@ public function stream_read(int $count)
178178
return '';
179179
}
180180

181+
public function stream_set_option(int $option, int $arg1, ?int $arg2): bool
182+
{
183+
if (null === $this->handle || 'stream' !== get_resource_type($this->handle)) {
184+
trigger_error(sprintf('The "$handle" property of "%s" need to be a stream.', __CLASS__), E_USER_WARNING);
185+
186+
return false;
187+
}
188+
189+
switch ($option) {
190+
case STREAM_OPTION_BLOCKING:
191+
return $this->stream_set_blocking($this->handle, $arg1);
192+
break;
193+
case STREAM_OPTION_READ_TIMEOUT:
194+
return $this->stream_set_timeout($this->handle, $arg1, $arg2);
195+
break;
196+
case STREAM_OPTION_WRITE_BUFFER:
197+
return $this->stream_set_write_buffer($this->handle, $arg1);
198+
break;
199+
default:
200+
trigger_error(sprintf('The option "%s" is unknown for "stream_set_option" method', $option), E_USER_WARNING);
201+
202+
return false;
203+
}
204+
}
205+
206+
public function stream_set_blocking($stream, bool $mode): bool
207+
{
208+
if (true === $mode) {
209+
trigger_error(sprintf('Blocking mode is not supported yet with "%s" class.', __CLASS__), E_USER_WARNING);
210+
211+
return false;
212+
}
213+
214+
return true;
215+
}
216+
217+
public function stream_set_write_buffer($stream, int $buffer): int
218+
{
219+
trigger_error(sprintf('Writting with "%s" class, is not supported yet.', __CLASS__), E_USER_WARNING);
220+
221+
return false;
222+
}
223+
224+
public function stream_set_timeout($stream, int $seconds, int $microseconds = 0): bool
225+
{
226+
trigger_error(sprintf('Set timeout with "%s" class, is not supported yet.', __CLASS__), E_USER_WARNING);
227+
228+
return false;
229+
}
230+
181231
public function stream_tell(): int
182232
{
183233
return $this->offset;

0 commit comments

Comments
 (0)
0