stwe / DatatablesBundle

This Bundle integrates the jQuery DataTables plugin into your Symfony application.
355 stars 236 forks source link

Coding style #907

Closed stephanvierkant closed 5 years ago

stephanvierkant commented 5 years ago

I think we should decide on a coding style so we can automate the process of bitching about spaces, indenting, etc. and have a better, cleaner and easier to read and maintain code.

I don't like the Symfony Coding Standard for some reasons. I don't like the Yoda comparison, but that's a personal preference. More important: FriendsOfPHP/PHP-CS-Fixer lacks features squizlabs/PHP_CodeSniffer has.

Some ideas to improve the coding style:

I'll work on a PR to improve this, so please let me know if you have a opinion about this matter.

Seb33300 commented 5 years ago

Symfony follow PSR coding standards and the documentation recommend to use PHP CS fixer: https://symfony.com/doc/current/contributing/code/standards.html

Most of big projects (not only Symfony) are following the PSR coding standards. And since this bundle is Symfony bundle, I think we must follow PSR coding standards to keep consistency with the Symfony ecosystem.

This should not be a question about if you like it or not.

All the rules defined in the standards have been specified for a good reason.

stephanvierkant commented 5 years ago

I'm ok with following PSR standards, but they're very limited. We can follow @Symfony rules and add some extra rules (like removing useless dockblocks, remove else statements, etc.

For example: the Symfony Coding Standards allows redundant docblocks, but doesn't require them.

stephanvierkant commented 5 years ago

Another example. The idea behind the Yoda conditions is that one might write if ($foo = 'bar') {} while $foo == 'bar') {} is ment. But$singular = 1 === \count($diff);` is allowed. Can't get my head around this.

I'll write a PR with a coding style based on PSR/Symfony.