QafooLabs/php-refactoring-browser — pull request #51 by tomphp (2013-12-30 12:51:18+00:00)
Title: New patch generation system

This PR provides a new mechanism for generating the patches. **Please read below**

Benefits
------------
* More flexibility and resolves the problems I have mentioned before.
* Neater patch generation as all changes are taken into account at the point of creating the patch.
* Allows more complex refactorings as it would now be possible to re-analyse the partially refactored code for further refactoring rather than relying on code analysis just from the original file content. I think this will be very useful as the refactorings are added to and developped.

Implementation
----------------------
The patch is generated by phpspec/php-diff which is the library phpspec uses to produce diffs
https://github.com/phpspec/php-diff

This is done via a patch building library which I have created for this purpose and put into a seperate repository as I it could be useful in other project also.
https://github.com/tomphp/PatchBuilder

Testing
-----------
One thing I which I should say is that I have had to modify the behat features to get it to pass, the reason for this is that behat is testing the actual patch output which had been changed (and optimised) in this version.

I think a better solution would be to test the results of the patches, i.e. generated the patches and hand them to the patch command then check the result. I'm not sure however if this would be possible using the virtual file system and therefore make require using the real file system.

While I'm 90% sure everything that I have done is correct, it might first be work updating the test suite with the new method i just mentioned against the existing code then running this pr against that test suite. Thoughts?

Tidying Up
----------------
This PR currently has all the left over classes from the old patch system lying around, I will tidy this up before expecting a merge.

What next?
-----------------
I will compile and personally use this modded version for a while and see that it's working properly. If it is I think it would be great if we could go ahead with this version as it will allow progress with feature development.