當前位置: 首頁>>代碼示例>>PHP>>正文


PHP stream_bucket_new函數代碼示例

本文整理匯總了PHP中stream_bucket_new函數的典型用法代碼示例。如果您正苦於以下問題:PHP stream_bucket_new函數的具體用法?PHP stream_bucket_new怎麽用?PHP stream_bucket_new使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了stream_bucket_new函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: filter

 public function filter($in, $out, &$consumed, $closing)
 {
     while ($bucket = stream_bucket_make_writeable($in)) {
         if (!empty($this->_previous)) {
             $bucket->data = $this->_previous . $bucket->data;
             $this->_previous = '';
         }
         if (!feof($this->stream) && preg_match('/(%[12]\\$|%[12]|%)$/', $bucket->data)) {
             $this->_previous .= $bucket->data;
             return PSFS_FEED_ME;
         }
         $consumed += $bucket->datalen;
         if (preg_match('/%([12])\\$s/', $bucket->data, $matches)) {
             if ($matches[1] == '1') {
                 $bucket->data = preg_replace('/%1\\$s/', $this->_sender, $bucket->data);
             } else {
                 $bucket->data = preg_replace('/%2\\$s/', $this->_recipient, $bucket->data);
             }
         }
         $bucket->datalen = strlen($bucket->data);
         stream_bucket_append($out, $bucket);
     }
     if (!empty($this->_previous)) {
         if ($closing) {
             $bucket = stream_bucket_new($this->stream, $this->_previous);
             $bucket->data = $this->_previous;
             $consumed += strlen($this->_previous);
             $this->_previous = '';
             stream_bucket_append($out, $bucket);
         }
     }
     return PSFS_PASS_ON;
 }
開發者ID:raz0rsdge,項目名稱:horde,代碼行數:33,代碼來源:AddressFilter.php

示例2: filter

 function filter($in, $out, &$consumed, $closing)
 {
     while ($bucket = stream_bucket_make_writeable($in)) {
         $this->data .= $bucket->data;
         $this->bucket = $bucket;
         $consumed = 0;
     }
     if ($closing) {
         $consumed += strlen($this->data);
         if (isset($this->bucket)) {
             $bucket = $this->bucket;
         } else {
             $bucket = stream_bucket_new($this->stream, '');
         }
         $f = self::$registry[get_class($this)];
         AbstractStreamProcessor__lazyUriResolver::bind($this->stream, $f->uri);
         $bucket->data = $f->process($this->data);
         $bucket->datalen = strlen($bucket->data);
         stream_bucket_append($out, $bucket);
         $this->bucket = null;
         $this->data = '';
         return PSFS_PASS_ON;
     }
     return PSFS_FEED_ME;
 }
開發者ID:nicolas-grekas,項目名稱:Patchwork,代碼行數:25,代碼來源:AbstractStreamProcessor.php

示例3: filter

 /**
  * Filter some data.
  *
  * @param resource $in       Read from this input stream
  * @param resource $out      Write to this output stream
  * @param int      $consumed Count of bytes processed
  * @param bool     $closing  Is the input about to end?
  *
  * @return int PSFS_PASS_ON / PSFS_FEED_ME / PSFS_ERR_FATAL
  */
 public function filter($in, $out, &$consumed, $closing) : int
 {
     $return = PSFS_FEED_ME;
     // While input data is available, continue to read it.
     while ($bucket_in = stream_bucket_make_writeable($in)) {
         $this->data .= $bucket_in->data;
         $consumed += $bucket_in->datalen;
         // While we have complete GEDCOM records, process them.
         while (preg_match('/(.*?[\\r\\n]\\s*)(0.*)/s', $this->data, $match) === 1) {
             list(, $data, $this->data) = $match;
             // Send this record output.
             $data = $this->filterData($data);
             $bucket_out = stream_bucket_new($this->stream, $data);
             $return = PSFS_PASS_ON;
             stream_bucket_append($out, $bucket_out);
         }
     }
     // Process the final record.
     if ($closing && $this->data !== '') {
         $data = $this->filterData($this->data);
         $bucket_out = stream_bucket_new($this->stream, $data);
         $return = PSFS_PASS_ON;
         stream_bucket_append($out, $bucket_out);
     }
     return $return;
 }
開發者ID:fisharebest,項目名稱:lib-gedcom,代碼行數:36,代碼來源:AbstractGedcomFilter.php

