On Sun, Jan 20, 2013 at 8:45 AM, Gustavo Lopes <glo...@nebm.ist.utl.pt>wrote:

> On Sun, 20 Jan 2013 14:35:14 +0100, Sherif Ramadan <
> theanomaly...@gmail.com> wrote:
>
>> What I'm saying is this kind of behavior needs far more serious reasoning
>> than the very naive assesment you're making above.
>>
>> I mean that with all due respect. Just wondering if there is another take
>> on this from anyone else?
>>
>>
> I think the current behavior is most appropriate one for var_dump() (and
> array casts/get_object_vars()). It's the same behavior as if you had
> manually defined getXXX() methods or used __get().
>

It's actually not the same behavior at all. __get can only work on
inaccessible properties. So I would not see NULL there in the object and
then get a value in the instance property.


>
> If you start marking function calls, you get new problems like handling
> getters that throw exceptions or have side effects ("the code behaves
> differently when add a var_dump()?!").


I'm not suggesting the getters should be invoked from afar. I'm just
suggesting some additional means of informing the user of the existence of
that getter to distinguish it from the property in the output of var_dump.

So for example, in var_dump, you can get ["property":protected] => ... when
the property has a visibility outside of the current context. It might be
helpful to provide some similar behavior for accessors with null
initialized values, but have getters available to the caller?

Just a thought.


>
>
> --
> Gustavo Lopes
>

Reply via email to