Пример #1
0
 /**
  * Write PHP array, as table. Input array format: keys are strings,
  * values are (type,value) tuples.
  *
  * @param AMQPTable|array $d Instance of AMQPTable or PHP array WITH format hints (unlike write_array())
  * @return self
  * @throws PhpAmqpLib_Exception_AMQPInvalidArgumentException
  */
 public function write_table($d)
 {
     $typeIsSym = !$d instanceof AMQPTable;
     //purely for back-compat purposes
     $table_data = new PhpAmqpLib_Wire_AMQPWriter();
     foreach ($d as $k => $va) {
         list($ftype, $v) = $va;
         $table_data->write_shortstr($k);
         $table_data->write_value($typeIsSym ? PhpAmqpLib_Wire_AMQPAbstractCollection::getDataTypeForSymbol($ftype) : $ftype, $v);
     }
     $table_data = $table_data->getvalue();
     $this->write_long(mb_strlen($table_data, 'ASCII'));
     $this->write($table_data);
     return $this;
 }