Re: Deeply nested properties
| From: | Steph | Date: | Mon, 01 Aug 2005 17:37:44 +0000 |
| Subject: | Re: Deeply nested properties | ||
| References: | 1 2 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-1501@lists.php.net to get a copy of this message | ||
> Andrei Zmievski wrote:
>
> > a) expose everything and let those who use var_dump() haphazardly
suffer.
> > b) do not expose GtkStyle properties.
> >
> > Option b) means that you will not see any properties on var_dump
> > ($style), that get_object_vars($style) will return an empty array, and
> > so on. You would still be able to access them normally, $style- >fg etc.
>
> I vote for a. I can't think of a good reason off the top of my head but
> I am sure some one at some point will want to do this:
>
> foreach (get_object_vars($style) as $key => $value) {
> ....
> }
>
> Scott
ugh - that's 'haphazardly' :)
It's a tough decision because GtkStyle isn't a widget. I don't have GTK 2
source handy but, assuming it's the same principle as GTK 1, GtkStyle's not
even cast as an object - it's just a struct, pure'n'simple. So I'd look at
that as a documentation issue rather than as a dev issue - would you expect
get_object_vars() to return the (nested or otherwise) properties of a
third-party struct? Likewise, what would you expect var_dump() to return?
ps Andrei I took advice on irc and it was suggested I look at ext/simplexml
for a precedent, but I'm afraid I didn't get far with that 'cos as far as I
can see php_sxe_object _is_ treated as a genuine object....? (soap looked
more promising).