On Sun, Jan 20, 2013 at 10:31 AM, Clint Priest <cpri...@zerocue.com> wrote:

>
> On 1/20/2013 7:35 AM, Sherif Ramadan wrote:
>
>   Now $surface shows us the following from var_dump....
>
>  object(surface)#1 (3) {
>   ["area"]=>
>   NULL
>   ["width"]=>
>   int(4)
>   ["height"]=>
>   int(2)
> }
>
> Sounds like a reasonable approach to me... var_dump()
>
> 1) Should not invoke the getters..
>

I can agree this since the side effects could be unpredictable (as in the
case of an accessor implementing an actual method rather than dealing with
with any values -- the performance loss is unjustified)


> 2) Should indicate that they are property accessors (perhaps not even show
> the underlying guarded property?)
>

That is a sensible approach to me.


>
> Possibly:
>
>  object(surface)#1 (3) {
>   ["area":accessor]=>
>   NULL
>   ["width":accessor]=>
>   int(4)
>   ["height":accessor]=>
>   int(2)
> }
>
> This could easily be changed if nobody had any further disagreements with
> this?
>
> Only issue I could see would be existing code that may parse var_dump()
> might break if it wasn't written to accept something other that
> private/protected...
>

I think that one should rely on serialize or json_* serialization methods
or parsing data structures as opposed to var_dump output, since var_dump
doesn't always provide parseable output. Look at the output of DateTime
objects from var_dump or DateInterval objects, which have changed a bit
over 5.2 -> 5.3 and other objects like DOMDocument, which at one point did
not have any meaningful var_dump output at all.


>
>
> --
> -Clint
>

Reply via email to