View Issue Details

IDProjectCategoryView StatusLast Update
0002384XdebugStep Debuggingpublic2025-11-10 16:18
Reporterstaabm Assigned Toderick  
PrioritynormalSeverityfeatureReproducibilityalways
Status assignedResolutionopen 
Product Version3.4.6 
Summary0002384: customize variable representation in PHPStorm
Description

when step debuggin the phpstan-src codebase there are a few types which are ubiquitous.

it would be great, if php userland source code could customize the "description" of variables in the "Threads & Variables"-debug-panel, so we can provide information which is most often required and the developer don't need to constantly expand/collapse variable types.

I would imagine someting similar, we can do with __debugInfo() and var_dump().

so for example, I would want to see the value "cat1" of a PHPStan\Type\Constant\ConstantStringType variable, without the need of expanding it in said panel.
same is true for PHPStan\TrinaryLogic type. it would be super helpful to see at the top level whether which value the object is wrapping (1/0/-1)

Steps To Reproduce

put a break-point into PHPStan\Type\Constant\ConstantArrayTypeBuilder::__construct() and look for the $isList parameter (a TrinaryLogic object).
when the breakpoint is hit, it would be great if I would see on the first sight whether $isList wrapps 1 or 0 or -1, without the need to expand the object shape.

Additional Information

I can imagine it could work by implementing a new "magic-"method on the corresponding class, e.g. a __xdebugInfo(): string which would return specific information as a string, to be printed by the debugger in the debug panel.

TagsNo tags attached.
Attached Files
screenshot.png (248,559 bytes)   
screenshot.png (248,559 bytes)   
Operating System
PHP Version8.4.10-8.4.19

Activities

derick

2025-11-10 16:06

administrator   ~0007401

Last edited: 2025-11-10 16:07

  • Would this "description" be in addition to the normal properties, or replace the existing ones?
  • What should the name of this fake "description" property be? (I usually use $__UPPERCASE_NAME, like for $__RETURN_VALUE and $__INTERMEDIATE_VALUE).
  • Does it matter whether it returns a string or mixed? The IDE should be able to render it regardless.
  • Would you expect this description to also show up when Xdebug renders variables in other contexts, such as stack traces, or xdebug_var_dump()?

There might be situations where when Xdebug is in "break" mode, it's not possible to call functions safely. But it is also hard to know up front which situations this can be in. I think I would like to put this behind a feature flag — but that means that IDEs will need to add support for opting in, into this.

staabm

2025-11-10 16:18

reporter   ~0007402

Would this "description" be in addition to the normal properties, or replace the existing ones?

I think the description would be in addition to existing properties, but it would be shown to the user even before the object is expanded.
(therefore I think it cannot be printed side-by-side with existing properties, because this would not fit the purpose of this feature request).

see screenshot, which depicts the example of a TrinaryLogic property type: I would expect the "additional description" object be printed right beside the property which has this type.
I am not sure it needs a separate label.

Does it matter whether it returns a string or mixed? The IDE should be able to render it regardless.

I would be fine with any scalar type. as soon as we start adding complex information, like arrays etc. we would likely get visual problems, because there is not enough room for printing such data

Would you expect this description to also show up when Xdebug renders variables in other contexts, such as stack traces

I don't think so. I am usually searching such information in the "Threads & Variables" panel

... , or xdebug_var_dump()?

never used this utility. I have no opinion on this one.

grafik.png (75,404 bytes)   
grafik.png (75,404 bytes)   

Issue History

Date Modified Username Field Change
2025-11-10 15:34 staabm New Issue
2025-11-10 15:34 staabm File Added: screenshot.png
2025-11-10 16:06 derick Assigned To => derick
2025-11-10 16:06 derick Status new => feedback
2025-11-10 16:06 derick Note Added: 0007401
2025-11-10 16:06 derick Note Edited: 0007401
2025-11-10 16:07 derick Note Edited: 0007401
2025-11-10 16:18 staabm Note Added: 0007402
2025-11-10 16:18 staabm File Added: grafik.png
2025-11-10 16:18 staabm Status feedback => assigned