I'm working on a data serialization routine wherein I must iterate through
an object's properties while distinguishing between "sealed" properties
(i.e., those specified by class definitions) and "dynamic" properties"
(i.e., those assigned ad-hoc to some object that are not party of any class
definition).

I found the source of the php function get_object_vars():
http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985
However, I am still pretty confused. PHP source is *full* of macros and has
basically no comments. Hoping for some tips to keep me on the right track.
I'm pretty sure I can get something kludgy working, but I want my code to
be orthodox and work well.

QUESTIONS
1) Sadly, this approach is unable to distinguish "sealed" properties from
dynamic ones. If anyone can refer me to some source (or outline a general
approach) which can first iterate sealed properties and then iterate only
dynamic ones, that would be extremely helpful.

2) What does zend_objects_get_address do? This reference looks very
different than the usual macro, e.g. Z_OBJ_HT_P

3) Am I correct in understanding that zend_check_property_access simply
checks if the property in question is availabe in the scope in which this
function call gets executed? Is this the canonical/orthodox way to make
this check?

4) What does zend_unmangle_property_name do? Why is this function changed
to zend_unmangle_property_name_ex in 5.5 and later?

5) Why do we call Z_ADDREF_PP(value) here? Is this reference counting to
prevent garbage collection?

6) An IS_INTERNED check is added in php 5.6 and yet the macro for
IS_INTERNED is zero. What's that all about?

7) The code looks quite different between the different versions:
5.3 - http://lxr.php.net/xref/PHP_5_3/Zend/zend_builtin_functions.c#950
5.5 - http://lxr.php.net/xref/PHP_5_5/Zend/zend_builtin_functions.c#982
5.6 - http://lxr.php.net/xref/PHP_5_6/Zend/zend_builtin_functions.c#985
>From what I can tell there is at least one difference between 5.3 and 5.6
-- zend_unmangle_property_name_ex does not exist before 5.5. Can anyone
recommend how to make code that'll work in 5.3-5.6? Also, with 7 coming out
I'd like it work there too.

Any answers or assistance would be greatly appreciated.

Reply via email to