original_string: public function readInteger()
      {
          $count        = 1;
          $intReference = $this->_stream->readByte();
          $result       = 0;
          while ((($intReference & 0x80) != 0) && $count < 4) {
              $result       <<= 7;
              $result        |= ($intReference & 0x7f);
              $intReference   = $this->_stream->readByte();
              $count++;
          }
          if ($count < 4) {
              $result <<= 7;
              $result  |= $intReference;
          } else {
              // Use all 8 bits from the 4th byte
              $result <<= 8;
              $result  |= $intReference;
  
              // Check if the integer should be negative
              if (($result & 0x10000000) != 0) {
                  //and extend the sign bit
                  $result |= ~0xFFFFFFF;
              }
          }
          return $result;
      }
code: public function readInteger()
      {
          $count        = 1;
          $intReference = $this->_stream->readByte();
          $result       = 0;
          while ((($intReference & 0x80) != 0) && $count < 4) {
              $result       <<= 7;
              $result        |= ($intReference & 0x7f);
              $intReference   = $this->_stream->readByte();
              $count++;
          }
          if ($count < 4) {
              $result <<= 7;
              $result  |= $intReference;
          } else {
              // Use all 8 bits from the 4th byte
              $result <<= 8;
              $result  |= $intReference;
  
              // Check if the integer should be negative
              if (($result & 0x10000000) != 0) {
                  //and extend the sign bit
                  $result |= ~0xFFFFFFF;
              }
          }
          return $result;
      }
code_tokens: public function readInteger ( ) { $ count = 1 ; $ intReference = $ this -> _stream -> readByte ( ) ; $ result = 0 ; while ( ( ( $ intReference & 0x80 ) != 0 ) && $ count < 4 ) { $ result <<= 7 ; $ result |= ( $ intReference & 0x7f ) ; $ intReference = $ this -> _stream -> readByte ( ) ; $ count ++ ; } if ( $ count < 4 ) { $ result <<= 7 ; $ result |= $ intReference ; } else { // Use all 8 bits from the 4th byte $ result <<= 8 ; $ result |= $ intReference ; // Check if the integer should be negative if ( ( $ result & 0x10000000 ) != 0 ) { //and extend the sign bit $ result |= ~ 0xFFFFFFF ; } } return $ result ; }
docstring: Read and deserialize an integer
  
  AMF 3 represents smaller integers with fewer bytes using the most
  significant bit of each byte. The worst case uses 32-bits
  to represent a 29-bit number, which is what we would have
  done with no compression.
  - 0x00000000 - 0x0000007F : 0xxxxxxx
  - 0x00000080 - 0x00003FFF : 1xxxxxxx 0xxxxxxx
  - 0x00004000 - 0x001FFFFF : 1xxxxxxx 1xxxxxxx 0xxxxxxx
  - 0x00200000 - 0x3FFFFFFF : 1xxxxxxx 1xxxxxxx 1xxxxxxx xxxxxxxx
  - 0x40000000 - 0xFFFFFFFF : throw range exception
  
  0x04 -> integer type code, followed by up to 4 bytes of data.
  
  Parsing integers on OSFlash for the AMF3 integer data format:
  @link http://osflash.org/amf3/parsing_integers
  @return int|float
docstring_tokens: Read and deserialize an integer