Make Docker and Apple container actually work with flycheck-phpstan - #63
Merged
zonuexe merged 3 commits intoJul 17, 2026
Merged
Conversation
`phpstan-get-command-args' translated the config file with
`phpstan-normalize-path', but handed the analyzed file to PHPStan as a
host path. A containerized PHPStan only sees the project through its
mount point, so it answered
Path /Users/.../test-docker.php does not exist
and reported no errors at all. `flycheck-phpstan' was therefore unusable
with `(phpstan-executable . docker)'; `flymake-phpstan' worked only for
modified buffers, because it normalized the temporary file itself while
passing an unnormalized path for the unmodified case.
Normalize the paths in `phpstan-get-command-args', which is the one place
that already knows about the mount point, and drop the now-redundant call
in `flymake-phpstan--create-temp-file' so the translation lives in a
single place.
The `--tmp-file' branch needs more than translation: `:temp-file' creates
the copy in the system temporary directory, which is not mounted into the
container and hence invisible to it. Use the in-place copy instead when
running containerized, so the file lands inside the project. That branch
is only reachable for containers with `phpstan-activate-editor-mode' set
to `enabled', since version detection currently disables editor mode for
them, but it is wrong either way.
`phpstan--parse-json' deliberately skips everything before the first line
starting with `{', so that whatever the process wrote to STDERR is
ignored -- the checker process merges STDERR into STDOUT.
Its caller disagreed: it only chose the JSON branch when the *whole*
output started with `{'. Docker happens to stay quiet once the image is
local, so this went unnoticed, but Apple container reports its progress
on STDERR for every run:
[0/6] [0s]
[1/6] Fetching image [0s]
...
That prefix meant the JSON was never parsed, and every check came back
with no errors. Look for a line starting with `{' instead, which is the
same condition `phpstan--parse-json' then acts on.
When the output held no JSON report, `flycheck-phpstan-parse-output' built
a warning carrying the raw output -- and then dropped it on the floor:
(data (if json? (phpstan--parse-json ...)
(list (flycheck-error-new-at 1 1 'warning ...))))
(errors (phpstan--plist-to-alist (plist-get data :files)))
In the fallback branch DATA is a list of `flycheck-error', so `plist-get'
found no `:files' and returned nil, and the warning never reached
flycheck. Every failure that stopped PHPStan from producing a report --
a broken configuration file, a bad `-c' path, a crash -- was shown to the
user as a buffer with no errors.
Return the warning directly. With a config file PHPStan cannot use, the
checker now says
Bootstrap file /.../tests/bootstrap.php does not exist.
instead of nothing at all.
zonuexe
merged commit Jul 17, 2026
ace4531
into
feature/flycheck-generic-checker
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.
Makes Docker and Apple container actually work with
flycheck-phpstan. Both were broken before #62 as well — #62 wired the runtimes up correctly, but three separate defects downstream meant a containerized check still reported nothing.Stacked on #62. Please merge that first; this branch targets it.
The three defects
1. The analyzed file was passed as a host path.
phpstan-get-command-argstranslated the config file withphpstan-normalize-pathbut not the target, so PHPStan answeredPath /Users/.../test-docker.php does not existand reported no errors.flymake-phpstandodged this for modified buffers by normalizing the temp file itself, but was affected for unmodified ones.Normalization now happens in
phpstan-get-command-args, the one place that already knows about the mount point, and the redundant call inflymake-phpstan--create-temp-fileis dropped so there is a single source of truth.The
--tmp-filebranch needed more than translation::temp-filecreates the copy in the system temporary directory, which is not mounted and therefore invisible to the container. It now uses the in-place copy when containerized. That branch is only reachable for containers withphpstan-activate-editor-modeset toenabled, since version detection currently disables editor mode for them, but it was wrong either way.2. The JSON report was ignored when prefixed.
phpstan--parse-jsondeliberately skips everything before the first line starting with{, because the checker process merges STDERR into STDOUT. Its caller disagreed and only took the JSON branch when the whole output started with{. Docker stays quiet once the image is local, so this went unnoticed — but Apple container reports progress on STDERR for every run:so the JSON was never parsed and every check came back clean.
3. Failures were discarded. When there was no JSON at all, the fallback built a warning holding the raw output and then threw it away —
datais a list offlycheck-error, so(plist-get data :files)returned nil. Every failure that stopped PHPStan from producing a report (broken config, bad-cpath, a crash) was shown as a buffer with no errors. This is why the two defects above were silent rather than loud.Verification
Ran Flycheck for real against
ghcr.io/phpstan/phpstanon both runtimes:phpstan-activate-editor-mode=enabled(--tmp-file)("docker" "run" ...)explicit formAll match what local
vendor/bin/phpstanreports for the same fixture, with no leftover temporary files. Local (non-container) execution is unchanged. With a config file PHPStan cannot use, the checker now reportsBootstrap file /.../tests/bootstrap.php does not exist.instead of nothing.Still open
phpstan-editor-mode-available-prunsdocker --versionand parsesd1c06efout ofDocker version 29.5.3, build d1c06efas the PHPStan version, so editor mode stays silently disabled for container users — they get the in-place copy branch, which works. Fixing it needs a design decision (runningIMAGE --versioncosts a container start per check, and thephpstan-executable-versions-alistcache is keyed by executable string), so it is left for a follow-up.