1

I am looking for a way to undo php-cs-fixer fix

I did

./tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -v --diff

and a whole files on project fixed indent.

Is there any way to restore the original files?

conny
  • 119
  • 1
  • 7
  • 2
    I don't see anywhere [in their documentation](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/master/doc/usage.rst) that a backup of the original file is made. There is a `--dry-run` flag, but it's a little late for that. Are you using version control or have you made a backup recently? – JNevill Mar 25 '22 at 18:09
  • 2
    OP used `--diff` flag though, which should print all the changes as diff. If this output is available, there is a possibility to parse it and reverse the changes. Question is if OP has this output, or was it discarded. – ympek Mar 25 '22 at 18:12
  • Another thought is that if you have hard drive, you could perhaps use a tool called Recuva, scan the directory and ask Recuva to - maybe - restore data (which may not be full proof). One question I have is - what's so wrong with phpcs fixing all files? Are the fixes bad? Is it worth reverting back? – zedfoxus Mar 25 '22 at 18:13
  • If it's only the indention you don't like, can't you create the rules you want and run php-cs-fixer again with that? – M. Eriksson Mar 25 '22 at 18:19
  • 2
    php-cs-fixer only changes formatting, and should never introduce errors. If you don't like the formatting, just change the phpcs config file to expect the formatting you want, and then run the fixer again. (Also, take this opportunity to start implementing some source control like git so that issues like this can be trivially undone.) – Alex Howansky Mar 25 '22 at 18:33

0 Answers0