mmoreram / php-formatter

PHP Formatter is a PHP developer friendly set of tools
MIT License
166 stars 17 forks source link

Exclude directories? #26

Closed matt-usurp closed 7 years ago

matt-usurp commented 7 years ago

Is it possible to add excluded or ignored directories? It would be great to be able to prevent it from trying to sort use statements in my vendor directory or something.

mmoreram commented 7 years ago

Yes you can, but ATM you must execute the command per each folder. This feature can be implemented, for sure, and would be a great addition :)

matt-usurp commented 7 years ago

I was looking at a way of implementing this but realised that the config file will be interesting. Ideally the exclude would be for both header and use-sort so would there just be a new key at the root of the file called excluded-directories or something?

If so, I would ideally make a constant for this root key (similar to whats in the two command classes) so where would you suggest I put that? In ConfigLoader?

mmoreram commented 7 years ago

@matt-usurp this should be placed as an abstract configuration, so it make me thinks that maybe a small refactoring of the commands should be great.

Apart of that, yes, --exclude-dir would be great. Will be added for next major release.

Thanks.

matt-usurp commented 7 years ago

I won't be able to get around to doing this for about a week.

If its not implemented by then I will have another go now that the other fixer has been merged in too. The configuration loading doesn't look like it makes much sense once a command will use two root keys, so there is a refactor there but I don't want to do such a large scale change myself.

mmoreram commented 7 years ago

@matt-usurp almost done, will update the code tonight :)

mmoreram commented 7 years ago

@matt-usurp https://github.com/mmoreram/php-formatter/pull/28

matt-usurp commented 7 years ago

This is perfect!

Yeah looking at the scale of the refactor that was not something I was comfortable doing with one contribution. A nice refactor though, I will be upgrading to this as soon as possible!