Ask PHPStan for its version, not the program that launches it - #64
Merged
zonuexe merged 1 commit intoJul 17, 2026
Merged
Conversation
`phpstan-get-command-args' probed editor mode support with
(phpstan-editor-mode-available-p (car (phpstan-get-executable-and-args)))
but the car of that command line is only PHPStan itself when PHPStan is
directly executable. Everywhere else it is whatever launches PHPStan, and
that program answered for its own version:
* `(phpstan-executable . docker)' and `container' probed the runtime, so
`Docker version 29.5.3, build d1c06ef' parsed as version "d1c06ef";
* a PHAR without the executable bit runs as ("php" "..."), so PHP's
`--version' banner parsed as version "Technologies".
Neither starts with "1" or "2", so `phpstan-editor-mode-available-p'
returned nil and editor mode was silently off for every setup but one.
Pass the whole command line down and run `COMMAND... --version', which
reaches the real PHPStan in each case. Both `phpstan-version' and
`phpstan-editor-mode-available-p' still accept a bare string.
`phpstan-version' also captured STDERR, because `shell-command-to-string'
merges it. Apple container prints its progress there, so it would have
been read as part of the version; capture only STDOUT. Probing may now
have to start a container (measured at ~0.4s warm for Docker), so the
cache is keyed by the whole command line rather than the executable. For
a plain executable that key is unchanged.
Support is now treated as absent when the version cannot be determined,
rather than signalling from `elt' on an empty string.
zonuexe
merged commit Jul 17, 2026
ee0e42f
into
fix/container-path-normalization
12 of 14 checks passed
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.
Editor mode detection asked the wrong program for its version, so it was silently disabled for every setup except a directly executable
phpstan— not just for containers, as I first thought when filing this.Stacked on #63 (which is stacked on #62). Merge order: #62 → #63 → #64.
The bug
phpstan-get-command-argsprobed with:(phpstan-editor-mode-available-p (car (phpstan-get-executable-and-args)))The car of that command line is PHPStan itself only when PHPStan is directly executable. Everywhere else it is whatever launches PHPStan, and that program answered for its own version:
phpstan-executabledocker/container("docker" "run" ... IMAGE)docker --versiond1c06ef("docker" "run" ...)docker --versiond1c06ef+x("php" "/path/phpstan.phar")php --versionTechnologies("/path/phpstan")phpstan --version1.12.33✅phpstan-versiontakes the last whitespace-separated token, soDocker version 29.5.3, build d1c06efyieldsd1c06efand PHP's banner ending inZend TechnologiesyieldsTechnologies. Neither starts with1or2, sophpstan-editor-mode-available-preturned nil.It failed safe — those setups fell back to the in-place copy — but no one outside the one supported configuration ever got editor mode.
The fix
Pass the whole command line down and run
COMMAND... --version, which reaches the real PHPStan in every case.phpstan-versionandphpstan-editor-mode-available-pnow take a command list; a bare string is still accepted.Two details that fall out of this:
phpstan-versionusedshell-command-to-string, which merges STDERR. Apple container prints progress there, so it would have been read as part of the version. It now captures STDOUT only.Support is also treated as absent when the version cannot be determined, rather than signalling from
elton an empty string.Verification
Version detection, cache, and editor-mode decision, with the cache cleared per case:
phpstan-executablevendor/bin/phpstan(executable)1.12.33.phar(runs viaphp)1.12.33docker2.2.5("docker" "run" ...)2.2.5Cache: first probe 0.34s, second 0.000s.
With a modified buffer and auto-detection, both
dockerandcontainernow actually select editor mode and pass--tmp-file /app/INPLACE.php— the in-place copy introduced in #63, not the system temporary directory. That branch was unreachable by auto-detection until this fix; it only ran withphpstan-activate-editor-modeset toenabled.Full Flycheck runs against
ghcr.io/phpstan/phpstanstill pass on both runtimes with editor mode now on by default, and local execution is unchanged.