public function loadProperties(AMQPBufferReader $r)
 {
     // Read 16-bit shorts until we get one with a low bit set to zero
     $flags = array();
     while (true) {
         $flag_bits = $r->read_short();
         $flags[] = $flag_bits;
         if (($flag_bits & 1) == 0) {
             break;
         }
     }
     $shift = 0;
     $d = array();
     foreach ($this->prop_types as $key => $proptype) {
         if ($shift == 0) {
             if (!$flags) {
                 break;
             }
             $flag_bits = array_shift($flags);
             $shift = 15;
         }
         if ($flag_bits & 1 << $shift) {
             $d[$key] = $r->{'read_' . $proptype}();
         }
         $shift -= 1;
     }
     $this->properties = $d;
 }
 /**
  * Read an AMQP table, and return as a PHP array. keys are strings,
  * values are (type,value) tuples.
  *
  * @param bool $returnObject Whether to return AMQPTable instance instead of plain array
  * @return array|AMQPTable
  */
 public function read_table($returnObject = false)
 {
     $this->bitcount = $this->bits = 0;
     $tlen = $this->read_php_int();
     if ($tlen < 0) {
         throw new AMQPOutOfBoundsException('Table is longer than supported');
     }
     $table_data = new AMQPBufferReader($this->rawread($tlen));
     $result = $returnObject ? new AMQPTable() : array();
     while ($table_data->tell() < $tlen) {
         $name = $table_data->read_shortstr();
         $ftype = AMQPAbstractCollection::getDataTypeForSymbol($ftypeSym = $table_data->rawread(1));
         $val = $table_data->read_value($ftype, $returnObject);
         $returnObject ? $result->set($name, $val, $ftype) : ($result[$name] = array($ftypeSym, $val));
     }
     return $result;
 }