junstyle / vscode-php-cs-fixer

PHP CS Fixer extension for VS Code
https://marketplace.visualstudio.com/items?itemName=junstyle.php-cs-fixer
MIT License
357 stars 45 forks source link

Quick Save - Code Duplication #183

Closed yejune closed 2 years ago

yejune commented 2 years ago

When find and replace the contents of multiple files, the files with the same name in different folders are copied and overwritten.

src/Old/test.php

<?php

namespace Src\Old;
// A

src/New/test.php

<?php
namespace Src\New;
// B

find and replace all Src => Tmp

src/Old/test.php

<?php

namespace Tmp\Old;
// A

src/New/test.php

<?php
namespace Tmp\Old;
// A

Maybe it's because used the same command on both within a short time.

[ "fix", "--using-cache=no", "--format=json", "--config=~/.php-cs-fixer.php", "--path-mode=override", "/var/folders/x2/xcd5twps2l51_22dcdn4hgr00000gn/T/test.php" ]

junstyle commented 2 years ago

yeah, use a same file name, and override the previous file's. it seems must create a tmp dir to place the tmp file to keep the file name. i will fix

yejune commented 2 years ago

Another problem can arise when creating and deleting folders. How about making the file name a full file path hash (md5, sha... etc)?

junstyle commented 2 years ago

must keep the file name same to the original file, because some php-cs-fixer rules use the filename to fix file. https://github.com/junstyle/vscode-php-cs-fixer/issues/50