-
Notifications
You must be signed in to change notification settings - Fork 322
[XDebug Bridge] Fetch all array keys when inspecting an array #2409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
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. |
Motivation for the change, related issues
Fixes two problems:
property_get
XDebug 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.property
when 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
Run
nx run php-wasm-cli:dev --xdebug --devtools xdebug.php
before and after this PR. Confirm you see the following results:Before
After ($_SERVER is still duplicated – let's fix that separately)