Repository navigation
[XDebug Bridge] Fetch all array keys when inspecting an array - #2409
Conversation
|
I think I found a way to avoid having that duplicate array inside itself. When paginating, the last element is the element itself with : So instead of injecting the object itself again in the array, let's check if the current page is actually '0' and add it. Do nothing otherwise.
// Use same depth/context as parent
this.objectHandles.set(childObjectId, {
type: 'property',
depth: depth,
contextId: contextId,
fullname: prop.$.fullname || name,
});
+ if (prop.$.page == 0) {
currentProps.push({
name: prop.$.key || name,
value: {
type: 'object',
className: className,
description: className,
objectId: childObjectId,
},
writable: false,
configurable: false,
enumerable: true,
});
+ }
} else { |
|
@adamziel would you like me to take over this pull request? |
|
@mho22 yes please, thank you! |
|
I think your solution is great : const responseProps =
response.property?.property ?? response.property;Based on my findings in a previous comment, it seems like the last element of an array is the array itself without its I will also try to add multiple tests to cover what has been added in this pull request. |
|
I added the complete set of tests for the Xdebug bridge. And a specific test for the nested array relative to this pull request, the last test in the |
|
Thank you @mho22! |
Motivation for the change, related issues
Fixes two problems:
property_getXDebug command is paginated and before this PR, we'd only see a subset of all the array keys. With this PR, we see all the keys. This will be a problem on huge arrays so we'll need to bucket keys into group of 1000 in a follow-up PR.As for the latter, I'm not too happy about the solution – we're reaching for the nested XDebug
.property.propertywhen it's available. I expect that will lead us astray in some scenarios, e.g. when browsing arrays that have nested arrays. That being said, I couldn't easily break it so let's get it in and continue iterating:Testing instructions
Create a file called
xdebug.php:Run
nx run php-wasm-cli:dev --xdebug --experimental-devtools xdebug.phpbefore and after this PR. Confirm you see the following results:Before
After ($_SERVER is still duplicated – let's fix that separately)