示例4: filter

 function filter($in, $out, &$consumed, $closing)
 {
     if (!$closing) {
         $bucket = stream_bucket_new($this->stream, "42");
     }
     return PSFS_ERR_FATAL;
 }
開發者ID:badlamer,項目名稱:hhvm,代碼行數:7,代碼來源:filter_errors_user.php

示例5: filter

 public function filter($in, $out, &$consumed, $closing) : int
 {
     while ($bucket = stream_bucket_make_writeable($in)) {
         stream_bucket_append($out, stream_bucket_new($this->stream, str_rot13($bucket->data)));
     }
     return \PSFS_PASS_ON;
 }
開發者ID:jeremyadoux,項目名稱:hhvm,代碼行數:7,代碼來源:default-filters.php

示例6: filter

 function filter($in, $out, &$consumed, $closing)
 {
     while ($ib = stream_bucket_make_writeable($in)) {
         $ob = stream_bucket_new($this->stream, strtoupper($ib->data));
         stream_bucket_append($out, $ob);
     }
     return PSFS_PASS_ON;
 }
開發者ID:badlamer,項目名稱:hhvm,代碼行數:8,代碼來源:user_filter_order.php

示例7: filter

 /**
  * @see stream_filter_register()
  */
 public function filter($in, $out, &$consumed, $closing)
 {
     stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
     while ($bucket = stream_bucket_make_writeable($in)) {
         $consumed += $bucket->datalen;
         $bucket->data = addcslashes($bucket->data, '"\\');
         stream_bucket_append($out, $bucket);
     }
     stream_bucket_append($out, stream_bucket_new($this->stream, '"'));
     return PSFS_PASS_ON;
 }
開發者ID:netcon-source,項目名稱:apps,代碼行數:14,代碼來源:Quote.php

示例8: filter

 public function filter($in, $out, &$consumed, $closing)
 {
     while ($bucket = stream_bucket_make_writeable($in)) {
         $this->buffer .= $bucket->data;
         $consumed += $bucket->datalen;
     }
     if ($closing) {
         $bucket = stream_bucket_new($this->stream, 'Closed: ' . $this->buffer);
         stream_bucket_append($out, $bucket);
     }
     return PSFS_PASS_ON;
 }
開發者ID:badlamer,項目名稱:hhvm,代碼行數:12,代碼來源:buffered_user_filters.php

示例9: filter

 public function filter($in, $out, &$consumed, $closing)
 {
     while ($bucket = stream_bucket_make_writeable($in)) {
         $lenbucket = stream_bucket_new($this->stream, dechex($bucket->datalen) . "\r\n");
         stream_bucket_append($out, $lenbucket);
         $consumed += $bucket->datalen;
         stream_bucket_append($out, $bucket);
         $lenbucket = stream_bucket_new($this->stream, "\r\n");
         stream_bucket_append($out, $lenbucket);
     }
     return PSFS_PASS_ON;
 }
開發者ID:lab-dvsoftware,項目名稱:docker-php,代碼行數:12,代碼來源:Chunk.php

示例10: filter

 public function filter($in, $out, &$consumed, $closing)
 {
     // concatenate whole buffer from input brigade
     $data = '';
     while ($bucket = stream_bucket_make_writeable($in)) {
         $consumed += $bucket->datalen;
         $data .= $bucket->data;
     }
     // skip processing callback that already ended
     if ($this->closed) {
         return PSFS_FEED_ME;
     }
     // only invoke filter function if buffer is not empty
     // this may skip flushing a closing filter
     if ($data !== '') {
         try {
             $data = call_user_func($this->callback, $data);
         } catch (Exception $e) {
             // exception should mark filter as closed
             $this->onClose();
             trigger_error('Error invoking filter: ' . $e->getMessage(), E_USER_WARNING);
             return PSFS_ERR_FATAL;
         }
     }
     // mark filter as closed after processing closing chunk
     if ($closing) {
         $this->closed = true;
         // callback supports closing and is not already closed
         if ($this->supportsClose) {
             $this->supportsClose = false;
             // invoke without argument to signal end and append resulting buffer
             try {
                 $data .= call_user_func($this->callback);
             } catch (Exception $e) {
                 trigger_error('Error ending filter: ' . $e->getMessage(), E_USER_WARNING);
                 return PSFS_ERR_FATAL;
             }
         }
     }
     if ($data !== '') {
         // create a new bucket for writing the resulting buffer to the output brigade
         // reusing an existing bucket turned out to be bugged in some environments (ancient PHP versions and HHVM)
         $bucket = @stream_bucket_new($this->stream, $data);
         // legacy PHP versions (PHP < 5.4) do not support passing data from the event signal handler
         // because closing the stream invalidates the stream and its stream bucket brigade before
         // invoking the filter close handler.
         if ($bucket !== false) {
             stream_bucket_append($out, $bucket);
         }
     }
     return PSFS_PASS_ON;
 }
