Writes data to the stream.

@param string $data Bytes to write.

@throws ClosedException If the stream has already been closed.

@return Promise Succeeds once the data has been successfully written to the stream.
499537
public function bufferWrite(string $data): Promise
    {
        if ($this->write_hash === null) {
            return $this->write_buffer->bufferWrite($length);
        }

        $length = strlen($data);
        if ($this->write_check_after && $length + $this->write_check_pos >= $this->write_check_after) {
            if ($length + $this->write_check_pos > $this->write_check_after) {
                throw new \danog\MadelineProto\Exception('Too much out of frame data was sent, cannot check hash');
            }
            hash_update($this->write_hash, $data);

            return $this->write_buffer->bufferWrite($data.$this->getWriteHash());
        }
        if ($this->write_check_after) {
            $this->write_check_pos += $length;
        }
        if ($this->write_hash) {
            hash_update($this->write_hash, $data);
        }

        return $this->write_buffer->bufferWrite($data);
    }
675232
public function write($data = null)
    {
        $this->response = $this->httpClient->post($this->parameters['url'], $this->getRequestParameters($data));
    }
1117736
public function write($data)
    {
        if ($this->closed) {
            return;
        }

        $all = $this->tail . $data;
        $messages = $this->getParser()->consumeAll($all);
        $this->tail = $all;

        foreach ($messages as $message) {
            if (isset($message['message'])) {
                $this->emit('data', array($message['message']));
                $this->emit('irc.received', array($message));
            } elseif (isset($message['invalid'])) {
                $this->emit('invalid', array($message['invalid']));
            }
        }
    }
1126949
public function write($data)
    {
        $this->_checkStream();
        if (!@fwrite($this->_stream, $data)) {
            $meta_data = $this->getStatus();
            if (!empty($meta_data['timed_out'])) {
                throw new Client\Exception('Timed out writing data to socket');
            }
            throw new Client\Exception('Error writing data to socket');
        }
    }
1342303
public function stream_write($data)
    {
        if ($this->getOnWriteDataMode()) {

            $length = strlen($data);
            $this->appendDataBuffer($data);
            $this->appendPosition($length);
            return $length;
        } else {
            throw new \Exception('dirty mode.');
        }
    }
971075
public function write($data)
    {
        $this->contentLength += strlen($data);
        $this->data .= $data;

        return $this;
    }
1281255
public function writeln($data)
    {
        if (!$this->alive) {
            Daemon::log('Attempt to write to dead IOStream (' . get_class($this) . ')');
            return false;
        }
        if (!isset($this->bevWrite)) {
            return false;
        }
        if (!mb_orig_strlen($data) && !mb_orig_strlen($this->EOL)) {
            return true;
        }
        $this->writing = true;
        $this->bevWrite->write($data);
        $this->bevWrite->write($this->EOL);
        return true;
    }
716145
private function send(string $data):void
    {

        socket_write($this->socket, $data, strlen($data)) or $this->error();

    }
378497
public function stream_write($data)
    {
        assert(null !== $this->handle);

        return fwrite($this->handle, $data);
    }
728606
public function write($data)
	{
		$this->createFolderIfNotExist($this->folderPath());
		$this->createFile($this->getFilePath(), $data);
	}
322057
public function stream_write($data)
    {
        if (!$this->currentlyOpenedFile->isOpenedForWriting()) {
            return false;
        }
        //file access time changes so stat cache needs to be cleared
        $written = $this->currentlyOpenedFile->write($data);
        clearstatcache();

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

        $data .= "\r\n";

        $length = strlen($data);
        $fwrited = fwrite($this->_connection, $data, $length);

        if ($fwrited === false) {
            throw new SocketException('Socket is broken, write failed: '.substr($data, 0, 100));
        } elseif ($fwrited < $length) {
            throw new SocketException("Socket is broken, only write {$fwrited} bytes of {$length} bytes: ".substr($data, 0, 100));
        }

        return $fwrited;
    }
98859
protected function _write($data)
    {
        $result = @fwrite($this->_fileHandler, $data);

        if (false === $result) {
            throw new Mage_Exception('Failed to write data to ' . $this->_filePath);
        }
    }
488695
public function write($data)
    {

        $path = (string)$this->url();

        $isAppending = static::isAppendingMode($this->mode) || $this->didWrite;

        if (!is_resource($data) && !$data instanceof Stream && Type::isStringable($data)) {
            $this->didWrite = $isAppending ? $this->flysystem->update($path, $this->concat($data)) : $this->flysystem->write($path, $data);
            return $this->didWrite;
        }

        // Write while READING FROM A RESOURCE
        $readResource = $data instanceof Stream ? $data->resource() : $data;

        if (!is_resource($readResource)) {
            throw new RuntimeException('Cannot extract resource of ' . Type::of($data));
        }

        if ($isAppending) {
            $this->didWrite = $this->flysystem->updateStream($path, $readResource);
            return $this->didWrite;
        }

        $this->didWrite = $this->flysystem->writeStream($path, $readResource);

        return $this->didWrite;

    }
874777
public function stream_write( $data )
    {
        $left            = substr( $this->string, 0, $this->position );
        $right           = substr( $this->string, $this->position + strlen( $data ) );
        $this->string    = $left . $data . $right;
        $this->position += $written = strlen( $data );
        $this->length    = strlen( $this->string );
        return $written;
    }
616773
public function write($data = null) {
		if (!is_resource($this->_resource)) {
			return false;
		}
		if (!is_object($data)) {
			$data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
		}
		$this->set(CURLOPT_URL, $data->to('url'));

		if ($data instanceof Message) {
			if (!empty($this->_config['ignoreExpect'])) {
				$data->headers('Expect', ' ');
			}
			if (isset($data->headers)) {
				$this->set(CURLOPT_HTTPHEADER, $data->headers());
			}
			if (isset($data->method) && $data->method === 'POST') {
				$this->set([CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data->body()]);
			}
			if (isset($data->method) && in_array($data->method,['PUT','PATCH','DELETE'])) {
				$this->set([
					CURLOPT_CUSTOMREQUEST => $data->method,
					CURLOPT_POSTFIELDS => $data->body()
				]);
			}
		}
		return (boolean) curl_setopt_array($this->_resource, $this->options);
	}
1093954
public function writeAsync($data)
    {
        $this->dataBuffer .= $this->buffer->encodeMessage(serialize($data));
        if ($this->writeEvent === false)
        {
            $this->loop->addWriteStream($this->connection, function ($stream, LoopInterface $loop)
            {
                if (strlen($this->dataBuffer) > 0)
                {
                    $dataWritten = fwrite($stream,$this->dataBuffer);
                    $this->dataBuffer = substr($this->dataBuffer,$dataWritten);
                    if(strlen($this->dataBuffer) <= 0)
                    {
                        $loop->removeWriteStream($stream);
                        $this->writeEvent = false;
                    }
                }
            });
            $this->writeEvent = true;
        }
    }