A recent update (not sure which, I updated yesterday since cancelling updates since end last year) of Visual Studio Code changed behavior of PHP Debug from XDebug (or even with PHP Tools extension from DEVSENSE) now has this 'auto-expand-data' feature, where arrays and objects now shows their values inline of the array/object, which in the case of Magento 2 makes debugging extremely cumbersome now.
I should have just not upgraded!!!
The VS Code would crash more often now when large objects are displayed, because it now wants to auto-expand every single private variable for a Magento 2 object as well
Since the extended feature 'auto-expands' variable values, it is not really clear anymore which are private/protected/public values any more.
Which recent settings are added, and how do we disable this?
New:
> 0:array(2)
0:"price"
1:"ASC"
> 1:array(2)
0:"name"
1:"ASC"
> 2:array(2)
0:"attr1"
1:"ASC"
> 3:array(2)
0:"attr2"
1:"ASC"
> 4:array(2)
0:"attr3"
1:"ASC"
Old:
> 0:array(2)
> 1:array(2)
> 2:array(2)
> 3:array(2)
Clearly the 'old way' (before updating VS Code today) is more concise and easier to read, I am giving an array example, since Magento 2 object would just cause VS Code to crash (so can't show an exact example).
It's even worse for objects, viewing (while debugging) any Magento 2 object now spans 1000s of lines, and VS Code will crash almost everytime)
I don't need this feature, and would rather just want to access and view values as I need them from functions/variables:
For instance, when I would get $this->getCollection() from terminal now, I would get 1000s of unneeded values (private things expanded).
In debug terminal
// First find out what Collection is
$this->getCollection()
// Now since Collection processed filters, I might want to investigate `getSelect`
$this->getCollection()->getSelect();
// Also investigate 'from'
$this->getSelect()->getPart('from');
TonyG mentioned this in the comments as well, which I forgot to mention (as I just gave information on terminal command view), but this also happens to me.
The Watch area shows correct tree structure. It's the mouse-over on variables in code that is problematic.
VS Code version:
Version: 1.64.2 (system setup)
Commit: f80445acd5a3dadef24aa209168452a3d97cc326
Date: 2022-02-09T22:02:28.252Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043
PHP Debug (Xdebug) v1.24.2
Last updated 23/02/2022, 09:00:55
Identifier xdebug.php-debug
XDebug on Server: (Ubuntu 20.04)
Zend Engine v3.3.21, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.21-1+ubuntu20.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v3.0.3, Copyright (c) 2002-2021, by Derick Rethans
The auto-expand issue was related to an issue with PHP Debug.
This issue was related to PHP Debug ~v1.24.1 or v1.24.2
. Thanks for @zobo for the quick assistance on resolving the issue, much appreciated!
Solution:
Install his new update: VS Code extension PHP Debug
v1.24.3