Skip to content

Commit 1055c12

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

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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 static function register(): void
11+
{
12+
\stream_wrapper_register('dummy', self::class);
13+
}
14+
15+
public function stream_open(string $path, string $mode, int $options, ?string &$opened_path): bool
16+
{
17+
$options = \stream_context_get_options($this->context);
18+
var_dump($options['dummy']['foo']);
19+
20+
return true;
21+
}
22+
23+
public function stream_stat()
24+
{
25+
}
26+
27+
public function stream_read()
28+
{
29+
}
30+
31+
public function stream_eof()
32+
{
33+
}
34+
}
35+
36+
DummyWrapper::register();
37+
\file_get_contents('dummy://foo', false, \stream_context_create(['dummy' => ['foo' => 'bar']]));
38+
\file_get_contents('php://filter/resource=dummy://foo', false, \stream_context_create(['dummy' => ['foo' => 'bar']]));
39+
?>
40+
--EXPECT--
41+
string(288) "bar"
42+
string(288) "bar"

0 commit comments

Comments
 (0)