original_string: public function push($data)
      {
          $this->buffer->write($data);
  
          $result = [];
          while ($this->buffer->getRemainingBytes() > 0) {
              $type = $this->buffer->readByte() >> 4;
              try {
                  $packet = $this->factory->build($type);
              } catch (UnknownPacketTypeException $e) {
                  $this->handleError($e);
                  continue;
              }
  
              $this->buffer->seek(-1);
              $position = $this->buffer->getPosition();
              try {
                  $packet->read($this->buffer);
                  $result[] = $packet;
                  $this->buffer->cut();
              } catch (EndOfStreamException $e) {
                  $this->buffer->setPosition($position);
                  break;
              } catch (MalformedPacketException $e) {
                  $this->handleError($e);
              }
          }
  
          return $result;
      }
code: public function push($data)
      {
          $this->buffer->write($data);
  
          $result = [];
          while ($this->buffer->getRemainingBytes() > 0) {
              $type = $this->buffer->readByte() >> 4;
              try {
                  $packet = $this->factory->build($type);
              } catch (UnknownPacketTypeException $e) {
                  $this->handleError($e);
                  continue;
              }
  
              $this->buffer->seek(-1);
              $position = $this->buffer->getPosition();
              try {
                  $packet->read($this->buffer);
                  $result[] = $packet;
                  $this->buffer->cut();
              } catch (EndOfStreamException $e) {
                  $this->buffer->setPosition($position);
                  break;
              } catch (MalformedPacketException $e) {
                  $this->handleError($e);
              }
          }
  
          return $result;
      }
code_tokens: public function push ( $ data ) { $ this -> buffer -> write ( $ data ) ; $ result = [ ] ; while ( $ this -> buffer -> getRemainingBytes ( ) > 0 ) { $ type = $ this -> buffer -> readByte ( ) >> 4 ; try { $ packet = $ this -> factory -> build ( $ type ) ; } catch ( UnknownPacketTypeException $ e ) { $ this -> handleError ( $ e ) ; continue ; } $ this -> buffer -> seek ( - 1 ) ; $ position = $ this -> buffer -> getPosition ( ) ; try { $ packet -> read ( $ this -> buffer ) ; $ result [ ] = $ packet ; $ this -> buffer -> cut ( ) ; } catch ( EndOfStreamException $ e ) { $ this -> buffer -> setPosition ( $ position ) ; break ; } catch ( MalformedPacketException $ e ) { $ this -> handleError ( $ e ) ; } } return $ result ; }
docstring: Appends the given data to the internal buffer and parses it.
  
  @param string $data
  
  @return Packet[]
docstring_tokens: Appends the given data to the internal buffer and parses it .