Dgame / atom-php-fmt

11 stars 3 forks source link

Transfer the transformations to the sublime plugin #1

Closed Dgame closed 9 years ago

Dgame commented 9 years ago

@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. :)

Dgame commented 9 years ago

Shall I add you as contributor?

ucirello commented 9 years ago

yes, please :)

Dgame commented 9 years ago

Done

ucirello commented 9 years ago

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
Dgame commented 9 years ago

I see, that is the whole magic. :) Then I will implement it today.

ucirello commented 9 years ago

Yes, that's the whole magic. Features such as debug, troubleshoot and refactor can be done later.

Dgame commented 9 years ago

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 :)

ucirello commented 9 years ago

What do you think of the idea of shipping the plugin with the phar file inside?

Dgame commented 9 years ago

I thought of it, but that would mean to release a new version for each fix of your phar. That could be too much.

ucirello commented 9 years ago

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?

Dgame commented 9 years ago

selfupdate would be a good idea. Is it as simple as it looks? fmt.phar ---selfupdate?

ucirello commented 9 years ago

yes.

Dgame commented 9 years ago

Ok, seems easy enough. I will add it and the other options.

Dgame commented 9 years ago

So, options (including selfupdate) are now online. I will tag (with your approval) the first version.

Dgame commented 9 years ago

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?

ucirello commented 9 years ago

Feel free to copy the sublime-phpfmt README.md adapting it to this plugin.

Dgame commented 9 years ago

Ok, done. Take a look. After that, we've finished the first step. :)

ucirello commented 9 years ago

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?

Dgame commented 9 years ago

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.

ucirello commented 9 years ago

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.

ucirello commented 9 years ago

LGTM

Dgame commented 9 years ago

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.

ucirello commented 9 years ago

But I think that is not that easy.

Agreed

Dgame commented 9 years ago

I'll publish the plugin now, do you agree?

ucirello commented 9 years ago

I agree with the publishing of this plugin

Dgame commented 9 years ago

https://atom.io/packages/php-fmt