Page 1 of 1

PHP refactoring

Posted: Thu Jun 01, 2017 2:55 am
by AJenbo
While cleaning up some large php code bases i often need split large functions. As such I think this will be the next plugin/functionality I might work on. This was actually what initially got me to try CodeLite as i saw it listed as having refactor capabilities and php support, and is open source :)

External tools for doing this already exists https://github.com/QafooLabs/php-refactoring-browser so one option would be to make a plugin similar to the code formatter that taktes the current selection range, asks for a new name for the function and then passes this on to that tool. For me personally I think this would work reasonably but I don't feel this is a feature that can really justify external dependencies and the need for configurations.

The other option is to implement something that takes advantage of the php lexer in CL, but I'm honestly not sure where to start with something like that.

Any help or advice (even opinions :P ) are very welcome at this point :)

Re: PHP refactoring

Posted: Thu Jun 01, 2017 3:07 am
by AJenbo
would it be possible to bundle some of the phar applications with cl, or add some more or less automatic automatic script for fetching of them?

Re: PHP refactoring

Posted: Thu Jun 01, 2017 4:36 am
by AJenbo
Had a secound look at things. Atom, Sublime Text 2/3 and vim all seams to be using that phar tool for this functionality.
PhpStorm has it's own thing.

php-refactor-browser also has way more functionality then I think I would ever be able to implement (time wise :lol: ). So instead of spending time implementing a simple methode extraction function my time would probably be better spent exposing some of the additional capabilities from php-refactor-browser.

Php storm did have a few nice things that might be good inspiration for where to take the PHPLint plugin in the future:
https://confluence.jetbrains.com/displa ... n+PhpStorm

PhpStorm also have some nice build in linters (especially detect undefined) and code formatters, but thease are probably better to take up with phpcbf (or php-cs-fixer) and phpmd so that everybody gets to benefit from it.

P.s. after php-refactoring i think the next logical step would be phpunit intergration. If you feel that there are some parts i should further flesh out before moving ahead with my plans feal free to give some input :)

I guess some guides/documentation would be a nice last thing (doesn’t really scratch my itch ;) ) to do.

Re: PHP refactoring

Posted: Mon Jun 05, 2017 4:34 am
by AJenbo
So turned out php-refactoring-browser was not in the best state as it hadn't been updated in years and so didn't have support for php7 source files. I managed find some forks of it and some dependencies that resolves it and also fixed two other issues while I was at it. So to any one that want to use it i recoment trying out my branch:
https://github.com/AJenbo/php-refactoring-browser
I haven't had time to do a .phar release yet, but you can run it via ./src/bin/refactor after you do a compose install.
On the CL side of things I have a plugin read in a PR.

Re: PHP refactoring

Posted: Mon Jul 03, 2017 12:57 pm
by AJenbo
Refactoring is now merged and a guide to setting it up added to the wiki:
http://codelite.org/LiteEditor/PHP#toc9