[xdebug-general] Re: DBGp: determine the collection type (array vs hash) OR get full names from the eval() call

From: Kirill Safonov <kirill.safonov[@]gmail.com>
Date: Tue, 26 Jan 2010 00:26:30 +0300

Hello Derick,

Thanks for a quick reply,

Our current infrastructure provides only a string to evaluate, so immediate
solution is just to call 'eval' on it. We'll think of how to improve/rework
this.

Regards,
 Kirill

-----Original Message-----
From: Derick Rethans [mailto:derick[@]xdebug.org]
Sent: Monday, January 25, 2010 9:07 PM
To: Kirill Safonov
Cc: xdebug-general[@]lists.xdebug.org
Subject: Re: [xdebug-general] DBGp: determine the collection type (array vs
hash) OR get full names from the eval() call

On Mon, 25 Jan 2010, Kirill Safonov wrote:

> Is there any way to determine PHP collection type (array with integer keys
> vs dictionary with object keys) via DBGp protocol?
>
> property_get()result contains full names, i.e.
>
> Sent:
>
> property_get -i 67 -n $wp_styles -p 0
>
> Received:

[snip]

> But when eval() is called, there are no full names there:
>
> Sent:
>
> eval -i 110 -c 0 -- JHdwX3N0eWxlcw== ($wp_styles)
>
> Received:

[snip]

> If I want to read the contents of child variables (below max_depth), I
need
> to invoke property_get() for each of them, using full names. Eval gives no
> full names, so when constructing full name from the chain of parent names,
I
> need a way to distinguish integer keys from object ones, i.e.
> ($wp_styles->registered['wp-admin'] vs $wp_styles->registered[wp-admin]).
In
> the current case 'wp-admin' does not look like an integer, but one can use
> string keys which may be looking unclear (my_array[123] vs
my_array['123'])?
> If I knew which type of collection I have I could construct a valid full
> name. Or, alternatively, I need a way to get a valid full name from eval()
> call.

My question for you is, why do you want to use "eval" here?

Internally it uses PHP's eval() and the return value of this doesn't
know to which variable it belongs (as it could just be "eval 4+4;" which
doesn't have a variable name of course). Your solution here is to use
property_get always.

with kind regards,
Derick

-- 
Like Xdebug? Send a postcard: http://derickrethans.nl/xdebug_2_released.php
Xdebug | http://xdebug.org | xdebug-general@lists.xdebug.org
twitter: @derickr and @xdebug
Received on Mon Jan 25 2010 - 21:26:34 GMT

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST