protected function readAmf3Vector($type)
{
/* AMF Spec: "The first (low) bit is a flag with value 1. The remaining 1 to 28 significant bits are used to encode the count of
items in Vector." */
// according to the above - $inline will always be 1 after the bitshift, and what remains in $handle
// after the bitshift is the count of the vector
$handle = $this->readAmf3Int();
$inline = ($handle & 1) != 0;
$handle = $handle >> 1;
if ($inline) {
$vector = new Amfphp_Core_Amf_Types_Vector();
$vector->type = $type;
/* AMF Spec: "Boolean U8 value, 0x00 if not a fixed-length Vector, otherwise 0x01 if fixed-length." */
// we are not really concerned in PHP if the vector is fixed-length right now.
$vector->fixed = $this->readByte();
$vector->data = array();
$this->storedObjects[] =& $vector;
if ($type === Amfphp_Core_Amf_Types_Vector::VECTOR_OBJECT) {
$vector->className = $this->readAmf3String();
for ($i = 0; $i < $handle; $i++) {
//Grab the type for each element.
$vector->data[] = $this->readAmf3Data();
}
} else {
switch ($type) {
case Amfphp_Core_Amf_Types_Vector::VECTOR_INT:
$length = 4;
$format = "ival";
break;
case Amfphp_Core_Amf_Types_Vector::VECTOR_UINT:
$length = 4;
$format = "Ival";
break;
case Amfphp_Core_Amf_Types_Vector::VECTOR_DOUBLE:
$length = 8;
$format = "dval";
break;
}
for ($i = 0; $i < $handle; $i++) {
//Grab the type for each element.
$vector->data[] = $this->readAmf3VectorValue($length, $format);
}
}
return $vector;
} else {
return $this->storedObjects[$handle];
}
}