Write data to the stream.

@param string $string The string that is to be written.

@return int Returns the number of bytes written to the stream.

@throws \RuntimeException on failure.
@throws \TypeError
426195
public function write($string)
    {
        if (!\is_resource($this->stream)) {
            throw new \TypeError();
        }
        if (!$this->isWritable() || ($written = \fwrite($this->stream, $string)) === false) {
            throw new \RuntimeException('Could not write to stream');
        }
        if (!isset($written)) {
            $written = 0;
        }

        // reset size so that it will be recalculated on next call to getSize()
        $this->size = null;

        return (int) $written;
    }
7090
public function write($string)
    {
        $handle = @fopen($this->filePath, $this->mode);
        if ($handle === false) {
            return $handle;
        }
        return @fwrite($handle, $string);


    }
214515
protected function _write($data) {
		if (!$this->connected) {
			$message = 'No connecting found while writing data to socket.';
			throw new RuntimeException($message);
		}

		$data .= "\r\n";
		return fwrite($this->_connection, $data, strlen($data));
	}
310392
public function write($string)
    {
        $this->content = substr_replace($this->content, $string, $this->position, 0);
        $len = strlen($string);
        $this->position += $len;
        return $len;
    }
556761
public function write(string $data): int
	{
		$totalBytesWritten = 0;

		$bytesLeft = strlen($data);

		do
		{
			$totalBytesWritten += $bytesWritten = fwrite($this->connection, $data);

			if($bytesWritten === false || $bytesWritten === 0)
			{
				throw new RedisException('Failed to write data to the server.');
			}

			$bytesLeft -= $bytesWritten;

			$data = substr($data, $bytesWritten);
		}
		while($bytesLeft > 0);

		return $totalBytesWritten;
	}
32335
public function write($string)
    {
        if (!is_resource($this->stream)) {
            throw new \RuntimeException('Cannot write to an empty resource stream');
        }

        if (!$this->isWritable()) {
            throw new \RuntimeException('Cannot write to a non-writable stream');
        }

        // We can't know the size after writing anything
        $this->size = null;
        $result = fwrite($this->stream, $string);

        if ($result === false) {
            throw new \RuntimeException('Unable to write to stream');
        }

        return $result;
    }
96523
public function write($string) {
        if ( ! is_array($string)) {
            $string = [$string];
        }

        foreach ($string as $item) {
            $this->buffer .= $item;
        }
    }
414703
public function write($string)
    {
        $chunked = $this->getChunkedString($string);
        $this->position += strlen($chunked);
        return $this->stream->write($chunked);
    }
920100
public function writeString(&$string)
    {
        $len = strlen($string);
        if(!$len){
            $this->writeInteger(0x01);
            return $this;
        }

        $ref = array_key_exists($string, $this->_referenceStrings) 
             ? $this->_referenceStrings[$string] 
             : false;
        if ($ref === false){
            $this->_referenceStrings[$string] = count($this->_referenceStrings);
            $this->writeBinaryString($string);
        } else {
            $ref <<= 1;
            $this->writeInteger($ref);
        }

        return $this;
    }
15983
public function stream_write($data)
    {
        if ( ! $this->stream instanceof WritableStream) {
            return 0;
        }

        try {
            return $this->stream->writeBytes($data);
        } catch (Exception $e) {
            trigger_error(sprintf('%s: %s', get_class($e), $e->getMessage()), \E_USER_WARNING);
            return false;
        }
    }
682504
public function readStream($length)
    {
        $stream  = self::fromString();
        $target  = $stream->stream;
        $source  = $this->stream;

        if ($length < 1) {
            return $stream;
        }

        $written = stream_copy_to_stream($source, $target, $length);

        if ($written !== $length) {
            throw new RuntimeException('Failed to read stream with ' . $length . ' bytes');
        }

        $stream->seek(0);

        return $stream;
    }
1041494
public function stream_write($data)
    {
        if ($this->fileHandle === null) {
            return false;
        }
        self::restore();
        $length = fwrite($this->fileHandle, $data);
        self::register();
        return $length;
    }
21953
function write($content, $inByte = null)
    {
        $this->_assertWritable();

        $stream = $this->resource()->getRHandler();

        $inByte = ($inByte === null)
            ? $this->getBuffer()
            : $inByte;


        $content = (string) $content;
        if (null === $inByte)
            $ret = fwrite($stream, $content);
        else
            $ret = fwrite($stream, $content, $inByte);

        if (false === $ret)
            throw new \RuntimeException('Cannot write on stream.');

        $transCount = $inByte;
        if ($transCount === null) {
            if (function_exists('mb_strlen'))
                $transCount = mb_strlen($content, '8bit');
            else
                $transCount = strlen($content);
        }

        $this->_resetTransCount($transCount);
        return $this;
    }
736403
public function stream_write($data)
    {
        if (self::READONLY === $this->mode) {
            return 0;
        }

        if ($this->content->isWritable(vfsStream::getCurrentUser(), vfsStream::getCurrentGroup()) === false) {
            return 0;
        }

        return $this->content->write($data);
    }
565529
public function stream_write($data)
    {
        if ($this->_upload === null) {
            return false;
        }
        $this->_upload->addContent($data);
        $result = StringHelper::byteLength($data);
        $this->_pointerOffset += $result;
        return $result;
    }
487028
public function write(string $bytes): int
    {
        if ($this->isFileCreationDelayed()) {
            $this->setHandle($this->openFile($this->file, $this->mode));
        }

        return parent::write($bytes);
    }
14561
public function write($data)
    {
        if ($this->isOpen() === false) {
            $msg = "Cannot write in a closed MemoryStream.";
            throw new MemoryStreamException($msg, $this, MemoryStreamException::NOT_OPEN);
        }
        
        if ($this->length - 1 === $this->position) {
            // simply append.
            $this->binary .= $data;
        } elseif ($this->position === 0) {
            // simply prepend.
            $this->binary = ($data . $this->binary);
        } else {
            // we are in the middle of the string.
            $part1 = substr($this->binary, 0, $this->position);
            $part2 = substr($this->binary, $this->position);
            $this->binary = ($part1 . $data . $part2);
        }

        $dataLen = strlen($data);
        $this->incrementPosition($dataLen);
        $this->incrementLength($dataLen);

        return $dataLen;
    }