開發者ID:Finzy,項目名稱:stageDB,代碼行數:52,代碼來源:CallbackFilter.php

示例11: filter

 /**
  * Filter implementation converts encoding before returning PSFS_PASS_ON.
  * 
  * @param resource $in
  * @param resource $out
  * @param int $consumed
  * @param bool $closing
  * @return int
  */
 public function filter($in, $out, &$consumed, $closing)
 {
     while ($bucket = stream_bucket_make_writeable($in)) {
         $converted = $this->converter->convert($bucket->data);
         $consumed += strlen($bucket->data);
         // $this->stream is undocumented.  It was found looking at HHVM's source code
         // for its convert.iconv.* implementation in ConvertIconFilter and explained
         // somewhat in this StackOverflow page: http://stackoverflow.com/a/31132646/335059
         // declaring a member variable called 'stream' breaks the PHP implementation (5.5.9
         // at least).
         stream_bucket_append($out, stream_bucket_new($this->stream, $converted));
     }
     return PSFS_PASS_ON;
 }
開發者ID:Werdffelynir,項目名稱:owncollab_talks,代碼行數:23,代碼來源:CharsetStreamFilter.php

示例12: filter

 public function filter($in, $out, &$consumed, $closing)
 {
     static $closed = 0;
     while ($bucket = stream_bucket_make_writeable($in)) {
         stream_bucket_append($out, stream_bucket_new($this->stream, $bucket->data));
     }
     if ($closing) {
         $closed++;
     }
     if ($closed > 0) {
         var_dump($closed++);
     }
     return PSFS_PASS_ON;
 }
開發者ID:gleamingthecube,項目名稱:php,代碼行數:14,代碼來源:ext_standard_tests_streams_stream_multi_filters_close.php

示例13: filter

 /**
  * {@inheritdoc}
  */
 public function filter($in, $out, &$consumed, $closing)
 {
     while ($streamBucket = stream_bucket_make_writeable($in)) {
         $this->sourceCode .= $streamBucket->data;
     }
     if ($closing || feof($this->stream)) {
         $consumed = strlen($this->sourceCode);
         $processedCode = Engine::parse($this->sourceCode);
         $streamBucket = stream_bucket_new($this->stream, $processedCode);
         stream_bucket_append($out, $streamBucket);
         return PSFS_PASS_ON;
     }
     return PSFS_FEED_ME;
 }
開發者ID:goaop,項目名稱:ast-manipulator,代碼行數:17,代碼來源:AstSourceFilter.php

示例14: filter

 /**
  * @param resource $in
  * @param resource $out
  * @param int $consumed
  * @param bool $closing
  *
  * @return int
  */
 public function filter($in, $out, &$consumed, $closing)
 {
     if ($closing) {
         /** @var resource|\stdClass $bucket */
         $bucket = stream_bucket_new($this->stream, $this->transform($this->data));
         $this->data = '';
         $consumed += $bucket->datalen;
         stream_bucket_append($out, $bucket);
         return PSFS_PASS_ON;
     } else {
         while ($bucket = stream_bucket_make_writeable($in)) {
             $this->data .= $bucket->data;
         }
         return PSFS_FEED_ME;
     }
 }
開發者ID:komex,項目名稱:influence,代碼行數:24,代碼來源:Filter.php

示例15: filter

 function filter($in, $out, &$consumed, $closing)
 {
     $output = 0;
     while ($bucket = stream_bucket_make_writeable($in)) {
         $bucket->data = strtoupper($bucket->data);
         $consumed += $bucket->datalen;
         stream_bucket_append($out, $bucket);
         $output = 1;
     }
     if ($closing) {
         $bucket = stream_bucket_new($this->stream, "\n===close===\n");
         stream_bucket_append($out, $bucket);
         $output = 1;
     }
     return $output ? PSFS_PASS_ON : PSFS_FEED_ME;
 }
開發者ID:zaky-92,項目名稱:php-1,代碼行數:16,代碼來源:ext_standard_tests_filters_read.php


注:本文中的stream_bucket_new函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。