Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Remove the conditional class declaration of ArrayObject #3684

Closed
wants to merge 3 commits into from

3 participants

@ircmaxell

Remove the conditional class declaration from ArrayObject
Always defining the custom class. This is because there's no
benefit to using the core one (only possible negatives).
Additionally, the conditional class declaration can play
havoc with opcode caches and certain extensions.

@ircmaxell ircmaxell Remove conditional class declaration
Remove the conditional class declaration from ArrayObject
Always defining the custom class. This is because there's no
benefit to using the core one (only possible negatives).
Additionally, the conditional class declaration can play
havoc with opcode caches and certain extensions.
df406a8
@mwillbanks
Collaborator

Hey; glad to see you here. Unfortunately the reason for the conditional class is because of PHP 5.3.3 support. We were actually testing opcode caching today with this change as well and @weierophinney can provide more details there.

Basically all of this is due to ArrayAccess not having the facility to allow offsetGet to return by reference in PHP 5.3.3 (http://www.php.net/arrayaccess). If you look at the build: https://travis-ci.org/zendframework/zf2/jobs/4608438 from reverting this you will see the failures that it causes - a complete cluster fuck if you know what I mean. We had a huge discussion on the mailing list around if we bump the minor PHP version to 5.3.5 or not and basically the decision was to not do it until distribution support widens.

Moving along to ArrayObject... it is even worse as you cannot provide a reference to be returned via offsetGet; additionally any bug reports or the like opened up on it in the past have all been marked as "bogus" which leads to this crazy behavior of having to rewrite ArrayObject to retain some form of BC in userland extending ArrayAccess but then it only works in PHP 5.3.4+.

The other thought that we had was providing different classes by changing the autoloader to look for deprecated versions by a different extension or the like. You will see a few of these conditional blocks now in order to fix unsetting multi-dimensional arrays. If you have any additional ideas by all means bring them up :)

@ircmaxell

Yeah, I realized that once I saw the test results from travis.

The way that I've solved this before is to use a bootstrap file to load polyfills. So you'd have a bootstrap file (that composer would include on every load) that would check the PHP version, and load the 5.3.3 version of the class (which lives in another directory, violating PSR-0 intentionally).

The benefit to doing that, is that you can transparently add any polyfill. For example, if you wanted to provide a core CallbackFilterIterator (which is only available in 5.4+), you could use the bootstrap mechanism to load it in. That way it auto-disables itself when you upgrade, and you don't need any funny logic in the autoloader.

Thoughts?

@weierophinney

@ircmaxell I like this idea. Can you provide links/references/etc on how to accomplish the composer side of things? We can document alternate workflows for those not using Composer fairly easily.

@weierophinney

I think I found it: http://getcomposer.org/doc/04-schema.md#files -- going to try and work something up now.

@ircmaxell

@weierophinney I'm working on a PR now (proof of concept at least). Give me a few minutes and I'll update this here...

@ircmaxell

@weierophinney I've updated this PR with the concept I posted above. I added a new root level folder called "compatibility" (the name can be tweaked if desired). Then I added a bootstrap.php file inside of it which does the conditional loading of the dependencies.

Future polyfills and version-dependent code could be added to that bootstrap.php file...

Thoughts?

@mwillbanks
Collaborator

I like this; question now becomes how do we handle cases where someone is downloading components of zf2; aka zend-session zend-stdlib etc where these polyfills will be needed. Seems like any circumstance that we hit in this case we need to always load those classes.

We could likely check to see if the component is installed or check the directories for which items are actually there. There are actually 2 additional cases where these need to be handled:
Zend\Session\Container and Zend\Session\Storage\SessionArrayStorage since they override ArrayAccess::offsetGet.

@weierophinney

I was just playing with this as well, @ircmaxell -- and came up with the same issues as @mwillbanks. We'd need to put the compatibility in each component that has such issues, and have the file loaded in the component composer.json as well as the framework composer.json.

The bigger problem, though, is that Composer is not properly creating the path to the script -- it's making it relative to the vendor directory, not the package directory. I'm going to see if I can figure that out.

@ircmaxell

Interesting.

Perhaps have the polyfill be a separate composer sub-package. That way, Stdlib would declare the polyfill package as a dependency. That SHOULD take care of this particular issue...

Or am I missing some part of it...

@weierophinney

Actually, the path is created correctly -- I was misinterpreting vendor/composer/autoload_real.php.

@weierophinney

@ircmaxell -- please wait on any further changes -- I'm working up a solution that will allow Stdlib to be shipped as a standalone package or as part of the framework.

@ircmaxell

I've updated it so that it can be a separate package (with composer support), having Stdlib's composer require it...

@weierophinney weierophinney referenced this pull request from a commit in weierophinney/zf2
@weierophinney weierophinney [#3684] Polyfill support for version-dependent classes
- Per ideas from @ircmaxell, removed the conditional declaration of classes in
  favor of an autoloading solution. If using 5.3.3, composer will now load an
  alternate Zend\Stdlib\ArrayObject implementation.

  Both the project- and component-level composer.json files were modified so
  that the change will take place regardless of whether you install the full
  framework or just the component.

- Made changes to the php-code-sniffer configuration to ensure that the
  PHP-5.3.3-specific ArrayObject implementation is not checked, as it violates
  PSR-0 intentionally.

  - Realized that travis-build could be simplified, as .php_cs has the expected
    configuration for the full framework.
834d631
@weierophinney weierophinney was assigned
@weierophinney weierophinney referenced this pull request from a commit in weierophinney/zf2
@weierophinney weierophinney [#3684] Do polyfill for Session component as well
- SessionArrayStorage and Container were both doing version-specific conditional
  declarations; moved these into a compat layer as was done in Stdlib, and
  updated the composer.json for each of the component and framework.
- Currently, the SessionConfigTest suite is not running for me, but appears to
  be a random autoloading error from running in isolated processes; will see how
  the Travis-CI run looks.
352a040
@ircmaxell

Closing PR as [#3684] solves this better...

@ircmaxell ircmaxell closed this
@weierophinney weierophinney referenced this pull request from a commit in weierophinney/zf2
@weierophinney weierophinney [#3684] Simplified .php_cs fixers declaration
- A constant exists for what I wanted... Thanks, @Maks3w
732360c
@weierophinney weierophinney referenced this pull request from a commit in weierophinney/zf2
@weierophinney weierophinney [#3684] Fix indentation
- Fixes docblock indentation in compat file
0b88086
@GordonSchmidt GordonSchmidt referenced this pull request in zendframework/ZendSkeletonApplication
Closed

SkeletonApplication with Zend Framework 2.1.1 #161

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3684] Polyfill support for version-dependent classes
- Per ideas from @ircmaxell, removed the conditional declaration of classes in
  favor of an autoloading solution. If using 5.3.3, composer will now load an
  alternate Zend\Stdlib\ArrayObject implementation.

  Both the project- and component-level composer.json files were modified so
  that the change will take place regardless of whether you install the full
  framework or just the component.

- Made changes to the php-code-sniffer configuration to ensure that the
  PHP-5.3.3-specific ArrayObject implementation is not checked, as it violates
  PSR-0 intentionally.

  - Realized that travis-build could be simplified, as .php_cs has the expected
    configuration for the full framework.
b0ee2ef
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3684] Do polyfill for Session component as well
- SessionArrayStorage and Container were both doing version-specific conditional
  declarations; moved these into a compat layer as was done in Stdlib, and
  updated the composer.json for each of the component and framework.
- Currently, the SessionConfigTest suite is not running for me, but appears to
  be a random autoloading error from running in isolated processes; will see how
  the Travis-CI run looks.
a26f21b
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3684] Simplified .php_cs fixers declaration
- A constant exists for what I wanted... Thanks, @Maks3w
1fc3c5d
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney [#3684] Fix indentation
- Fixes docblock indentation in compat file
76265a1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 6, 2013
  1. @ircmaxell

    Remove conditional class declaration

    ircmaxell authored
    Remove the conditional class declaration from ArrayObject
    Always defining the custom class. This is because there's no
    benefit to using the core one (only possible negatives).
    Additionally, the conditional class declaration can play
    havoc with opcode caches and certain extensions.
  2. @ircmaxell
  3. @ircmaxell
This page is out of date. Refresh to see the latest.
View
4 composer.json
@@ -23,6 +23,9 @@
"zendframework/zendservice-recaptcha": "ZendService\\ReCaptcha for rendering ReCaptchas in Zend\\Captcha and/or Zend\\Form"
},
"autoload": {
+ "files": [
+ "library/compatibility/bootstrap.php"
+ ],
"psr-0": {
"Zend\\": "library/",
"ZendTest\\": "tests/"
@@ -37,6 +40,7 @@
"zendframework/zend-cache": "self.version",
"zendframework/zend-captcha": "self.version",
"zendframework/zend-code": "self.version",
+ "zendframework/zend-compatibility": "self.version",
"zendframework/zend-config": "self.version",
"zendframework/zend-console": "self.version",
"zendframework/zend-crypt": "self.version",
View
715 library/Zend/Stdlib/ArrayObject.php
@@ -15,424 +15,405 @@
use Serializable;
use Countable;
-// use our own version of arrayobject to handle references
-if (version_compare(PHP_VERSION, '5.3.3') > 0) {
+/**
+ * ArrayObject
+ * This ArrayObject is a rewrite of the implementation to fix
+ * issues with php's implementation of ArrayObject where you
+ * are unable to unset multi-dimensional arrays because you
+ * need to fetch the properties / lists as references.
+ */
+class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Countable
+{
+ /**
+ * Properties of the object have their normal functionality
+ * when accessed as list (var_dump, foreach, etc.).
+ */
+ const STD_PROP_LIST = 1;
+
+ /**
+ * Entries can be accessed as properties (read and write).
+ */
+ const ARRAY_AS_PROPS = 2;
+
+ /**
+ * @var array
+ */
+ protected $storage;
+
/**
- * ArrayObject
- * This ArrayObject is a rewrite of the implementation to fix
- * issues with php's implementation of ArrayObject where you
- * are unable to unset multi-dimensional arrays because you
- * need to fetch the properties / lists as references.
+ * @var int
*/
- class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Countable
+ protected $flag;
+
+ /**
+ * @var string
+ */
+ protected $iteratorClass;
+
+ /**
+ * @var array
+ */
+ protected $protectedProperties;
+
+ /**
+ * Constructor
+ *
+ * @param array $input
+ * @param int $flags
+ * @param string $iteratorClass
+ * @return ArrayObject
+ */
+ public function __construct($input = array(), $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
{
- /**
- * Properties of the object have their normal functionality
- * when accessed as list (var_dump, foreach, etc.).
- */
- const STD_PROP_LIST = 1;
-
- /**
- * Entries can be accessed as properties (read and write).
- */
- const ARRAY_AS_PROPS = 2;
-
- /**
- * @var array
- */
- protected $storage;
-
- /**
- * @var int
- */
- protected $flag;
-
- /**
- * @var string
- */
- protected $iteratorClass;
-
- /**
- * @var array
- */
- protected $protectedProperties;
-
- /**
- * Constructor
- *
- * @param array $input
- * @param int $flags
- * @param string $iteratorClass
- * @return ArrayObject
- */
- public function __construct($input = array(), $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
- {
- $this->setFlags($flags);
- $this->storage = $input;
- $this->setIteratorClass($iteratorClass);
- $this->protectedProperties = array_keys(get_object_vars($this));
+ $this->setFlags($flags);
+ $this->storage = $input;
+ $this->setIteratorClass($iteratorClass);
+ $this->protectedProperties = array_keys(get_object_vars($this));
+ }
+
+ /**
+ * Returns whether the requested key exists
+ *
+ * @return boolean
+ */
+ public function __isset($key)
+ {
+ if ($this->flag == self::ARRAY_AS_PROPS) {
+ return $this->offsetExists($key);
+ }
+ if (in_array($key, $this->protectedProperties)) {
+ throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
}
- /**
- * Returns whether the requested key exists
- *
- * @return boolean
- */
- public function __isset($key)
- {
- if ($this->flag == self::ARRAY_AS_PROPS) {
- return $this->offsetExists($key);
- }
- if (in_array($key, $this->protectedProperties)) {
- throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
- }
+ return isset($this->$key);
+ }
- return isset($this->$key);
+ /**
+ * Sets the value at the specified key to value
+ *
+ * @param mixed $key
+ * @param mixed $value
+ * @return void
+ */
+ public function __set($key, $value)
+ {
+ if ($this->flag == self::ARRAY_AS_PROPS) {
+ return $this->offsetSet($key, $value);
}
-
- /**
- * Sets the value at the specified key to value
- *
- * @param mixed $key
- * @param mixed $value
- * @return void
- */
- public function __set($key, $value)
- {
- if ($this->flag == self::ARRAY_AS_PROPS) {
- return $this->offsetSet($key, $value);
- }
- if (in_array($key, $this->protectedProperties)) {
- throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
- }
- $this->$key = $value;
+ if (in_array($key, $this->protectedProperties)) {
+ throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
}
+ $this->$key = $value;
+ }
- /**
- * Unsets the value at the specified key
- *
- * @param mixed $key
- * @return void
- */
- public function __unset($key)
- {
- if ($this->flag == self::ARRAY_AS_PROPS) {
- return $this->offsetUnset($key);
- }
- if (in_array($key, $this->protectedProperties)) {
- throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
- }
- unset($this->$key);
+ /**
+ * Unsets the value at the specified key
+ *
+ * @param mixed $key
+ * @return void
+ */
+ public function __unset($key)
+ {
+ if ($this->flag == self::ARRAY_AS_PROPS) {
+ return $this->offsetUnset($key);
}
+ if (in_array($key, $this->protectedProperties)) {
+ throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
+ }
+ unset($this->$key);
+ }
- /**
- * Returns the value at the specified key by reference
- *
- * @param mixed $key
- * @return mixed
- */
- public function &__get($key)
- {
- $ret = null;
- if ($this->flag == self::ARRAY_AS_PROPS) {
- $ret =& $this->offsetGet($key);
-
- return $ret;
- }
- if (in_array($key, $this->protectedProperties)) {
- throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
- }
+ /**
+ * Returns the value at the specified key by reference
+ *
+ * @param mixed $key
+ * @return mixed
+ */
+ public function &__get($key)
+ {
+ $ret = null;
+ if ($this->flag == self::ARRAY_AS_PROPS) {
+ $ret =& $this->offsetGet($key);
- return $this->$key;
+ return $ret;
}
-
- /**
- * Appends the value
- *
- * @param mixed $value
- * @return void
- */
- public function append($value)
- {
- $this->storage[] = $value;
+ if (in_array($key, $this->protectedProperties)) {
+ throw new Exception\InvalidArgumentException('$key is a protected property, use a different key');
}
- /**
- * Sort the entries by value
- *
- * @return void
- */
- public function asort()
- {
- asort($this->storage);
- }
+ return $this->$key;
+ }
- /**
- * Get the number of public properties in the ArrayObject
- *
- * @return int
- */
- public function count()
- {
- return count($this->storage);
- }
+ /**
+ * Appends the value
+ *
+ * @param mixed $value
+ * @return void
+ */
+ public function append($value)
+ {
+ $this->storage[] = $value;
+ }
- /**
- * Exchange the array for another one.
- *
- * @param array $data
- * @return array
- */
- public function exchangeArray(array $data)
- {
- $storage = $this->storage;
+ /**
+ * Sort the entries by value
+ *
+ * @return void
+ */
+ public function asort()
+ {
+ asort($this->storage);
+ }
- $this->storage = $data;
+ /**
+ * Get the number of public properties in the ArrayObject
+ *
+ * @return int
+ */
+ public function count()
+ {
+ return count($this->storage);
+ }
- return $storage;
- }
+ /**
+ * Exchange the array for another one.
+ *
+ * @param array $data
+ * @return array
+ */
+ public function exchangeArray(array $data)
+ {
+ $storage = $this->storage;
- /**
- * Creates a copy of the ArrayObject.
- *
- * @return array
- */
- public function getArrayCopy()
- {
- return $this->storage;
- }
+ $this->storage = $data;
- /**
- * Gets the behavior flags.
- *
- * @return int
- */
- public function getFlags()
- {
- return $this->flag;
- }
+ return $storage;
+ }
- /**
- * Create a new iterator from an ArrayObject instance
- *
- * @return Iterator
- */
- public function getIterator()
- {
- $class = $this->iteratorClass;
+ /**
+ * Creates a copy of the ArrayObject.
+ *
+ * @return array
+ */
+ public function getArrayCopy()
+ {
+ return $this->storage;
+ }
- return new $class($this->storage);
- }
+ /**
+ * Gets the behavior flags.
+ *
+ * @return int
+ */
+ public function getFlags()
+ {
+ return $this->flag;
+ }
- /**
- * Gets the iterator classname for the ArrayObject.
- *
- * @return string
- */
- public function getIteratorClass()
- {
- return $this->iteratorClass;
- }
+ /**
+ * Create a new iterator from an ArrayObject instance
+ *
+ * @return Iterator
+ */
+ public function getIterator()
+ {
+ $class = $this->iteratorClass;
- /**
- * Sort the entries by key
- *
- * @return void
- */
- public function ksort()
- {
- ksort($this->storage);
- }
+ return new $class($this->storage);
+ }
- /**
- * Sort an array using a case insensitive "natural order" algorithm
- *
- * @return void
- */
- public function natcasesort()
- {
- natcasesort($this->storage);
- }
+ /**
+ * Gets the iterator classname for the ArrayObject.
+ *
+ * @return string
+ */
+ public function getIteratorClass()
+ {
+ return $this->iteratorClass;
+ }
- /**
- * Sort entries using a "natural order" algorithm
- *
- * @return void
- */
- public function natsort()
- {
- natsort($this->storage);
- }
+ /**
+ * Sort the entries by key
+ *
+ * @return void
+ */
+ public function ksort()
+ {
+ ksort($this->storage);
+ }
- /**
- * Returns whether the requested key exists
- *
- * @return boolean
- */
- public function offsetExists($key)
- {
- return isset($this->storage[$key]);
- }
+ /**
+ * Sort an array using a case insensitive "natural order" algorithm
+ *
+ * @return void
+ */
+ public function natcasesort()
+ {
+ natcasesort($this->storage);
+ }
- /**
- * Returns the value at the specified key
- *
- * @param mixed $key
- * @return mixed
- */
- public function &offsetGet($key)
- {
- $ret = null;
- if (!$this->offsetExists($key)) {
- return $ret;
- }
- $ret =& $this->storage[$key];
+ /**
+ * Sort entries using a "natural order" algorithm
+ *
+ * @return void
+ */
+ public function natsort()
+ {
+ natsort($this->storage);
+ }
+
+ /**
+ * Returns whether the requested key exists
+ *
+ * @return boolean
+ */
+ public function offsetExists($key)
+ {
+ return isset($this->storage[$key]);
+ }
+ /**
+ * Returns the value at the specified key
+ *
+ * @param mixed $key
+ * @return mixed
+ */
+ public function &offsetGet($key)
+ {
+ $ret = null;
+ if (!$this->offsetExists($key)) {
return $ret;
}
+ $ret =& $this->storage[$key];
- /**
- * Sets the value at the specified key to value
- *
- * @param mixed $key
- * @param mixed $value
- * @return void
- */
- public function offsetSet($key, $value)
- {
- $this->storage[$key] = $value;
- }
+ return $ret;
+ }
- /**
- * Unsets the value at the specified key
- *
- * @return void
- */
- public function offsetUnset($key)
- {
- if ($this->offsetExists($key)) {
- unset($this->storage[$key]);
- }
- }
+ /**
+ * Sets the value at the specified key to value
+ *
+ * @param mixed $key
+ * @param mixed $value
+ * @return void
+ */
+ public function offsetSet($key, $value)
+ {
+ $this->storage[$key] = $value;
+ }
- /**
- * Serialize an ArrayObject
- *
- * @return string
- */
- public function serialize()
- {
- return serialize(get_object_vars($this));
+ /**
+ * Unsets the value at the specified key
+ *
+ * @return void
+ */
+ public function offsetUnset($key)
+ {
+ if ($this->offsetExists($key)) {
+ unset($this->storage[$key]);
}
+ }
+
+ /**
+ * Serialize an ArrayObject
+ *
+ * @return string
+ */
+ public function serialize()
+ {
+ return serialize(get_object_vars($this));
+ }
+
+ /**
+ * Sets the behavior flags
+ *
+ * @param int $flags
+ * @return void
+ */
+ public function setFlags($flags)
+ {
+ $this->flag = $flags;
+ }
+
+ /**
+ * Sets the iterator classname for the ArrayObject
+ *
+ * @param string $class
+ * @return void
+ */
+ public function setIteratorClass($class)
+ {
+ if (class_exists($class)) {
+ $this->iteratorClass = $class;
- /**
- * Sets the behavior flags
- *
- * @param int $flags
- * @return void
- */
- public function setFlags($flags)
- {
- $this->flag = $flags;
+ return ;
}
- /**
- * Sets the iterator classname for the ArrayObject
- *
- * @param string $class
- * @return void
- */
- public function setIteratorClass($class)
- {
+ if (strpos($class, '\\') === 0) {
+ $class = '\\' . $class;
if (class_exists($class)) {
$this->iteratorClass = $class;
return ;
}
-
- if (strpos($class, '\\') === 0) {
- $class = '\\' . $class;
- if (class_exists($class)) {
- $this->iteratorClass = $class;
-
- return ;
- }
- }
-
- throw new Exception\InvalidArgumentException('The iterator class does not exist');
}
- /**
- * Sort the entries with a user-defined comparison function and maintain key association
- *
- * @param callable $function
- * @return void
- */
- public function uasort($function)
- {
- if (is_callable($function)) {
- uasort($this->storage, $function);
- }
- }
+ throw new Exception\InvalidArgumentException('The iterator class does not exist');
+ }
- /**
- * Sort the entries by keys using a user-defined comparison function
- *
- * @param callable $function
- * @return void
- */
- public function uksort($function)
- {
- if (is_callable($function)) {
- uksort($this->storage, $function);
- }
+ /**
+ * Sort the entries with a user-defined comparison function and maintain key association
+ *
+ * @param callable $function
+ * @return void
+ */
+ public function uasort($function)
+ {
+ if (is_callable($function)) {
+ uasort($this->storage, $function);
}
+ }
- /**
- * Unserialize an ArrayObject
- *
- * @param string $data
- * @return void
- */
- public function unserialize($data)
- {
- $ar = unserialize($data);
- $this->setFlags($ar['flag']);
- $this->exchangeArray($ar['storage']);
- $this->setIteratorClass($ar['iteratorClass']);
- foreach ($ar as $k => $v) {
- switch ($k) {
- case 'flag':
- $this->setFlags($v);
- break;
- case 'storage':
- $this->exchangeArray($v);
- break;
- case 'iteratorClass':
- $this->setIteratorClass($v);
- break;
- case 'protectedProperties':
- continue;
- default:
- $this->__set($k, $v);
- }
- }
+ /**
+ * Sort the entries by keys using a user-defined comparison function
+ *
+ * @param callable $function
+ * @return void
+ */
+ public function uksort($function)
+ {
+ if (is_callable($function)) {
+ uksort($this->storage, $function);
}
}
-} else {
- class ArrayObject extends PhpArrayObject
+
+ /**
+ * Unserialize an ArrayObject
+ *
+ * @param string $data
+ * @return void
+ */
+ public function unserialize($data)
{
- /**
- * Constructor
- *
- * @param array $input
- * @param int $flags
- * @param string $iteratorClass
- * @return ArrayObject
- */
- public function __construct($input = array(), $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
- {
- parent::__construct($input, $flags, $iteratorClass);
+ $ar = unserialize($data);
+ $this->setFlags($ar['flag']);
+ $this->exchangeArray($ar['storage']);
+ $this->setIteratorClass($ar['iteratorClass']);
+ foreach ($ar as $k => $v) {
+ switch ($k) {
+ case 'flag':
+ $this->setFlags($v);
+ break;
+ case 'storage':
+ $this->exchangeArray($v);
+ break;
+ case 'iteratorClass':
+ $this->setIteratorClass($v);
+ break;
+ case 'protectedProperties':
+ continue;
+ default:
+ $this->__set($k, $v);
+ }
}
}
-}
+}
View
3  library/Zend/Stdlib/composer.json
@@ -16,6 +16,7 @@
"pecl-weakref": "Implementation of weak references for Stdlib\\CallbackHandler"
},
"require": {
- "php": ">=5.3.3"
+ "php": ">=5.3.3",
+ "zendframework/zend-compatibility": "self.version"
}
}
View
33 library/compatibility/Zend/Stdlib/ArrayObject.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+namespace Zend\Stdlib;
+
+use ArrayObject as PhpArrayObject;
+
+/**
+ * This is a compatibility implementation of ArrayObject for PHP <= 5.3.3
+ * This is automatically loaded instead of the core implementation by the
+ * compatibility boostrap file
+ */
+class ArrayObject extends PhpArrayObject
+{
+ /**
+ * Constructor
+ *
+ * @param array $input
+ * @param int $flags
+ * @param string $iteratorClass
+ * @return ArrayObject
+ */
+ public function __construct($input = array(), $flags = self::STD_PROP_LIST, $iteratorClass = 'ArrayIterator')
+ {
+ parent::__construct($input, $flags, $iteratorClass);
+ }
+}
View
22 library/compatibility/bootstrap.php
@@ -0,0 +1,22 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+
+/**
+ * This file bootstraps in compatibility components to allow for backwards
+ * compatibility with versions of PHP.
+ */
+
+if (version_compare(PHP_VERSION, '5.3.3') <= 0) {
+ /**
+ * For PHP <= 5.3.3, we need to load a compatibility version of the
+ * Stdlib ArrayObject class. This overrides the normal ArrayObject version
+ * provided in library
+ */
+ require_once __DIR__ . '/Zend/Stdlib/ArrayObject.php';
+}
View
18 library/compatibility/composer.json
@@ -0,0 +1,18 @@
+{
+ "name": "zendframework/zend-compatibility",
+ "description": " ",
+ "license": "BSD-3-Clause",
+ "keywords": [
+ "zf2",
+ "compatibility"
+ ],
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "target-dir": "compatibility",
+ "require": {
+ "php": ">=5.3.3"
+ }
+}
Something went wrong with that request. Please try again.