Write callback

@param $handle
@param $data
@return integer
771308
public function write($handle, $data)
    {
      if(!is_resource($handle))
        throw new Exception(__METHOD__ . '; cURL handle is not valid');

      $length = strlen($data);

      if($this->hasResource())
        fwrite($this->getResource(), $data, $length);
      else
        $this->data .= $data;

      return $length;
    }
601780
public function handler_write($id, $data) {
        if (is_null($this->connection)) {
            // The session has already been closed, don't attempt another write.
            error_log('Tried to write session: '.$id.' before open or after close.');
            return false;
        }

        // We do not do locking here because memcached doesn't.  Also
        // PHP does open, read, destroy, write, close. When a session doesn't exist.
        // There can be race conditions on new sessions racing each other but we can
        // address that in the future.
        try {
            $this->connection->setex($id, $this->timeout, $data);
        } catch (RedisException $e) {
            error_log('Failed talking to redis: '.$e->getMessage());
            return false;
        }
        return true;
    }
243624
public function handle(
    Handler $handler, $sendResponse = true, $catchExceptions = true, $flushHeaders = true, $throwEventExceptions = false
  )
  {
    $this->_eventChannel->setShouldThrowExceptions($throwEventExceptions);
    $c = $this->getContext();
    if($handler instanceof ContextAware)
    {
      $handler->setContext($c);
    }

    try
    {
      $this->_eventChannel->trigger(PreExecuteEvent::i($c, $handler));
      $r = $handler->handle($c);
      $this->_eventChannel->trigger(ResponsePrepareEvent::i($c, $handler, $r));
      $r->prepare($c->request());
      $this->_eventChannel->trigger(ResponsePreparedEvent::i($c, $handler, $r));
    }
    catch(\Throwable $e)
    {
      if(!$catchExceptions)
      {
        throw $e;
      }
      $this->getLogger()->error($e->getMessage());
      $r = (new ExceptionHandler($e))->handle($c);
      $r->prepare($c->request());
    }
    try
    {
      if($sendResponse)
      {
        $this->_eventChannel->trigger(ResponsePreSendHeadersEvent::i($c, $handler, $r));
        $r->sendHeaders();
        if($flushHeaders)
        {
          flush();
        }
        $this->_eventChannel->trigger(ResponsePreSendContentEvent::i($c, $handler, $r));
        $r->send();
      }
      $this->_eventChannel->trigger(HandleCompleteEvent::i($c, $handler, $r));
    }
    catch(\Throwable $e)
    {
      if(!$catchExceptions)
      {
        throw $e;
      }
      $this->getLogger()->error($e->getMessage());
    }
    return $r;
  }
1318034
protected function _Send($handle, $data, $length)
    {
        if (feof($handle) || fwrite($handle, $data, $length) !== $length) {
            $this->_error = 'connection unexpectedly closed (timed out?)';
            $this->_connerror = true;

            return false;
        }

        return true;
    }
783208
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);
		}
		return fwrite($this->_resource, (string) $data, strlen((string) $data));
	}
726429
function tryCall(handler, data, callback)
{
  try {
    handler(data, callback);
  } catch (e) {
    callback(e);
  }
}
1159513
protected function writeToRemote($data, $connection)
    {
        $buffer = serialize($data);
        $buffer = pack('N', 4 + strlen($buffer)) . $buffer;
        $len = fwrite($connection, $buffer);
        if ($len !== strlen($buffer)) {
            throw new \Exception('writeToRemote fail');
        }
    }
1114525
public function writeData($data)
	{
		if (strlen($data) - 4 > $this->_limit) {
			$data = $this->_addContinue($data);
		}
		$this->_datasize += strlen($data);

		return $data;
	}
1184878
public function write($id, $data) : bool
    {
        return (bool)$this->walk(
            'write',
            null,
            [$id, compact('data') + self::$session]
        );
    }
