View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000925 | Xdebug | public | 2013-02-15 21:56 | 2013-06-22 13:39 | |
Reporter | bobl | Assigned To | derick | ||
Priority | normal | Severity | crash | Reproducibility | always |
Status | resolved | Resolution | unable to reproduce | ||
Platform | eclipse-pdt | OS | windows7 | OS Version | sp1 |
Product Version | 2.2.1 | ||||
Summary | 0000925: crash accessing php object properties | ||||
Description | Something funny happens with object property access described below. Note I encountered this inspecting various objects generated using json_decode() output. <?php More details are below in steps to reproduce. Thank you! | ||||
Steps To Reproduce | http://stackoverflow.com/questions/14902335/need-help-understanding-php-object-property-names-versus-array-keys (see steps to reproduce) I'm having some trouble using PHP object property names in a flexible way, similar to array keys. My understanding is that an array key can be any string or integer, e.g $arr = array("crash-me" => "value"); is a valid key/value pair. Now if I "cast" that to an object: $obj = (object) $arr; have I done something illegal, because of the dash in the key string? A simple example shows my dilema: <?php This will crash eclipse-pdt using xdebug when you inspect the value of the $obj before the print_r(). However, without bp, contents are printed correctly from print_r() at exit. stdClass Object ( [crash-me] => Array ( ) ) Note that if I stuff something into the array when assigning it to the property, things are OK: $obj = new stdClass; Bottom-line, I'd like to use property names with dashes and possibly other punctuation similar to array key. Is it possible? Or am I doing something illegal by assigning an empty array, in which case wouldn't an error be caught? Thanks ahead for your kind consideration! on edit, I forgot another part of puzzle - the code below does not crash. In this case, the property name does not have a dash, however, the array key is empty! $obj = new stdClass; Sorry for the confusion! It's probably something obvious I am missing. On second edit- To clarify, I was hoping to read property names from json_decode() and simply use the objects without having to convert to arrays. It was an experiment with dynamic code generation using keys from json data files. Per discussion below, looks like if I want to continue with PHP for this, I'll need the $arr['key1']['key2']... syntax and have the decoder use the "array" flag. Thanks for the great replies! | ||||
Tags | No tags attached. | ||||
Operating System | wind7 sp1 | ||||
PHP Version | 5.3.15-5.3.19 | ||||
|
Could you please try Xdebug 2.2.3 which has just been released? I am suspecting that release might fix this issue. |
|
Hello - can you please try 2.2.3? |
|
Unable to reproduce, and no feedback provided. Please reopen if this is still an issue for you. |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-02-15 21:56 | bobl | New Issue | |
2013-05-22 05:48 | derick | Note Added: 0002479 | |
2013-05-22 05:48 | derick | Assigned To | => derick |
2013-05-22 05:48 | derick | Status | new => feedback |
2013-06-09 10:21 | derick | Note Added: 0002499 | |
2013-06-22 13:39 | derick | Note Added: 0002514 | |
2013-06-22 13:39 | derick | Status | feedback => resolved |
2013-06-22 13:39 | derick | Resolution | open => unable to reproduce |
2016-07-31 12:35 | derick | Category | Debug client (console) => debugclient (debugging tool) |
2016-07-31 12:35 | derick | Category | debugclient (debugging tool) => (No Category) |