[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/psr/http-message/src/ -> StreamInterface.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace Psr\Http\Message;
   6  
   7  /**
   8   * Describes a data stream.
   9   *
  10   * Typically, an instance will wrap a PHP stream; this interface provides
  11   * a wrapper around the most common operations, including serialization of
  12   * the entire stream to a string.
  13   */
  14  interface StreamInterface
  15  {
  16      /**
  17       * Reads all data from the stream into a string, from the beginning to end.
  18       *
  19       * This method MUST attempt to seek to the beginning of the stream before
  20       * reading data and read the stream until the end is reached.
  21       *
  22       * Warning: This could attempt to load a large amount of data into memory.
  23       *
  24       * This method MUST NOT raise an exception in order to conform with PHP's
  25       * string casting operations.
  26       *
  27       * @see http://php.net/manual/en/language.oop5.magic.php#object.tostring
  28       * @return string
  29       */
  30      public function __toString();
  31  
  32      /**
  33       * Closes the stream and any underlying resources.
  34       *
  35       * @return void
  36       */
  37      public function close();
  38  
  39      /**
  40       * Separates any underlying resources from the stream.
  41       *
  42       * After the stream has been detached, the stream is in an unusable state.
  43       *
  44       * @return resource|null Underlying PHP stream, if any
  45       */
  46      public function detach();
  47  
  48      /**
  49       * Get the size of the stream if known.
  50       *
  51       * @return int|null Returns the size in bytes if known, or null if unknown.
  52       */
  53      public function getSize();
  54  
  55      /**
  56       * Returns the current position of the file read/write pointer
  57       *
  58       * @return int Position of the file pointer
  59       * @throws \RuntimeException on error.
  60       */
  61      public function tell();
  62  
  63      /**
  64       * Returns true if the stream is at the end of the stream.
  65       *
  66       * @return bool
  67       */
  68      public function eof();
  69  
  70      /**
  71       * Returns whether or not the stream is seekable.
  72       *
  73       * @return bool
  74       */
  75      public function isSeekable();
  76  
  77      /**
  78       * Seek to a position in the stream.
  79       *
  80       * @link http://www.php.net/manual/en/function.fseek.php
  81       * @param int $offset Stream offset
  82       * @param int $whence Specifies how the cursor position will be calculated
  83       *     based on the seek offset. Valid values are identical to the built-in
  84       *     PHP $whence values for `fseek()`.  SEEK_SET: Set position equal to
  85       *     offset bytes SEEK_CUR: Set position to current location plus offset
  86       *     SEEK_END: Set position to end-of-stream plus offset.
  87       * @throws \RuntimeException on failure.
  88       */
  89      public function seek(int $offset, int $whence = SEEK_SET);
  90  
  91      /**
  92       * Seek to the beginning of the stream.
  93       *
  94       * If the stream is not seekable, this method will raise an exception;
  95       * otherwise, it will perform a seek(0).
  96       *
  97       * @see seek()
  98       * @link http://www.php.net/manual/en/function.fseek.php
  99       * @throws \RuntimeException on failure.
 100       */
 101      public function rewind();
 102  
 103      /**
 104       * Returns whether or not the stream is writable.
 105       *
 106       * @return bool
 107       */
 108      public function isWritable();
 109  
 110      /**
 111       * Write data to the stream.
 112       *
 113       * @param string $string The string that is to be written.
 114       * @return int Returns the number of bytes written to the stream.
 115       * @throws \RuntimeException on failure.
 116       */
 117      public function write(string $string);
 118  
 119      /**
 120       * Returns whether or not the stream is readable.
 121       *
 122       * @return bool
 123       */
 124      public function isReadable();
 125  
 126      /**
 127       * Read data from the stream.
 128       *
 129       * @param int $length Read up to $length bytes from the object and return
 130       *     them. Fewer than $length bytes may be returned if underlying stream
 131       *     call returns fewer bytes.
 132       * @return string Returns the data read from the stream, or an empty string
 133       *     if no bytes are available.
 134       * @throws \RuntimeException if an error occurs.
 135       */
 136      public function read(int $length);
 137  
 138      /**
 139       * Returns the remaining contents in a string
 140       *
 141       * @return string
 142       * @throws \RuntimeException if unable to read or an error occurs while
 143       *     reading.
 144       */
 145      public function getContents();
 146  
 147      /**
 148       * Get stream metadata as an associative array or retrieve a specific key.
 149       *
 150       * The keys returned are identical to the keys returned from PHP's
 151       * stream_get_meta_data() function.
 152       *
 153       * @link http://php.net/manual/en/function.stream-get-meta-data.php
 154       * @param string|null $key Specific metadata to retrieve.
 155       * @return array|mixed|null Returns an associative array if no key is
 156       *     provided. Returns a specific key value if a key is provided and the
 157       *     value is found, or null if the key is not found.
 158       */
 159      public function getMetadata(?string $key = null);
 160  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1