Registers stream instance for a protocol.

@param StreamInterface $stream
@param bool            $replaceWrapper

@return self
513252
public function registerStream(StreamInterface $stream, $replaceWrapper = false)
    {
        $protocol = $stream->getProtocol();
        if ($replaceWrapper === true && in_array($protocol, stream_get_wrappers())) {
            stream_wrapper_unregister($protocol);
        }

        if (stream_wrapper_register($protocol, $stream->getStreamWrapperClass())) {
            self::$streams[$protocol] = $stream;
        }

        return $this;
    }
1340691
public Promise<Void> replaceStream(CountedReference<WebRTCMediaStream> mediaStream) {
        return ask(new PeerConnectionActor.ReplaceStream(mediaStream.acquire()));
    }
1227747
public function initializeStreamWrapper()
    {
        $stream = new Stream('accompli', array(
                'recipe' => realpath(__DIR__.'/Resources/recipe'),
            ), false);

        StreamManager::create()->registerStream($stream);
    }
399963
private function invokeInternalStreamWrapper(string $functionName, ...$arguments)
    {
        $silentExecution = $functionName{0} === '@';
        $functionName = ltrim($functionName, '@');
        $this->restoreInternalSteamWrapper();

        try {
            if ($silentExecution) {
                $result = @call_user_func_array($functionName, $arguments);
            } else {
                $result = call_user_func_array($functionName, $arguments);
            }
        } finally {
            $this->registerStreamWrapper();
        }

        return $result;
    }
1112271
function prependFilter(iFilterStream $filter, $rwFlag = STREAM_FILTER_ALL)
    {
        $filterRes = $filter->prependTo($this);

        // store attached filter resource, so we can remove it from stream handler later
        $this->attachedFilters[$filter->getLabel()] = $filterRes;
        return $this;
    }
699810
static function convertToResource(StreamInterface $stream)
    {
        # register wrapper if not
        $self = new self;
        if(!RegistryOfWrapperStream::isRegistered($self->getLabel()))
            RegistryOfWrapperStream::register($self);

        # make resource
        $mode = new AccessMode();
        (!$stream->isWritable()) ?: $mode->openForWrite();
        (!$stream->isReadable()) ?: $mode->openForRead();

        $label = $self->getLabel();

        $context  = new ContextStreamBase( $label, array('stream' => $stream) );
        $context  = $context->toContext();
        $resource = fopen($label.'://stream'
            , (string) $mode
            , null
            ## set options to wrapper
            , $context
        );

        return $resource;
    }
197278
public function setWrapperFormat(string $wrapper): self
    {
        $this->compilerOptions['wrapper'] = $wrapper;
        $this->schemaCompilerOptions['wrapper'] = $wrapper;
        return $this;
    }
1358864
private function setStream($stream, $mode = 'r')
    {
        $error    = null;
        $resource = $stream;

        if (is_string($stream)) {
            set_error_handler(function ($e) use (&$error) {
                $error = $e;
            }, E_WARNING);
            $resource = fopen($stream, $mode);
            restore_error_handler();
        }

        if ($error) {
            throw new InvalidArgumentException('Invalid stream reference provided');
        }

        if (! is_resource($resource) || 'stream' !== get_resource_type($resource)) {
            throw new InvalidArgumentException(
                'Invalid stream provided; must be a string stream identifier or stream resource'
            );
        }

        if ($stream !== $resource) {
            $this->stream = $stream;
        }

        $this->resource = $resource;
    }
232669
public function restore(ContainerInterface $container, array $dump)
    {
        if (true === $dump['has_event_dispatcher']) {
            $this->setEventDispatcher($container->get('event.dispatcher'));
        }

        $this->register();

        $this->_namespaces = $dump['namespaces_locations'];
        $this->_streamWrappers = $dump['wrappers_namespaces'];

        if (0 < count($dump['wrappers_namespaces'])) {
            $this->registerStreams();
        }

        $this->_is_restored = true;
    }
427430
public function registerWrapper($name, $class)
    {
        if (!is_subclass_of($class, WrapperInterface::class)) {
            throw new \RuntimeException(sprintf(
                'Wrapper class "%s" must be implement ' . WrapperInterface::class,
                $class
            ));
        }
        $this->wrappers[$name] = $class;

        return $this;
    }
241304
public static function unregister($protocol)
  {
    $wrappers = stream_get_wrappers();
    if (!in_array($protocol, $wrappers)) {
      throw new Wrapper_Exception(
        "Protocol '$protocol' has not been registered yet"
      );
    }

    return stream_wrapper_unregister($protocol);
  }
463498
public function withBody(StreamInterface $body)
    {
        $request = $this->copy();
        $request->setBody($body);
        
        return $request;
    }
503142
public function setStream($stream = null)
    {
        // String passed in? Try converting it to a stream
        if (is_string($stream)) {
            $stream = @fopen($stream, 'a');
        }

        // Make sure the stream is a resource
        if (!is_resource($stream)) {
            throw new \InvalidArgumentException('Invalid Stream');
        }

        // Store it
        $this->stream = $stream;

        // Afford chaining
        return $this;
    }
357548
protected static function stringReplaceIgnoringStreamWrapper($toReplace, $replacement, string $fullPath):string
    {
        if (strpos($fullPath, '://') !== false) {
            list($streamWrapper, $path) = explode('://', $fullPath, 2);

            return $streamWrapper . '://' . ltrim(str_replace(
                $toReplace,
                $replacement,
                $path
            ), DIRECTORY_SEPARATOR);
        } else {
            return str_replace($toReplace, $replacement, $fullPath);
        }
    }
1116197
public static function decorate(StreamInterface $stream, array $methods)
    {
        // If any of the required methods were not provided, then simply
        // proxy to the decorated stream.
        foreach (array_diff(static::SLOTS, array_keys($methods)) as $diff) {
            $methods[$diff] = [$stream, $diff];
        }

        return new self($methods);
    }
1043532
protected function setStream($type, StreamInterface $stream)
    {
        $this->streams[$type] = $stream;

        $callback = array($this, 'on'.ucfirst($type).'Message');

        $stream->addListener(
            StreamInterface::MESSAGE,
            $this->createEventListenerForStream($callback)
        );

        return $this;
    }
529308
public function setStream($stream)
    {
        if (! is_resource($stream) || ! 'stream' == get_resource_type($stream)) {
            throw new \InvalidArgumentException(sprintf(
                'Expects argument to be a stream resource, got %s',
                is_resource($stream) ? get_resource_type($stream) : gettype($stream)
            ));
        }

        $this->stream = $stream;

        return $this;
    }