vscode-php-debug icon indicating copy to clipboard operation
vscode-php-debug copied to clipboard

Sort Object properties in Variables view

Open G3z opened this issue 9 years ago • 9 comments

PHP version: 5.5.9 XDebug version: 2.4.0 Adapter version: 1.9.1

is it possible to sort object properties alphabetically? schermata 2016-06-21 alle 17 26 43

G3z avatar Jun 21 '16 15:06 G3z

I just send them to VS Code in the same order I get them from XDebug. XDebug sorts them like they are defined I think, and doesn't distinguish between object properties and variables. So I don't know if it woud be good to change this.

felixfbecker avatar Jun 21 '16 15:06 felixfbecker

Well in my code $base is defined before $anagrafica so I think XDebug sorts the first level. I think it would be more user friendly to have variable sorted

G3z avatar Jun 21 '16 15:06 G3z

it would definitelly be good to change order of properties. It is annoyting when you cannot find property because of no sort order. If for somebody it is useful tha they are not sorted, then you could let user itself to choose if he wants to sort or not. Its not the firtst time that I cannot find. And then I have to add additional watch like $object->getProperty() to see its value !

darius-v avatar Jul 27 '18 18:07 darius-v

The context variables (Locals, Superglobals...) are sorted, but keys in an array are not. And I would not change this as the order might be important. Perhaps we could do this with classes/objects, but even there I'd rather not introduce behavior different from native PHP.

And there is a type/search function in VS Code now, so finding something you are looking for should be better.

zobo avatar May 10 '21 08:05 zobo

I think this is needed, at least sorting variables and object properties. Keys in arrays can be more problematic. VS code type/search is not comfortable enough to use constantly, time and time again

ghost avatar Apr 19 '23 22:04 ghost

Moreover, in IDEs like PHPStorm there is a setting that can enable sorting properties alphabetically while in debug mode, and it's a major enhancement when working say with entities that have 100+ properties.

wadamczyk-insolutions avatar Mar 13 '24 09:03 wadamczyk-insolutions

The context variables (Locals, Superglobals...) are sorted, but keys in an array are not. And I would not change this as the order might be important.

What are the criteria for the default order ? If no one knows, that might not be as important ?

Maybe order could become an option ?

In PHPStorm it seems it is. And the alphabetical order might be the default as I don't recall the need to modify the option when I was using this IDE ?

And there is a type/search function in VS Code now

I tried to focus the variable window and type something, and indeed that brings focus to the occurrence. Typing again seems to focus on the next one. So yes this is indeed a workaround, but :

  • not easy to find,
  • and also not as convenient as the alphabetical order as for objects you generally want to check multiple attributes values

piRGoif avatar Nov 26 '25 10:11 piRGoif

I'll revisit this as an option...

zobo avatar Nov 26 '25 12:11 zobo

I'll revisit this as an option...

Many thanks !

piRGoif avatar Nov 26 '25 13:11 piRGoif