Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Php-cs-fixer support #14

Merged
merged 3 commits into from
May 30, 2015
Merged

Added Php-cs-fixer support #14

merged 3 commits into from
May 30, 2015

Conversation

klipach
Copy link
Contributor

@klipach klipach commented May 24, 2015

There is very cool tool PHP-CS-Fixer it allows to fix codestyle errors automatically.

@aderuwe
Copy link
Contributor

aderuwe commented May 24, 2015

Can you update the php version requirement in composer.json so that travis can do its thing?
The PR looks good otherwise on first glance, but I'll look more later.

@veewee I think bumping the php version to 5.3.6 should be ok if we decide to accept this PR?

@klipach
Copy link
Contributor Author

klipach commented May 25, 2015

Please, check, i updated PHP version and fixed codestyle errors.

@veewee
Copy link
Contributor

veewee commented May 26, 2015

Hello @klipach
Thanks for adding the php-cs-fixer task!
I do have some additional questions/remarks:

It sounds 'scary' to alter files during a commit. You won't have control about those files anymore. It's a good thing to make the auto_fix configurable and set it to false by default. Maybe an extra note could be added to the README file to use that option with care. Also note that the changed files won't be committed. You will need an additional git add to commit the changed files during the pre-commit hook.

Could you also add a configurable --config-file option? We tend to use the .php_cs file to determine the fixers, files, ... for the project. Or does this make the fixer run for all files?

These are some general remarks about the future structure of GrumPHP. These might not be fixed in this issue, but I would like to have some input on this:

Another remark I have concerning this auto_fix variable is the priority of the tasks. By changing the files you might break some existing tasks. Maybe it's a good idea to add a task priority per task configuration? For example: run the php-cs-fixer task first, next all other tests.

At the moment the Task::run command is rather bug. We might introduce a 'Formatter' interface to display success / warning / error messages. Not sure how it will look for the moment, but it will remove the formatting stuff from the Task::run command. It seems like a good idea to me.

Another thing that ennoys me in the Task::run commands is this part:

if ($config['whatever']) { 
    $processBuilder->add(); 
}

Maybe it's a good idea to create a wrapper around the Symfony ProcessBuilder with following additional methods:

// Add an optional configuration option. This will not add anything if the config is empty
$wrapper->addOptionalAttribute('--config=%s', $config['config']); 
// Add a required configuration options. Throws exception when the config is empty
$wrapper->addRequiredAttribute('--config=%s', $config['config']);
// Clone the processbuilder wrapper
$wrapper->clone()

@veewee
Copy link
Contributor

veewee commented May 26, 2015

Hi @klipach,

Me and @aderuwe discussed this issue. It seems like a good idea to drop the auto_fix field.
It seems like a better idea to let the task fail and show the suggestion to fix it manually.
Otherwise the user won't have any control about what he/she is commiting.

The --config-file option might still be usefull.

All other remarks are placed in new issues: #16, #18 and #19.

Looking forward to hear your feedback.

@klipach
Copy link
Contributor Author

klipach commented May 27, 2015

Thank you for comments, i agree that auto_fix is no cool feature, so i removed it.

veewee added a commit that referenced this pull request May 30, 2015
@veewee veewee merged commit 90aae07 into phpro:master May 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants