public function toArray(Clazz $componentType, SSSR_BoundedList $buffer) { if ($buffer->getExpectedSize() != $buffer->size()) { throw new SerializationException('Inconsistent number of elements received. Received ' . $buffer->size() . ' but expecting ' . $buffer->getExpectedSize()); } $arr = ArrayType::newInstance(null, $buffer->size()); for ($i = 0, $n = $buffer->size(); $i < $n; $i++) { $this->setSingleValue($arr, $i, $buffer->removeFirst()); } return $arr; }
public function visitArray(ArrayValueCommand $x, Context $ctx) { if ($this->maybePushBackRef($x)) { $values = $x->getComponentValues(); $array = ArrayType::newInstance(null, count($values)); $size = count($values); for ($i = 0; $i < $size; $i++) { $this->accept($values[$i]); $array[$i] = array_pop($this->values); } $this->push($x, $array); } return false; }