Created
March 8, 2012 06:28
-
-
Save hjr3/1999181 to your computer and use it in GitHub Desktop.
XML response output from DBGP for PHP arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def xml_on_element(self, node): | |
if node.nodeName == 'property': | |
self.type = node.getAttribute('type') | |
name = node.getAttribute('name') | |
fullname = node.getAttribute('fullname') | |
if name == '': | |
name = 'EVAL_RESULT' | |
if fullname == '': | |
fullname = 'EVAL_RESULT' | |
if self.type == 'uninitialized': | |
return str(('%-20s' % name) + " = /* uninitialized */'';") | |
else: | |
return str('%-20s' % fullname) + ' = (' + self.type + ') ' # <----- nested array gets here | |
elif node.nodeName == 'response': | |
return "$command = '" + node.getAttribute('command') + "'" | |
else: | |
return VimWindow.xml_on_element(self, node) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- $a = array(1,2,3); --> | |
<?xml version="1.0" encoding="iso-8859-1"?> | |
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="12"> | |
<property address="140737043230608" type="array" children="1" numchildren="3" page="0" pagesize="32"> | |
<property name="0" address="266646504" type="int"><![CDATA[1]]></property> | |
<property name="1" address="266646552" type="int"><![CDATA[2]]></property> | |
<property name="2" address="266647840" type="int"><![CDATA[3]]></property> | |
</property> | |
</response> | |
<!-- $a = array( array(1), array(2), array(3),); --> | |
<?xml version="1.0" encoding="iso-8859-1"?> | |
<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="eval" transaction_id="8"> | |
<property address="140736875083056" type="array" children="1" numchildren="3" page="0" pagesize="32"> | |
<property name="0" address="139683984" type="array" children="1" numchildren="1"></property> | |
<property name="1" address="139689760" type="array" children="1" numchildren="1"></property> | |
<property name="2" address="139690200" type="array" children="1" numchildren="1"></property> | |
</property> | |
</response> |
hm, seems like the plugin uses eval to get to property values, that is wrong. It should run a property_get:
http://xdebug.org/docs-dbgp.php#property-get-property-set-property-value
In the future, could you also post the commands that the IDE sends to Xdebug? Makes it a bit easier to track down.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The xml dump shows the difference between a simple array and a nested array. The simple array is handled fine because the response provides CDATA values within the property tag. The nested array is not handled fine because the response has no value in the property tag, so the best the debugger.py file does is print out the type. I show the code-snippet from debugger.py that handles the nested array.
I am not sure how to handle the nested array response. I can write the code to recurse through the nested array, but what command do I send to DBGP?