Re: Re: protected/private access and var_dump/print_r
| From: | Andi Gutmans | Date: | Thu, 20 May 2004 08:37:37 +0000 |
| Subject: | Re: Re: protected/private access and var_dump/print_r | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9957@lists.php.net to get a copy of this message | ||
Fine with me. I'm not sure printing public is a bad idea. How many ppl actually use this in their application for purposes other than debugging?
At 09:28 AM 5/20/2004 +0200, Andrey Hristov wrote:
Andi Gutmans wrote:At 11:42 AM 5/18/2004 +0200, Christian Schneider wrote:So, I have made a patch against HEAD : http://hristov.com/andrey/projects/php_stuff/patches/var_dump.diff.2.txt php -r 'class a{ protected $a=1; private $b=2;var $c=3;} $a=new a(); var_dump($a);' produces : object(a)#1 (3) { ["a:protected"]=> int(1) ["b:private"]=> int(2) ["c"]=> int(3) } I hope that everyone will be happy with this. var_dump() is still BC since it does not print ":public" on public properties. AndreySara Golemon wrote:I agree that showing all PPP makes more sense for these functions. They are mainly debugging tools and for human inspection. Information hiding is important on the language level itself. Andivar_dump($someobject); shows only public properties (as I'd expect), but print_r($someobject) shows all properties (explicitly identifying protected/private props).I agree with Derick and Andrey in that if anything should be changed it is var_dump. Reasoning: PPP is there to specify an interface, not to be used in a sandbox way. Both var_dump and print_r are for human inspection and I don't an advantage in hiding information there, quite the opposite.