Support for relative paths in editorUrl
#1414
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows running PHPStan within Docker environment and output errors with links to files on the host (
editorUrl
must be configured using actual host's path to the project +%rel_file%
).Fixes phpstan/phpstan#7043
I decided to use
%rel_file%
because there wasRelativePathHelper
already in the formatter, so it was almost non-invasive. Other options would require much more work and many other files modified.I wanted to add test for it, but honestly I don't know how to do it 🤔 I created test similar to
TableErrorFormatterTest::testEditorUrlWithTrait()
but flow of outputting errors does not allow to check ifhref
added to message is correct - it's missing in the output retrieved with$this->getOutputContent()
. Anyway, I was able to test it with Docker runtime created locally and it works:Screenshot shows PHPStan analysis within Docker container, at the bottom you can see tooltip with href that is shown when mouse cursor is over the activated link - it's proper host's path, not container's one (which is
/etc/phpstan/...
).FYI:
~/Dev
is a symlink to/Volumes/Projects/
, if CLI prompt looks suspicious 😉