Skip to content
This repository has been archived by the owner on Jul 12, 2020. It is now read-only.

New patch generation system #51

Merged
merged 1 commit into from
Jan 3, 2014
Merged

Conversation

tomphp
Copy link
Contributor

@tomphp tomphp commented Dec 30, 2013

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

Benefits

  • More flexibility and resolves the problems I have mentioned before (i.e. fixes the problem I was have working on this Convert local method parameter variables to instance variables #50)
  • 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.

@@ -16,7 +16,7 @@

use QafooLabs\Refactoring\Domain\Model\EditorBuffer;
use QafooLabs\Refactoring\Domain\Model\LineRange;
use QafooLabs\Patches\PatchBuilder;
use QafooLabs\Refactoring\Adapters\PatchBuilder\PatchBuilder;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the factory code for this changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, have seen it.

@beberlei
Copy link
Contributor

beberlei commented Jan 3, 2014

Can you remove the PatchBuilder component then, including tests?

@tomphp
Copy link
Contributor Author

tomphp commented Jan 3, 2014

Do you want me to remove the whole QafooLabs\Patches system?

@tomphp
Copy link
Contributor Author

tomphp commented Jan 3, 2014

Also did you see me comment about the behat tests and the fact that they test the patch output rather than the result of the patch. Do think this would be a worthwhile change to make to the testsuite?

@tomphp
Copy link
Contributor Author

tomphp commented Jan 3, 2014

Ok, I've removed all obsoleted code and tests.

@beberlei
Copy link
Contributor

beberlei commented Jan 3, 2014

@tomphp Can you squash the commits to one? That be the only thing left :)

@tomphp
Copy link
Contributor Author

tomphp commented Jan 3, 2014

@beberlei squashed :)

beberlei added a commit that referenced this pull request Jan 3, 2014
@beberlei beberlei merged commit a698e36 into QafooLabs:master Jan 3, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants