original_string: public function write($data)
      {
          if (!$this->connected && !$this->connect()) {
              return false;
          }
          $totalBytes = strlen($data);
          $written = 0;
          while ($written < $totalBytes) {
              $rv = fwrite($this->connection, substr($data, $written));
              if ($rv === false || $rv === 0) {
                  return $written;
              }
              $written += $rv;
          }
  
          return $written;
      }
code: public function write($data)
      {
          if (!$this->connected && !$this->connect()) {
              return false;
          }
          $totalBytes = strlen($data);
          $written = 0;
          while ($written < $totalBytes) {
              $rv = fwrite($this->connection, substr($data, $written));
              if ($rv === false || $rv === 0) {
                  return $written;
              }
              $written += $rv;
          }
  
          return $written;
      }
code_tokens: public function write ( $ data ) { if ( ! $ this -> connected && ! $ this -> connect ( ) ) { return false ; } $ totalBytes = strlen ( $ data ) ; $ written = 0 ; while ( $ written < $ totalBytes ) { $ rv = fwrite ( $ this -> connection , substr ( $ data , $ written ) ) ; if ( $ rv === false || $ rv === 0 ) { return $ written ; } $ written += $ rv ; } return $ written ; }
docstring: Write data to the socket.
  
  The bool false return value is deprecated and will be int 0 in the next major.
  Please code respectively to be future proof.
  
  @param string $data The data to write to the socket.
  @return int|false Bytes written.
docstring_tokens: Write data to the socket .