I am trying to format PHP files using the following function:
function! PHPCSFixer() let l:fixer_path = '$HOME/.devtools/php/php-cs-fixer-v2.phar' let l:config_path = '$HOME/.devtools/php/php-cs-fixer.conf' let l:cmd = l:fixer_path . ' fix --quiet --config="' . l:config_path . '" -- "' . expand('%:p') . '"' :call system(l:cmd) :edit! endfun command! PHPCSFixer call PHPCSFixer() autocmd BufWritePost *.php silent :PHPCSFixer
It just run the following script on the current file (https://github.com/FriendsOfPHP/PHP-CS-Fixer).
The problem is that every once in a while when I save (:w) a PHP file a warning pops up:
WARNING: The file has been changed since reading it!!! Do you really want to write to it (y/n)?
I guess there is a timing problem somewhere but I don't know how/what to do to fix it...
Can someone point me to the right direction on this issue?