Skip to content

Commit 0c93bbf

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

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,28 @@ 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+
case STREAM_OPTION_READ_TIMEOUT:
193+
return $this->stream_set_timeout($this->handle, $arg1, $arg2);
194+
case STREAM_OPTION_WRITE_BUFFER:
195+
return $this->stream_set_write_buffer($this->handle, $arg1);
196+
default:
197+
trigger_error(sprintf('The option "%s" is unknown for "stream_set_option" method', $option), E_ERROR);
198+
199+
return false;
200+
}
201+
}
202+
181203
public function stream_tell(): int
182204
{
183205
return $this->offset;
@@ -270,6 +292,31 @@ public function stream_stat(): array
270292
];
271293
}
272294

295+
private function stream_set_blocking($stream, bool $mode): bool
296+
{
297+
if (true === $mode) {
298+
trigger_error(sprintf('Blocking mode is not supported yet with "%s" class.', __CLASS__), E_USER_WARNING);
299+
300+
return false;
301+
}
302+
303+
return true;
304+
}
305+
306+
private function stream_set_write_buffer($stream, int $buffer): int
307+
{
308+
trigger_error(sprintf('Writting with "%s" class, is not supported yet.', __CLASS__), E_USER_WARNING);
309+
310+
return false;
311+
}
312+
313+
private function stream_set_timeout($stream, int $seconds, int $microseconds = 0): bool
314+
{
315+
trigger_error(sprintf('Set timeout with "%s" class, is not supported yet.', __CLASS__), E_USER_WARNING);
316+
317+
return false;
318+
}
319+
273320
private function __construct()
274321
{
275322
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy