Skip to content

Commit 61f5d68

Browse files
committed
Fixing serialization bug with strict collections
1 parent defa020 commit 61f5d68

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/AbstractStrictCollection.php

+36-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,18 @@ public function __construct(array $data = array())
3939
* @return array
4040
*/
4141
abstract protected function getDefinition();
42-
42+
43+
/**
44+
* This method is called by var_dump() when dumping an object to get the properties that should be shown.
45+
* If the method isn't defined on an object, then all public, protected and private properties will be shown.
46+
* @return array
47+
* @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo
48+
*/
49+
public function __debugInfo()
50+
{
51+
return $this->_storage;
52+
}
53+
4354
/**
4455
* Whether a offset exists
4556
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
@@ -65,6 +76,30 @@ public function offsetGet($offset)
6576
throw $this->_createOutOfBoundsException($offset);
6677
}
6778

79+
/**
80+
* String representation of object
81+
* @link http://php.net/manual/en/serializable.serialize.php
82+
* @return string the string representation of the object or null
83+
*/
84+
public function serialize()
85+
{
86+
return serialize(array(
87+
$this->_definition,
88+
$this->_storage
89+
));
90+
}
91+
92+
/**
93+
* Constructs the object
94+
* @link http://php.net/manual/en/serializable.unserialize.php
95+
* @param string $serialized The string representation of the object.
96+
* @return void
97+
*/
98+
public function unserialize($serialized)
99+
{
100+
list($this->_definition, $this->_storage) = unserialize($serialized);
101+
}
102+
68103
/**
69104
* Offset to set
70105
* @link http://php.net/manual/en/arrayaccess.offsetset.php

0 commit comments

Comments
 (0)