Closed Dgame closed 9 years ago
Shall I add you as contributor?
yes, please :)
Done
All magic happens with fmt.phar. All transformations can be added with --passes=
param, and core transformations can be removed with --exclude
.
To get a list of all possible additional transformations:
./fmt.phar --list
Currently, they are : https://github.com/dericofilho/sublime-phpfmt#currently-supported-transformations
PSR1/2 are enabled and disabled with --psr1
, --psr1-naming
and --psr2
.
Help:
./fmt.phar
Usage: ./fmt.phar [-hv] [-o=FILENAME] [--config=FILENAME] [--cache[=FILENAME]] [options] <target>
--cache[=FILENAME] cache file. Default: .php.tools.cache
--cakephp Apply CakePHP coding style
--config=FILENAME configuration file. Default: .php.tools.ini
--constructor=type analyse classes for attributes and generate constructor - camel, snake, golang
--enable_auto_align disable auto align of ST_EQUAL and T_DOUBLE_ARROW
--exclude=pass1,passN,... disable specific passes
--help-pass show specific information for one pass
--ignore=PATTERN-1,PATTERN-N,... ignore file names whose names contain any PATTERN-N
--indent_with_space=SIZE use spaces instead of tabs for indentation. Default 4
--laravel Apply Laravel coding style (deprecated)
--lint-before lint files before pretty printing (PHP must be declared in %PATH%/$PATH)
--list list possible transformations
--list-simple list possible transformations - greppable
--no-backup no backup file (original.php~)
--passes=pass1,passN,... call specific compiler pass
--profile=NAME use one of profiles present in configuration file
--psr activate PSR1 and PSR2 styles
--psr1 activate PSR1 style
--psr1-naming activate PSR1 style - Section 3 and 4.3 - Class and method names case.
--psr2 activate PSR2 style
--selfupdate self-update fmt.phar from Github
--setters_and_getters=type analyse classes for attributes and generate setters and getters - camel, snake, golang
--smart_linebreak_after_curly convert multistatement blocks into multiline blocks
--version version
--visibility_order fixes visibiliy order for method in classes - PSR-2 4.2
--yoda yoda-style comparisons
-h, --help this help message
-o=- output the formatted code to standard output
-o=file output the formatted code to "file"
-v verbose
If <target> is "-", it reads from stdin
I see, that is the whole magic. :) Then I will implement it today.
Yes, that's the whole magic. Features such as debug, troubleshoot and refactor can be done later.
Seems your are hardworking. Transformations did work now, would you please take a look? If you are satisfied I will release the first version 0.1.0 :)
What do you think of the idea of shipping the plugin with the phar file inside?
I thought of it, but that would mean to release a new version for each fix of your phar. That could be too much.
It is update a lot, sometime several times a day. You could at least add an option to the --selfupdate
and something to notify the users a new phar is available. Otherwise, we will not be able to push them updates. What you say?
selfupdate
would be a good idea. Is it as simple as it looks? fmt.phar ---selfupdate
?
yes.
Ok, seems easy enough. I will add it and the other options.
So, options (including selfupdate
) are now online. I will tag (with your approval) the first version.
Ok, one last missing thing: the readme. Would you mind it (since my english isn't that well and in generall it is your plugin after all) to write (or copy) a readme?
Feel free to copy the sublime-phpfmt README.md adapting it to this plugin.
Ok, done. Take a look. After that, we've finished the first step. :)
Are you going to add the fmt.phar?i did not find it anywhere.
Another thing concerns me, how is it the buffer being updated? Is is going to do a file flush? Will it lose undo history and lines foldings?
Are you going to add the fmt.phar?i did not find it anywhere.
That was not my intention. But it seems you want it?
Another thing concerns me, how is it the buffer being updated? Is is going to do a file flush? Will it lose undo history and lines foldings?
I don't know how exactly the internals of atom work. But yes, I think it's a file flush, and yes you lose your undo history. But that is a atom problem, not ours.
No problem. No need to add it if you already considered it thoroughly.
It is an editor issue for sure, but I am concerned about usability. In sublime-phpfmt at a certain point I addressed this issue. It would be a pity if we couldn't make it happen in Atom.
LGTM
No problem. No need to add it if you already considered it thoroughly.
Yes, mainly because I think it would be better to get a fresh fmt.phar
after installing this plugin, and not a old one.
It is an editor issue for sure, but I am concerned about usability. In sublime-phpfmt at a certain point I addressed this issue. It would be a pity if we couldn't make it happen in Atom.
You can try to solve it, I will do so too. But I think that is not that easy.
But I think that is not that easy.
Agreed
I'll publish the plugin now, do you agree?
I agree with the publishing of this plugin
@dericofilho it would be nice if you can give me an detailed explanation what I need to know to pass the transformations to your plugin. :)