PHPStan 1.7.15 brings small, but helpful feature: support for relative paths in editorUrl
for virtualised environments. It’s even better when it makes you a repository collaborator - yes, it’s my initiative! 🥹
Working with PHPStan is great when you use editorUrl
configuration. It adds clickable link in the CLI output, which opens reported file at specific line. It improves productivity because you need less time to jump between analysis report and the codebase. Of course, you can configure your IDE to do real-time analysis, but it’s whole different story… maybe next time 😉
Anyway, having editorUrl
is great, but until 1.7.15 it was not helpful when you run PHPStan analysis in virtualised environment, like Docker or Vagrant. It’s because local paths are most often different from paths in container / virtual machine - clickable link will have wrong path and IDE won’t open it properly. It also wasn’t possible to determine actual paths because PHPStan inside container doesn’t have information about host’s filesystem.
In this release, support for relFile
was added, so you can configure PHPStan like this:
# phpstan.neon
includes:
- phpstan.neon.dist
parameters:
editorUrl: 'phpstorm://open?file=/your/local/path/%%relFile%%&line=%%line%%'
This will generate clickable links based on your local path to the project’s root directory, so IDE will open it correctly 🎉.