Serializing objects, best way to distinguish 'orthodox' object properties from dynamic ones?

From: Date: Mon, 16 Feb 2015 19:20:10 +0000
Subject: Serializing objects, best way to distinguish 'orthodox' object properties from dynamic ones?
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-12597@lists.php.net to get a copy of this message
I'm working on a PECL extension to implement proper AMF3 serialization for objects. I have two major questions. 1) HOW DO I DISTINGUISH ORTHODOX OBJECT PROPERTIES FROM DYNAMICALLY ASSIGNED ONES? According to the spec, objects are serialized differently if they contain only the 'orthodox' properties of a class then they are if they contain dynamic qualities assigned in an ad-hoc fashion. For example if I define a class like this: class foo { public $orth1 = "orth prop 1"; public $orth2 = "orth prop 2"; } and then I create two objects: $a = new foo(); $b = new foo(); $b->dynamic_property = "this is a dynamic property"; Then object $a has only orthodox properties defined by the class but object $b has an extra dynamic property and must be serialized differently. Can anyone suggest the best method to distinguish orthodox properties from dynamic ones? Or at least a way to get a list (HashTable?) of the properties that belong to a class? 2) HOW DOES ONE DEFINE A CLASS WITH ONE'S PECL EXTENSION? AMF3 serialization allows for a user-defined serialization technic and the serialization code is supposed to detect the intention to implement this by determining whether in object implements the iExternalizable interface (The idea is similar to __serialize magic method). I see that certain PHP modules (e.g., mysqli) define classes in PHP space. Can anyone refer me to a good extisting example where a class is defined by PECL extension or PHP core code? Also, how does one determine what interfaces a ZVAL object might be implementing? Any help would be truly appreciated. For anyone who is curious, the AMF3 spec is here: http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/amf/pdf/amf-file-format-spec.pdf

« previous php.pecl.dev (#12597) next »