Support for relative paths in editorUrl#1414
Merged
ondrejmirtes merged 5 commits intophpstan:1.7.xfrom Jun 18, 2022
Merged
Conversation
c7f7912 to
723ba37
Compare
Wirone
added a commit
to Wirone/phpstan
that referenced
this pull request
Jun 11, 2022
Covers changes from phpstan/phpstan-src#1414
ondrejmirtes
requested changes
Jun 12, 2022
Member
ondrejmirtes
left a comment
There was a problem hiding this comment.
- Needs a test
- It's not going to work with the default
relativePathHelperconfigured for TableErrorFormatter (FuzzyRelativePathHelper). It has more complex logic which doesn't always result in relative path starting at CWD. You need to injectsimpleRelativePathHelperthere as a 2nd one and use that. - I don't like
rel_file, all names are camelCaps now.
Contributor
Author
|
@ondrejmirtes how would you like to test it? Because when I debug it: I see that there's no EDIT: Decorated output stream did the trick 🙂 |
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
723ba37 to
7d030de
Compare
Member
|
Thank you very much! I finally got it and it's nice! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 (
editorUrlmust be configured using actual host's path to the project +%rel_file%).Fixes phpstan/phpstan#7043
I decided to use
%rel_file%because there wasRelativePathHelperalready 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 ifhrefadded 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:
~/Devis a symlink to/Volumes/Projects/, if CLI prompt looks suspicious 😉