Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

BufferStream.php

Zuletzt modifiziert: 01.05.2026, 11:26 - Dateigröße: 3.01 KiB


 001  <?php
 002   
 003  namespace GuzzleHttp\Psr7;
 004   
 005  use Psr\Http\Message\StreamInterface;
 006   
 007  /**
 008   * Provides a buffer stream that can be written to to fill a buffer, and read
 009   * from to remove bytes from the buffer.
 010   *
 011   * This stream returns a "hwm" metadata value that tells upstream consumers
 012   * what the configured high water mark of the stream is, or the maximum
 013   * preferred size of the buffer.
 014   *
 015   * @final
 016   */
 017  class BufferStream implements StreamInterface
 018  {
 019      private $hwm;
 020      private $buffer = '';
 021   
 022      /**
 023       * @param int $hwm High water mark, representing the preferred maximum
 024       *                 buffer size. If the size of the buffer exceeds the high
 025       *                 water mark, then calls to write will continue to succeed
 026       *                 but will return false to inform writers to slow down
 027       *                 until the buffer has been drained by reading from it.
 028       */
 029      public function __construct($hwm = 16384)
 030      {
 031          $this->hwm = $hwm;
 032      }
 033   
 034      public function __toString()
 035      {
 036          return $this->getContents();
 037      }
 038   
 039      public function getContents()
 040      {
 041          $buffer = $this->buffer;
 042          $this->buffer = '';
 043   
 044          return $buffer;
 045      }
 046   
 047      public function close()
 048      {
 049          $this->buffer = '';
 050      }
 051   
 052      public function detach()
 053      {
 054          $this->close();
 055   
 056          return null;
 057      }
 058   
 059      public function getSize()
 060      {
 061          return strlen($this->buffer);
 062      }
 063   
 064      public function isReadable()
 065      {
 066          return true;
 067      }
 068   
 069      public function isWritable()
 070      {
 071          return true;
 072      }
 073   
 074      public function isSeekable()
 075      {
 076          return false;
 077      }
 078   
 079      public function rewind()
 080      {
 081          $this->seek(0);
 082      }
 083   
 084      public function seek($offset, $whence = SEEK_SET)
 085      {
 086          throw new \RuntimeException('Cannot seek a BufferStream');
 087      }
 088   
 089      public function eof()
 090      {
 091          return strlen($this->buffer) === 0;
 092      }
 093   
 094      public function tell()
 095      {
 096          throw new \RuntimeException('Cannot determine the position of a BufferStream');
 097      }
 098   
 099      /**
 100       * Reads data from the buffer.
 101       */
 102      public function read($length)
 103      {
 104          $currentLength = strlen($this->buffer);
 105   
 106          if ($length >= $currentLength) {
 107              // No need to slice the buffer because we don't have enough data.
 108              $result = $this->buffer;
 109              $this->buffer = '';
 110          } else {
 111              // Slice up the result to provide a subset of the buffer.
 112              $result = substr($this->buffer, 0, $length);
 113              $this->buffer = substr($this->buffer, $length);
 114          }
 115   
 116          return $result;
 117      }
 118   
 119      /**
 120       * Writes data to the buffer.
 121       */
 122      public function write($string)
 123      {
 124          $this->buffer .= $string;
 125   
 126          // TODO: What should happen here?
 127          if (strlen($this->buffer) >= $this->hwm) {
 128              return false;
 129          }
 130   
 131          return strlen($string);
 132      }
 133   
 134      public function getMetadata($key = null)
 135      {
 136          if ($key == 'hwm') {
 137              return $this->hwm;
 138          }
 139   
 140          return $key ? null : [];
 141      }
 142  }
 143