New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for relative paths in editorUrl
#1414
Support for relative paths in editorUrl
#1414
Conversation
c7f7912
to
723ba37
Compare
Covers changes from phpstan/phpstan-src#1414
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Needs a test
- It's not going to work with the default
relativePathHelper
configured for TableErrorFormatter (FuzzyRelativePathHelper). It has more complex logic which doesn't always result in relative path starting at CWD. You need to injectsimpleRelativePathHelper
there as a 2nd one and use that. - I don't like
rel_file
, all names are camelCaps now.
@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
Thank you very much! I finally got it and it's nice! |
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 馃槈