Ejemplo n.º 1
0
 /**
  * Read an AMQP table, and return as a PHP array. keys are strings,
  * values are (type,value) tuples.
  */
 public function read_table()
 {
     $this->bitcount = $this->bits = 0;
     $tlen = $this->read_php_int();
     if ($tlen < 0) {
         throw new PhpAmqpLib_Exception_AMQPOutOfBoundsException("Table is longer than supported");
     }
     $table_data = new PhpAmqpLib_Wire_AMQPReader($this->rawread($tlen), null);
     $result = array();
     while ($table_data->tell() < $tlen) {
         $name = $table_data->read_shortstr();
         $ftype = $table_data->rawread(1);
         $val = $table_data->read_value($ftype);
         $result[$name] = array($ftype, $val);
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Read an AMQP table, and return as a PHP array. keys are strings,
  * values are (type,value) tuples.
  *
  * @param bool $returnObject Whether to return PhpAmqpLib_Wire_AMQPArray instance instead of plain array
  * @return array|PhpAmqpLib_Wire_AMQPTable
  */
 public function read_table($returnObject = false)
 {
     $this->bitcount = $this->bits = 0;
     $tlen = $this->read_php_int();
     if ($tlen < 0) {
         throw new PhpAmqpLib_Exception_AMQPOutOfBoundsException('Table is longer than supported');
     }
     $table_data = new PhpAmqpLib_Wire_AMQPReader($this->rawread($tlen), null);
     $result = $returnObject ? new PhpAmqpLib_Wire_AMQPTable() : array();
     while ($table_data->tell() < $tlen) {
         $name = $table_data->read_shortstr();
         $ftype = PhpAmqpLib_Wire_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;
 }