Page 1 of 1

php-cs-fixer vs phpcbf

Posted: Thu Jun 01, 2017 2:44 pm
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?

Re: php-cs-fixer vs phpcbf

Posted: Tue Jun 06, 2017 11:15 pm
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 ;)

Re: php-cs-fixer vs phpcbf

Posted: Wed Jun 14, 2017 4:29 am
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 :).

Re: php-cs-fixer vs phpcbf

Posted: Wed Jun 21, 2017 1:22 pm
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).

Re: php-cs-fixer vs phpcbf

Posted: Wed Jun 21, 2017 5:06 pm
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

Re: php-cs-fixer vs phpcbf

Posted: Thu Jun 22, 2017 5:13 am
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).

Re: php-cs-fixer vs phpcbf

Posted: Thu Jun 22, 2017 5:18 am
by AJenbo
As for testing on Windows, I still haven't succeeded in compiling the Windows binary.

Re: php-cs-fixer vs phpcbf

Posted: Sun Jun 25, 2017 2:15 am
by AJenbo
Fixed two of the two dos, only need to reimplement only formatting selected code now :)

Re: php-cs-fixer vs phpcbf

Posted: Mon Jun 26, 2017 3:19 am
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.