1--TEST--
2stream userfilter test
3--FILE--
4<?php
5
6class testfilter extends php_user_filter {
7  function filter($in, $out, &$consumed, $closing): int {
8    while ($bucket = stream_bucket_make_writeable($in)) {
9      $bucket->data = strtoupper($bucket->data);
10      $consumed += strlen($bucket->data);
11      stream_bucket_append($out, $bucket);
12    }
13    return PSFS_PASS_ON;
14  }
15
16  function oncreate(): bool {
17    echo "params: {$this->params}\n";
18    return true;
19  }
20}
21
22stream_filter_register('testfilter','testfilter');
23
24$text = "Hello There!";
25
26$fp = tmpfile();
27fwrite($fp, $text);
28
29rewind($fp);
30stream_filter_append($fp, 'testfilter', STREAM_FILTER_READ, 'testuserfilter');
31
32var_dump(fgets($fp));
33fclose($fp);
34
35?>
36--EXPECT--
37params: testuserfilter
38string(12) "HELLO THERE!"
39