public function __construct() { $args = func_get_args(); if (count($args)) { $data = array_shift($args); parent::__construct($data); $defaultValue = ''; if (!empty($args[0]) && is_array($args[0])) { $args = $args[0]; } foreach ($args as $key_index => $key_value) { if (is_scalar($key_index)) { if (is_numeric($key_index)) { $value = !empty($this->_data[$key_index]) ? $this->_data[$key_index] : $defaultValue; $key_index = $key_value; $key_value = $value; } // $this->_keys[] = $key_index; if (!isset($this->_data[$key_index])) { $this->_data[$key_index] = $key_value; } } } } }
/** * Constructor * * Sets the $_SESSION superglobal to an ArrayObject, maintaining previous * values if any discovered. * * @param null|array|ArrayAccess $input * @param int $flags * @param string $iteratorClass * @return void */ public function __construct($input = null, $flags = \ArrayObject::ARRAY_AS_PROPS, $iteratorClass = '\\ArrayIterator') { $resetSession = true; if (null === $input && isset($_SESSION)) { $input = $_SESSION; if (is_object($input) && $_SESSION instanceof \ArrayObject) { $resetSession = false; } elseif (is_object($input) && !$_SESSION instanceof \ArrayObject) { $input = (array) $input; } } elseif (null === $input) { $input = array(); } parent::__construct($input, $flags, $iteratorClass); if ($resetSession) { $_SESSION = $this; } }