最近更新了 VS Code + PHP XDebug - 禁用“自动扩展数据”数组/对象

发布于 2025-01-09 21:18:58 字数 2240 浏览 5 评论 0原文

Visual Studio Code 的最近更新(不确定是哪一个,自从去年年底取消更新以来我昨天更新了)改变了 XDebug 中 PHP 调试的行为(甚至使用 DEVSENSE 中的 PHP 工具扩展)现在有了这个“自动扩展数据”功能,其中数组和对象现在显示数组/对象内联的值,对于 Magento 2 来说,这使得调试现在变得非常麻烦。

我不应该升级!!!

  • 当显示大对象时,VS Code 现在会更频繁地崩溃,因为它现在想要自动扩展每个私有变量Magento 2 对象也是如此

  • 由于扩展功能“自动扩展”,扩展了变量值,现在已经不太清楚哪些是私有/受保护/公共值了。

最近添加了哪些设置,我们如何禁用它?

示例

新示例:旧

> 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"

:显然,

> 0:array(2)
> 1:array(2)
> 2:array(2)
> 3:array(2)

“旧方式”(今天更新 VS Code 之前)更简洁且更易于阅读,我给出了一个数组示例,因为 Magento 2 对象只会导致 VS Code 崩溃(因此无法显示一个确切的例子)。

对于对象来说更糟糕,查看(调试时)任何 Magento 2 对象现在都会跨越 1000 行,VS Code 几乎每次都会崩溃)

我不需要这个功能,而只是想从函数/变量中访问和查看我需要的值:

例如,当我现在从终端获取 $this->getCollection() 时,我会得到 1000 个不需要的值(私有事情扩大了)。

在调试终端中

// 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 在评论中也提到了这一点,我忘了提及(因为我刚刚提供了有关终端命令视图的信息),但这也发生在我身上。

监视区域显示正确的树结构。代码中的变量上的鼠标悬停是有问题的。

VS Code 版本:

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 调试 (Xdebug) v1.24.2

Last updated 23/02/2022, 09:00:55
Identifier xdebug.php-debug

服务器上的 XDebug:(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

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?

Example

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');

How can I disable this feature?

Additional information

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

多像笑话 2025-01-16 21:18:59

自动扩展问题与 PHP 调试问题有关。

此问题与 PHP 调试 ~v1.24.1 或 v1.24.2 有关。感谢@zobo 为解决问题提供的快速帮助,非常感谢!

解决方案:

安装他的新更新:VS Code 扩展 PHP 调试 v1.24.3

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文