Open
Conversation
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.
Add PHPStan Editor Mode Support
Fixes: WI-58890
Summary
This PR adds support for PHPStan's editor mode, which resolves issues with
ignoreErrorsconfiguration not working correctly during on-the-fly analysis in PhpStorm.Fix file mapping for temp files: When PhpStorm performs on-the-fly analysis, it creates temporary copies of files. PHPStan's
ignoreErrorsrules (configured inphpstan.neon) match against file paths, so errors that should be ignored based on the original file path were incorrectly being reported because PHPStan saw the temp file path instead.Add version detection: Editor mode (
--tmp-file/--instead-ofCLI options) is only available in PHPStan 1.12.27+ and 2.1.17+. The plugin now detects the PHPStan version and only enables editor mode when supported.Changes
File Mapping (
PhpStanAnnotatorProxy.java)Editor Mode Command Options (
PhpStanGlobalInspection.java)getCommandLineOptions()overload for editor mode that uses:--tmp-file <temp-path>- specifies the temp file containing current editor content--instead-of <original-path>- tells PHPStan to treat errors as coming from the original pathVersion Support (
PhpStanVersionSupport.java)extractVersionFromOutput()- parses version string from PHPStan outputsupportsEditorMode()- checks version compatibility (1.12.27+ or 2.1.17+)detectVersion()- runsphpstan --versionfor auto-detectionConfiguration Changes
PhpStanConfiguration.java- stores detected PHPStan versionPhpStanConfigurableForm.java- captures version during tool validationNote: I had to rebuild the gradle build system for this repo since there didn't seem to be any build system in place. I left that on a separate branch to avoid adding more than the fix to this pull request.
Test Plan
I need guidance on testing. I tested it with my local phpstorm and it worked.
This is the test plan I came up with:
ignoreErrorsrules inphpstan.neonare respected during on-the-fly analysis