/hphp/test/slow/streams/user_filter_autoload.php
PHP | 22 lines | 19 code | 3 blank | 0 comment | 1 complexity | 8b487399ca98c9ee44712c1ed7917996 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause, LGPL-2.0, LGPL-2.1
- <?php
- spl_autoload_register(function ($class) {
- printf("loading\n");
- class TestFilter extends php_user_filter {
- public function filter($in, $out, &$consumed, $closing) {
- printf("filtering\n");
- while ($bucket = stream_bucket_make_writeable($in)) {
- $bucket->data = strtoupper($bucket->data);
- $consumed += $bucket->datalen;
- stream_bucket_append($out, $bucket);
- }
- return PSFS_PASS_ON;
- }
- }
- }, true, false);
- stream_filter_register('test_filter', '\TestFilter');
- $stream = fopen('php://memory', 'r+');
- stream_filter_append($stream, 'test_filter', STREAM_FILTER_WRITE);
- fwrite($stream, "data");