Skip to content

Conversation

cs278
Copy link
Contributor

@cs278 cs278 commented Feb 14, 2025

Recently discovered the editorUrl property but it's a bit of a chore to go and set it in the many projects I have locally.

Fortunately it's possible to reuse the xdebug extensions configuration which a number of other projects do:

So there is decent precedent for this, I've searched previous issues/pulls/discussions and only found a single reference to this in the context of PHPStan which kinda incorrectly concluded it wasn't possible.

I'm not sure if my implementation is correct but it certainly works, it was the easiest way I could find of adding a default value to a property at runtime which can be completely overridden by the configuration files. Happy to make any changes that are needed though if the premise is acceptable.

The configuration files will override the xdebug configuration.
@ondrejmirtes
Copy link
Member

Hi, this isn't going to work for multiple reasons.

  1. PHPStan's editorUrl and XDebug's file_link_format use different placeholders. PHPStan is using %file and %line, but XDebug is using %f and %l.
  2. People sometimes have some JavaScript in their XDebug's file_link_format, as recommended by the manual: https://xdebug.org/docs/all_settings#file_link_format This also isn't something that's going to work in PHPStan's context.

I recommend you to have a global phpstan.neon in your ~ home directory with PHPStan-compatible editorUrl setting, and include it in your environment-specific phpstan.neon in your projects, like this:

includes:
    - /home/cs278/phpstan.neon # my global config
    - phpstan.neon.dist # local project config

More about that here https://phpstan.org/config-reference#multiple-files

@cs278 cs278 deleted the autoconfigure-editor-links branch February 14, 2025 15:37
@cs278
Copy link
Contributor Author

cs278 commented Feb 14, 2025

  1. PHPStan's editorUrl and XDebug's file_link_format use different placeholders. PHPStan is using %file and %line, but XDebug is using %f and %l.

I sorted that by translating the xdebug setting.

2. People sometimes have some JavaScript in their XDebug's file_link_format, as recommended by the manual: xdebug.org/docs/all_settings#file_link_format This also isn't something that's going to work in PHPStan's context.

Was not aware of that, could ignore any prefixed with javascript:

I recommend you to have a global phpstan.neon in your ~ home directory with PHPStan-compatible editorUrl setting, and include it in your environment-specific phpstan.neon in your projects, like this:

Sure, I've seen this advice but sadly it's a bit limiting as it doesn't seem to respect $HOME or ~ to resolve my home directory which varies and isn't tolerant of the file not existing.

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

Successfully merging this pull request may close these issues.

2 participants