Skip to content

Commit f0319b5

Browse files
committed
test: keep context in filtered streams
1 parent 8fbdf98 commit f0319b5

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
GH-15155: Stream context is lost when custom stream wrapper is being filtered
3+
--FILE--
4+
<?php
5+
6+
class DummyWrapper
7+
{
8+
public $context;
9+
10+
public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool
11+
{
12+
$options = stream_context_get_options($this->context);
13+
var_dump($options['dummy']['foo']);
14+
return true;
15+
}
16+
17+
public function stream_stat()
18+
{
19+
}
20+
21+
public function stream_read()
22+
{
23+
}
24+
25+
public function stream_eof()
26+
{
27+
}
28+
}
29+
30+
$context = stream_context_create(['dummy' => ['foo' => 'bar']]);
31+
stream_wrapper_register('dummy', DummyWrapper::class);
32+
file_get_contents('dummy://foo', false, $context);
33+
@file_get_contents('php://filter/resource=dummy://foo', false, $context);
34+
?>
35+
--EXPECT--
36+
string(3) "bar"
37+
string(3) "bar"

0 commit comments

Comments
 (0)