protected function &mapByReference(&$value)
{
if ($value instanceof Closure) {
if (isset($this->scope->storage[$value])) {
if (static::supportBinding()) {
$ret = $this->scope->storage[$value];
} else {
$ret = $this->scope->storage[$value]->reference;
}
return $ret;
}
$instance = new static($value, $this->serializeThis);
if (static::$context !== null) {
static::$context->scope->toserialize--;
} else {
$instance->scope = $this->scope;
}
$this->scope->storage[$value] = $instance;
return $instance;
} elseif (is_array($value)) {
$ret = array_map(array($this, __FUNCTION__), $value);
return $ret;
} elseif ($value instanceof \stdClass) {
$ret = (array) $value;
$ret = array_map(array($this, __FUNCTION__), $ret);
$ret = (object) $ret;
return $ret;
}
return $value;
}