mini\Http\Message\Stream::cast() Method

public static

Signature

public static function cast(mixed $source): Psr\Http\Message\StreamInterface

Parameters

Name Type Default Description
$source mixed required Documentation missing

Returns

Psr\Http\Message\StreamInterface

Documentation

Cast a value to a Stream instance.

Convenience helper that accepts various types and ensures you get a StreamInterface:

  • StreamInterface: returned as-is (no-op)
  • string: written to php://temp stream
  • Stringable: cast to string, written to php://temp stream
  • resource (stream type): wrapped in Stream instance

Use this in methods that accept "string|StreamInterface" to normalize the input:

public function withBody($body) {
    $this->body = Stream::cast($body);
}

Source

src/Http/Message/Stream.php:36-63