Re: do_declare_property()

From: Date: Wed, 12 Jul 2000 15:29:13 +0000
Subject: Re: do_declare_property()
References: 1 2 3 4 5 6 7 8  Groups: php.dev 
Request: Send a blank email to php-dev+get-24342@lists.php.net to get a copy of this message
Hi Andi! On Wed, 12 Jul 2000, Andi Gutmans wrote: > I think you missed what I said. > Consider the following example: > function foo($obj) > { > $obj->bar; > } > > You have no idea what type (and/or class type) $obj is at compile-time. > So you can't know if $obj's bar property is private or not. > However, if you'd have the following syntax: > function foo(class MyObject $obj) > { > $obj->bar; > } > You could know at compile time if the MyObject class's bar member was > defined as private. Oh, I think I got your point, but I was referring to something different. In the case of `__' hack, the anti-privateness programmer would have to write $obj->__bar;' to directly access __bar' member (be it whatever type). But, if we rewrite it to _Class__bar, s/he will get a null (so we succeded in hiding it from direct access). I haven't looked at Mathieu's code yet (though I am not even familiar with Zend API :^) and don't know how did he implemented the `private' stuff, but I though you already have the class information attached to an object instance (e.g. where does var_dump() get it from?) so you can go to those get_class_vars() attributes and check for privateness. -- teodor

« previous php.dev (#24342) next »