php-cs-fixer vs phpcbf

Discussion about CodeLite development process and patches
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

php-cs-fixer vs phpcbf

Post by AJenbo »

So I only recently found out that the CodeFormatter is actually meant to be used with php-cs-fixer and not the fixer from the phpcs project. They appear to be two parallel projects, but from what I can tell php-cs-fixer can fix some issue that phpcbf can't. But the output from phpcbf is less error prone.

The command to invoke them are mostly compatible, although the fix parameter is not needed for phpcbf and lucally it just ignores it.

How ever I'm unsure if it would make sense to extend the plugin to also offer a phpcbf specific setup. And also I have seen some people using both in combination in some cases (this might not be relevent on a day to day basis but only as a single run on a really bad code base), so maybe it would make sense to allow people to enable multiple clean up tools to run in succession.

Any thoughts?
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: php-cs-fixer vs phpcbf

Post by AJenbo »

Well i decided to go with adding phpcbf as a separate tool. This allows for having more user friendly configuration options available directly in CL, although it really should be handled with project configuration files ;)
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: php-cs-fixer vs phpcbf

Post by AJenbo »

CodeFormatter code is now mostly unified. Therese still a little bit of work to do on batch formatting and I will have to reimplement cursor position and selection formatting. Disk bufferes are also used in more places (for common behaviour between formatters) so there might be a little slow down, and so some room for improvements, but better to have full functionality I say :).
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: php-cs-fixer vs phpcbf

Post by AJenbo »

Project formatting is now working with all formatters (also on non c++ projects). I'm now working on reintroducing the features that I removed when dropping the formatters to lowest common denominator (to make it easier to unify the code) as well as some performance optimizations (it's not bad as is, so mostly to have a more responsive preview).
User avatar
eranif
CodeLite Plugin
Posts: 6367
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: php-cs-fixer vs phpcbf

Post by eranif »

Note that the preview responsiveness will be more visible on Windows platforms where executing an external tool is relatively an heavy operation
So it will be better to try this on Windows, if you dont access to Windows machine - let me know and I will merge the PR and I will try it on my Windows box
Make sure you have read the HOW TO POST thread
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: php-cs-fixer vs phpcbf

Post by AJenbo »

I have now made it so that previews are only generated for the currently selected tab, this greatly speeds things up compared to previously :)

On the TODO list before I feel it's ready for PR:
* Re-implement only formatting selected code (only clang and AStyle are able to do this).
* I have a bug where the preview does not pick up the settings before pressing Ok (probably simple to fix).
* Find out how to find the project path for non-c++ projects.

After that I will have some more features that I will do as seporate PR's:
* Option to disable formatting on a per language basis (add no-engine to the engine options)
* Implement options for php-cs-fixer
* Implement options for phpcbf
* Settings export options for Clang, php-cs-fixer and phpcbf (don't know that it's possible for the others).
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: php-cs-fixer vs phpcbf

Post by AJenbo »

As for testing on Windows, I still haven't succeeded in compiling the Windows binary.
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: php-cs-fixer vs phpcbf

Post by AJenbo »

Fixed two of the two dos, only need to reimplement only formatting selected code now :)
AJenbo
CodeLite Enthusiast
Posts: 41
Joined: Mon May 22, 2017 12:06 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: php-cs-fixer vs phpcbf

Post by AJenbo »

All features are now re-implemented and the PR sent. I was also able to get rid of all unnecessary file writes so speed should be same or better as before the re-factoring.
Formatting will also skip in all cases if a tool hasn't been correctly configured so that it won't cause a delay.
Post Reply