/** * @return string */ public static final function getProtocol() { if (self::$_protocol === null) { self::$_protocol = defined('AMQP_STRICT_FLD_TYPES') && AMQP_STRICT_FLD_TYPES ? PhpAmqpLib_Channel_AbstractChannel::getProtocolVersion() : self::PROTOCOL_RBT; } return self::$_protocol; }
/** * Reads the array in the next value. * * @param bool $returnObject Whether to return AMQPArray instance instead of plain array * @return array|PhpAmqpLib_Wire_AMQPArray */ public function read_array($returnObject = false) { $this->bitcount = $this->bits = 0; // Determine array length and its end position $arrayLength = $this->read_php_int(); $endOffset = $this->offset + $arrayLength; $result = $returnObject ? new PhpAmqpLib_Wire_AMQPArray() : array(); // Read values until we reach the end of the array while ($this->offset < $endOffset) { $fieldType = PhpAmqpLib_Wire_AMQPAbstractCollection::getDataTypeForSymbol($this->rawread(1)); $fieldValue = $this->read_value($fieldType, $returnObject); $returnObject ? $result->push($fieldValue, $fieldType) : ($result[] = $fieldValue); } return $result; }
/** * @param int $type One of PhpAmqpLib_Wire_AMQPAbstractCollection::T_* constants * @param mixed $val */ private function write_value($type, $val) { //This will find appropriate symbol for given data type for currently selected protocol //Also will raise an exception on unknown type $this->write(PhpAmqpLib_Wire_AMQPAbstractCollection::getSymbolForDataType($type)); switch ($type) { case PhpAmqpLib_Wire_AMQPAbstractCollection::T_INT_SHORTSHORT: $this->write_signed_octet($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_INT_SHORTSHORT_U: $this->write_octet($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_INT_SHORT: $this->write_signed_short($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_INT_SHORT_U: $this->write_short($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_INT_LONG: $this->write_signed_long($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_INT_LONG_U: $this->write_long($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_INT_LONGLONG: $this->write_signed_longlong($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_INT_LONGLONG_U: $this->write_longlong($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_DECIMAL: $this->write_octet($val->e); $this->write_signed_long($val->n); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_TIMESTAMP: $this->write_timestamp($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_BOOL: $this->write_octet($val ? 1 : 0); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_STRING_SHORT: $this->write_shortstr($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_STRING_LONG: $this->write_longstr($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_ARRAY: $this->write_array($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_TABLE: $this->write_table($val); break; case PhpAmqpLib_Wire_AMQPAbstractCollection::T_VOID: break; default: throw new PhpAmqpLib_Exception_AMQPInvalidArgumentException(sprintf('Unsupported type "%s"', $type)); } }
public function __construct(array $data = null) { parent::__construct(empty($data) ? null : array_values($data)); }