|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-11-26 11:40 UTC] t dot prochazka at centrum dot cz
Description:
------------
PHP has no advanced support for serialization.
I think, that is problem, that PHP serialize all properties. What about add single keyword (as transient) for property which can't be serializable?
Example:
class Foo {
public $a;
public transient $b;
}
Description of Java transient keyword:
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#78119
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 20:00:02 2025 UTC |
Using a transient keyword is better because if we have the following case: class A { $a; $b; } class B extends A { $c function __sleep() { return array("c"); } } now if you serialize b you will not serialize the $a and $b members from class A. So the sleep functions actually changes the encapsulated behaviour of A. Or we should call the superclass A::__sleep() method and join that with the new arrow. However this is much cleaner code. And wether a member is transient or not should be declered nearby the member to keep else other developers may not now wether the member will be serialized or not.