QafooLabs / php-refactoring-browser

A command line refactoring tool for PHP
http://qafoolabs.github.com/php-refactoring-browser
MIT License
556 stars 39 forks source link

[RuntimeException] Adding more than one operation to line 21 is not allowed. #26

Open umpirsky opened 11 years ago

umpirsky commented 11 years ago

I get this error when I tried to fix class names on SyliusPaymentsBundle:

git clone git@github.com:Sylius/SyliusPaymentsBundle.git
cd SyliusPaymentсBundle
refactor.phar fix-class-names .

  [RuntimeException]                                         
  Adding more than one operation to line 21 is not allowed.  

Exception trace:
 () at phar:///usr/local/bin/refactor.phar/src/main/QafooLabs/Patches/PatchBuilder.php:165
 QafooLabs\Patches\PatchBuilder->assertValidOriginalLine() at phar:///usr/local/bin/refactor.phar/src/main/QafooLabs/Patches/PatchBuilder.php:72
 QafooLabs\Patches\PatchBuilder->changeToken() at phar:///usr/local/bin/refactor.phar/src/main/QafooLabs/Refactoring/Adapters/Patches/PatchBuffer.php:45
 QafooLabs\Refactoring\Adapters\Patches\PatchBuffer->replaceString() at phar:///usr/local/bin/refactor.phar/src/main/QafooLabs/Refactoring/Application/FixClassNames.php:84
 QafooLabs\Refactoring\Application\FixClassNames->refactor() at phar:///usr/local/bin/refactor.phar/src/main/QafooLabs/Refactoring/Adapters/Symfony/Commands/FixClassNamesCommand.php:70
 QafooLabs\Refactoring\Adapters\Symfony\Commands\FixClassNamesCommand->execute() at phar:///usr/local/bin/refactor.phar/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:244
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/refactor.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:899
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/refactor.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:191
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/refactor.phar/vendor/symfony/console/Symfony/Component/Console/Application.php:121
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/refactor.phar/src/bin/refactor:10
 require() at /usr/local/bin/refactor.phar:5

fix-class-names dir
beberlei commented 11 years ago

Yeah i had this before, i will fix it sometime this month.

umpirsky commented 11 years ago

Can you give me any hints? Why does it happens?

beberlei commented 11 years ago

@umpirsky the replaceString call needs to accept an array of changes and perform them together (a new method actually). Building patches can always only change one line. But in your case it wants to change the same line multiple times.

umpirsky commented 11 years ago

@beberlei Thanks.

beberlei commented 11 years ago

@umpirsky I just realized, this will not work on bundles, because by using 'target-dir' - they are normally not PSR-0 in their github repository structure.

I did fix a bunch of bugs with the renaming and for a repository with PSR-0 directory structures, it should work much better now. I havened fixed the not allowing 2 changes to one line though, this might be a bit more tricky.