-
Notifications
You must be signed in to change notification settings - Fork 201
Description
Describe the bug
php-cs-fixer git hook doesn't work if more than 1 file php file is staged - it throws an In ConfigurationResolver.php line 539: For multiple paths config parameter is required. error.
To reproduce
- Enable the
php-cs-fixergit hook
hooks = {
php-cs-fixer = {
enable = true;
};
};- Stage more than one PHP file (this is crucial! With just one PHP file, it's all fine)
- Run
pre-commit run - It will fail with the message
In ConfigurationResolver.php line 539: For multiple paths config parameter is required.
This message is misleading because it sounds as if the config file was missing, but what happens instead is that php-cs-fixer doesn't accept multiple files that pre-commit provides it with by default. It's a well-known limitation of the php-cs-fixer tool.
The workaround I'm using is:
php-cs-fixer = {
enable = true;
# php-cs-fixer won't accept multiple file paths at a time. This is why we're providing an override and spawning
# as many php-cs-fixer processes as the number of staged *.php files.
entry = ''
sh -c '
for file in "$@"; do
php-cs-fixer fix "$file"
done
' --
'';
};So, while I understand this isn't an issue on either devenv or pre-commit, it still makes the php-cs-fixer devenv plugin useless.
I'm not sure what the real solution is - I'm afraid that the hacky solution I use might be the only option. Otherwise, I would simply remove this plugin since with the default configuration, it's simply useless.
Version
devenv 1.8.2 (aarch64-darwin)