@@ -13,14 +13,19 @@ abstract class AbstractCodeTransform extends \php_user_filter
1313{
1414 public  const  NAME  = 'vcr_abstract_filter ' ;
1515
16+  private  string  $ data'' ;
17+ 
1618 /** 
1719 * Attaches the current filter to a stream. 
1820 */ 
1921 public  function  register (): void 
2022 {
2123 if  (!\in_array (static ::NAME , stream_get_filters (), true )) {
2224 $ isRegisteredstream_filter_register (static ::NAME , static ::class);
23-  Assertion::true ($ isRegisteredsprintf ('Failed registering stream filter "%s" on stream "%s" ' , static ::class, static ::NAME ));
25+  Assertion::true (
26+  $ isRegistered
27+  sprintf ('Failed registering stream filter "%s" on stream "%s" ' , static ::class, static ::NAME )
28+  );
2429 }
2530 }
2631
@@ -30,20 +35,26 @@ public function register(): void
3035 * @param resource $in 
3136 * @param resource $out 
3237 * @param int $consumed 
33-  * @param bool $closing 
3438 * 
3539 * @return int PSFS_PASS_ON 
3640 * 
3741 * @see http://www.php.net/manual/en/php-user-filter.filter.php 
3842 */ 
39-  public  function  filter ($ in$ out$ consumed$ closingint 
43+  public  function  filter ($ in$ out$ consumedbool   $ closingint 
4044 {
41-  while  ($ bucketstream_bucket_make_writeable ($ in
42-  $ bucketdata  = $ this transformCode ($ bucketdata );
43-  $ consumed$ bucketdatalen ;
44-  stream_bucket_append ($ out$ bucket
45+  while  ($ bufferstream_bucket_make_writeable ($ in
46+  $ this data  .= $ bufferdata ;
47+  $ consumed$ bufferdatalen ;
48+  }
49+ 
50+  if  (!$ closing
51+  return  \PSFS_FEED_ME ;
4552 }
4653
54+  $ bucketstream_bucket_new ($ this stream , $ this transformCode ($ this data ));
55+  $ this data  = '' ;
56+  stream_bucket_append ($ out$ bucket
57+ 
4758 return  \PSFS_PASS_ON ;
4859 }
4960
0 commit comments