SanderRonde / phpstan-vscode

PHPStan plugin for VSCode
https://marketplace.visualstudio.com/items?itemName=SanderRonde.phpstan-vscode
MIT License
40 stars 9 forks source link

Getting fatal errors about redefining "Logger" #15

Closed maxcohn closed 1 year ago

maxcohn commented 1 year ago

Hi, I'm getting some errors about redefining "Logger" in my code base. I suspect that this is because TreeFetcher.php is defining its own logger. Below is the extension's output:

[check:75] PHPStan process exited with error  err= PHP Fatal error:  Cannot declare class Logger, because the name is already in use in [redacted path] on line 4
Fatal error: Cannot declare class Logger, because the name is already in use in [redacted path] on line 4
  data= 

This appears when I use bootstrapFiles in my phpstan.neon. When I was trying to debug this and used the -a flag and passed it in so TreeFetcher.php got to run first, it pointed me towards seeing that it was defined there.

Do you happen to know a workaround for this? Otherwise (if it's not too much to ask), could Logger in TreeFetcher be renamed if it is in the global namespace to be something that's less likely to clash. I assume Logger is a pretty common class name in code bases (we both use it :)).

Let me know if there's any more info I can provide or work I can do here.

Thank you!

SanderRonde commented 1 year ago

Ah yeah I didn't think about it being put in the global namespace. Will fix it.

maxcohn commented 1 year ago

@SanderRonde Thank you!

maxcohn commented 1 year ago

@SanderRonde Apologies for bothering you, but when do you think the next release that includes your fix for this issue on the VS Code extension marketplace will be live?

SanderRonde commented 1 year ago

Ah sorry I thought I had already published it shortly after I made the initial commit but I didn't. Should be live in a few minutes (look for version 2.2.11).

maxcohn commented 1 year ago

@SanderRonde Oh no worries at all! You've been so helpful on top of already developing this handy extension. Thanks a ton!