Req #30324 [Opn->Csd]: serialize() should work on internal classes
| From: | nikic@php.net | Date: | Sun, 23 Sep 2012 16:40:55 +0000 |
| Subject: | Req #30324 [Opn->Csd]: serialize() should work on internal classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-173658@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=30324&edit=1
ID: 30324
Updated by: nikic@php.net
Reported by: matthias dot hoseit at comline dot de
Summary: serialize() should work on internal classes
-Status: Open
+Status: Closed
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: *
PHP Version: 5.0.*
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Closing as serialization for internal classes is already supported if the class implements it.
Previous Comments:
------------------------------------------------------------------------
[2004-10-04 19:40:36] helly@php.net
serialize() works on internal classes. It doesn't work on virtual properties and this problem
usually occurs with internal classes.
What you want is more control over serialization. Eventually the solution is a set of new magic
callbacks
function /* string */ __serialize()
static function /* instance */ __unserialize(string $data)
__serialze() would need to return the string used to recreate the instance and __unserialize() would
recreate it from the passed string. We could also make __unserialize() a non static fucntion in
which case the instance would be created prior to calling the function. However the static
functionality allows much more flexibility.
For example the static functionality allows instance creation through factory methods and they could
store the information needed to reread a xml document or reopen a database connection.
------------------------------------------------------------------------
[2004-10-04 17:00:56] matthias dot hoseit at comline dot de
Description:
------------
The function serialize() should work on internal classes like DOMDocument. I my opinion this could
be a nice Feature.
Best Regards Matthias Hoseit
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=30324&edit=1