253143
private function _write($handle, $data) 
    {
        
        try {
            $handle->query('TRUNCATE ' . 
                $this->config['table'].'');
            $statement = $handle->prepare('
                INSERT INTO `' . 
                $this->config['table'].'` (
                    type,
                    data,
                    created,
                    modified
                )
                VALUES (
                    :type,
                    :data,
                    now(),
                    now()
                )
            ');
    
            $statement->bindParam('type', 
                $handle->quote($this->type));
            $statement->bindParam('data', serialize($data));
    
            if (!$statement->execute()) {
                throw new PDOException($statement->errorCode());
            }
    
        } catch (PDOException $e) {
            throw new PDOException('PDOException: ' . $e->getMessage());
        }    
    }
400701
function write($id,$data) {
		$this->set('session_id',$id);
		$this->set('data',$data);
		$this->set('ip',$this->_ip);
		$this->set('agent',$this->_agent);
		$this->set('stamp',time());
		$this->save();
		return TRUE;
	}
1249186
protected function format($data, $file_handle)
    {
        $header = false;
        foreach ($data as $idx => $row)
        {
            $row = WF::cast_array($row);
            $this->validateRow($row);

            if ($this->write_bom && ftell($file_handle) === 0)
                fwrite($file_handle, Encoding::getBOM('UTF8'));

            if (!$header && $this->write_header)
            {
                $keys = array_keys($row);
                fputcsv($file_handle, $keys, $this->delimiter, $this->enclosure, $this->escape_char);
                $header = true;
            }
            fputcsv($file_handle, $row, $this->delimiter, $this->enclosure, $this->escape_char);
        }
    }
1278907
public function read($handle)
	{
		if (!is_resource($handle) || get_resource_type($handle) !== 'stream') {
			throw new Exception('Argument must be stream resource.');
		}

		$stat = fstat($handle);

		$sql = '';
		$delimiter = ';';
		$count = $size = 0;

		while (!feof($handle)) {
			$s = fgets($handle);
			$size += strlen($s);
			if (strtoupper(substr($s, 0, 10)) === 'DELIMITER ') {
				$delimiter = trim(substr($s, 10));

			} elseif (substr($ts = rtrim($s), -strlen($delimiter)) === $delimiter) {
				$sql .= substr($ts, 0, -strlen($delimiter));
				if (!$this->connection->query($sql)) {
					throw new Exception($this->connection->error . ': ' . $sql);
				}
				$sql = '';
				$count++;
				if ($this->onProgress) {
					call_user_func($this->onProgress, $count, isset($stat['size']) ? $size * 100 / $stat['size'] : null);
				}

			} else {
				$sql .= $s;
			}
		}

		if (rtrim($sql) !== '') {
			$count++;
			if (!$this->connection->query($sql)) {
				throw new Exception($this->connection->error . ': ' . $sql);
			}
			if ($this->onProgress) {
				call_user_func($this->onProgress, $count, isset($stat['size']) ? 100 : null);
			}
		}

		return $count;
	}
183530
def write(self, data, handle=None):
        """"""
        if not isinstance(data, (bytes, bytearray, memoryview)):
            raise TypeError("data: expecting a bytes-like instance, got {!r}"
                                .format(type(data).__name__))
        if handle is not None and not isinstance(self._handle, pyuv.Pipe):
            raise ValueError('handle: can only be sent over pyuv.Pipe')
        self._check_status()
        if not self._writable:
            raise TransportError('transport is not writable')
        if self._closing:
            raise TransportError('transport is closing')
        try:
            if handle:
                self._handle.write(data, self._on_write_complete, handle)
            else:
                self._handle.write(data, self._on_write_complete)
        except pyuv.error.UVError as e:
            self._error = TransportError.from_errno(e.args[0])
            self.abort()
            raise compat.saved_exc(self._error)
        # We only keep track of the number of outstanding write requests
        # outselves. See note in get_write_buffer_size().
        self._write_buffer_size += 1
        self._maybe_pause_protocol()
224779
public function writeCallback($resource, $string)
    {
        $this->body .= $string;

        if ($this->onBody === null || call_user_func($this->onBody, $this->body, $this->data) !== false) {
            return strlen($string);
        }

        //Cancel
        $this->body = null;

        return -1;
    }
720243
public function renderNoInteraction(Handle $handle, array $calls): string
    {
        $class = $handle->class();

        if ($parentClass = $class->getParentClass()) {
            $class = $parentClass;
        }

        $atoms = explode('\\', $class->getName());
        $renderedHandle = array_pop($atoms);

        if ($handle instanceof InstanceHandle) {
            $label = $handle->label();

            if ('' !== $label) {
                $renderedHandle .= '[' . $label . ']';
            }
        } else {
            $renderedHandle .= '[static]';
        }

        usort($calls, [CallData::class, 'compareSequential']);
        $renderedCalls = [];

        foreach ($calls as $index => $call) {
            $renderedArguments = [];

            foreach ($call->arguments()->all() as $argument) {
                $renderedArguments[] = $this->exporter->export($argument);
            }

            $renderedCalls[] =
                '    ' . $this->fail .
                ' ' . $this->exporter->exportCallable($call->callback()) .
                '(' . implode(', ', $renderedArguments) . ')';
        }

        return $this->reset . 'Expected no interaction with ' .
            $this->bold . $renderedHandle . $this->reset .
            '. Calls:' . PHP_EOL . implode(PHP_EOL, $renderedCalls);
    }
741674
public static function write($handle = 0, $command = '', $arguments = array()) {
        $buffer = self::parseCommand($command, $arguments);
        return self::_writeToServer($handle, $buffer);
    }