protected function readAmf3Object()
{
$handle = $this->readAmf3Int();
$inline = ($handle & 1) != 0;
$handle = $handle >> 1;
if ($inline) {
//an inline object
$inlineClassDef = ($handle & 1) != 0;
$handle = $handle >> 1;
if ($inlineClassDef) {
//inline class-def
$typeIdentifier = $this->readAmf3String();
$typedObject = !is_null($typeIdentifier) && $typeIdentifier != '';
//flags that identify the way the object is serialized/deserialized
$externalizable = ($handle & 1) != 0;
$handle = $handle >> 1;
$dynamic = ($handle & 1) != 0;
$handle = $handle >> 1;
$classMemberCount = $handle;
$classMemberDefinitions = array();
for ($i = 0; $i < $classMemberCount; $i++) {
$classMemberDefinitions[] = $this->readAmf3String();
}
$classDefinition = array('type' => $typeIdentifier, 'members' => $classMemberDefinitions, 'externalizable' => $externalizable, 'dynamic' => $dynamic);
$this->storedDefinitions[] = $classDefinition;
} else {
//a reference to a previously passed class-def
$classDefinition = $this->storedDefinitions[$handle];
}
} else {
//an object reference
return $this->storedObjects[$handle];
}
$typeIdentifier = $classDefinition['type'];
$obj = $this->resolveType($typeIdentifier);
//Add to references as circular references may search for this object
$this->storedObjects[] =& $obj;
if ($classDefinition['externalizable']) {
if ($typeIdentifier == 'flex.messaging.io.ArrayCollection' || $typeIdentifier == 'flex.messaging.io.ObjectProxy') {
//special for Flex. This doesn't belong here, but it's the least worst way I found to support returning them
$obj = $this->readAmf3Data();
} else {
$externalizedDataField = Amfphp_Core_Amf_Constants::FIELD_EXTERNALIZED_DATA;
$obj->{$externalizedDataField} = $this->readAmf3Data();
}
} else {
$members = $classDefinition['members'];
$memberCount = count($members);
for ($i = 0; $i < $memberCount; $i++) {
$val = $this->readAmf3Data();
$key = $members[$i];
$obj->{$key} = $val;
}
if ($classDefinition['dynamic']) {
$key = $this->readAmf3String();
while ($key != '') {
$value = $this->readAmf3Data();
$obj->{$key} = $value;
$key = $this->readAmf3String();
}
}
}
return $obj;
}