Skip to content
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

Evaluate namespaces in debug console #951

Open
jeffam opened this issue Jan 25, 2024 · 1 comment
Open

Evaluate namespaces in debug console #951

jeffam opened this issue Jan 25, 2024 · 1 comment

Comments

@jeffam
Copy link

jeffam commented Jan 25, 2024

PHP version: 8.2.15
Xdebug version: 3.2.0
VS Code extension version: 1.34.0

When I test expressions in the debug console, I've noticed that namespaced classes don't seem to evaluate use statements.

For example, if I debug this code:

<?php

require '../vendor/autoload.php';

use XdebugNsTest\Bar;

$test = new Bar('Hello, World!');

var_dump($test instanceof Bar);

And enter the following in the debug console:

→  $test
 ❯ XdebugNsTest\Bar
→  $test instanceof Bar
   false
→  $test instanceof XdebugNsTest\Bar
   true

$test instanceof Bar returns false when I would expect it to return true.

@zobo
Copy link
Contributor

zobo commented Apr 2, 2024

Indeed that is the current way, as all code in the debug window is just passed to Xdebug eval command. And this is probably as it is in PHP as I believe use referencing happens in compile time and not run-time.

This is also something that's bothering me sometimes but I can hardly do much as it would require that this extension understood a lot more about PHP language as it does...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants