Search code examples
phpvisual-studio-debuggingneovimxdebug-3scope-resolution-operator

Why DAP adapter shows this error on this expression evaluation (which has :: operator)?


I'm rather new to PHP and now I'm debugging an app with the DAP adapter in NeoVim (and it uses the VS Code PHP dap adapter).

I paused on a breakpoint where this particular expression is present:

return Security::READ_WRITE === $this->visibility;

It evaluates to true in the real world, i.e. not in the REPL console. Even if I continue from the breakpoint, let alone, if I just run the request as the user would do, i.e. w/o any debugger.

When I run

dap> $this->visibility
2

It evaluates to 2.

But when I try to evaluate Security::READ_WRITE:

dap> Security::READ_WRITE
error evaluating code
dap> 

It throws.

Sorry for may be a silly question, but I really had to ask it. An answer I'd appreciate to receive would either tell if it's something wrong with the debugger or I don't understand the :: double colon operator and how those use imports work.

Thank you, including for the understanding that I can't share more of the production code.


Solution

  • The reason was that for some reasons XDebug has troubles with aliased namespaces.

    In my case the php file had this (altered the actual identifier, but the idea should be clear):

    use \OurSpecial_Security as Security;
    

    So in the DAP Repl console, one should've used:

    dap> OurSpecial_Security::READ_WRITE
    

    then I works