PHPStan baseline files generated
Preliminary checklist
- [x] I am using the latest stable version of DDEV
- [x] I am using the latest stable version of this add-on
Expected Behavior
After running ddev phpstan, no new files appear
Actual Behavior
After running ddev phpstan, I have untracked files in my checkout? Lets give maintainers guidance about how to handle them.
Untracked files:
(use "git add <file>..." to include in what will be committed)
phpstan-baseline.neon
phpstan.neon
recipes/
Steps To Reproduce
No response
Anything else?
No response
One option is to keep track of whether the files existed before the run, and only clean them up after it finishes if they were generated during the run. This is the approach I took for cspell:
https://github.com/jameswilson/ddev-drupal-contrib/blob/cspell/commands/web/cspell#L32-L34
Thanks for this command, ddev phpstan is really handy for contrib work!
I agree with the expectation here: running ddev phpstan shouldn’t create new files (or leave the repo dirty), especially when there is no phpstan.neon or phpstan.neon.dist yet.
What I’d expect instead is roughly:
- If
phpstan.neonORphpstan.neon.distexists, use them. - If neither exists, fail with a clear error message, e.g.
“No PHPStan config found. Create
phpstan.neon.distand commit it to your project (you can copy it to phpstan.neon locally for overrides).”
That keeps ddev phpstan from generating untracked files, while still encouraging the common pattern of committing phpstan.neon.dist and optionally ignoring phpstan.neon for local tweaks.
Sorry if I’m wrong in thinking phpstan.neon.dist is the one we should be committing, but this problem is affecting me especially because I think this.