1--TEST--
2stream userfilter test
3--FILE--
4<?php
5
6class testfilter extends php_user_filter {
7  function filter($in, $out, &$consumed, $closing) {
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() {
17    echo "params: {$this->params}\n";
18  }
19}
20
21stream_filter_register('testfilter','testfilter');
22
23$text = "Hello There!";
24
25$fp = tmpfile();
26fwrite($fp, $text);
27
28rewind($fp);
29stream_filter_append($fp, 'testfilter', STREAM_FILTER_READ, 'testuserfilter');
30
31var_dump(fgets($fp));
32fclose($fp);
33
34?>
35--EXPECT--
36params: testuserfilter
37string(12) "HELLO THERE!"
38