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

Uniformize files coding style #1433

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

helyakin
Copy link

@helyakin helyakin commented May 18, 2023

Hello everyone

I'm very found of this project and try to convert everyone I know to use it when it's necessary
I've long wanted to do a contribution, and this is a complicated one (to me at list).
But beforehand I've noticed numerous inconsistencies in the coding styles files are using or use of syntax that are kinda old fashioned.

Such as array() which is useful for backward compatibility yes, but do we want to keep using it when using typed parameters in some files ?

Anyway this PR is here to discuss about this topic, and once this one will be settled I'll gladly make another one to uniformise all the typed parameters and attribute in all files.

Here are a few rule I've set using cs-fixer:
no_superfluous_phpdoc_tags: It's kind of pointless to comment the type of a typed parameter
array_syntax: use [] instead of array()
blank_line_before_statement: Some blank lines were missing between attributes
header_comment: Some file are missing the header comment
single_quote: Some file are using double quote when single is enough
visibility_required: Some function visibility were not declared
php_unit_method_casing: Enforce CamelCase case even for tests

Anyway I'll be glad to here from you before spending more time on this !

Cheers

@ciaranmcnulty
Copy link
Contributor

Most of these changes LGTM on their own, my only historical hesitation has been the affect it has on git blame - is there a sensible way around that?

If we do make a change like this I'd also want to see enforcement of the rules in future by committing relevant config files and enforcing them in the GitHub workflows

@ciaranmcnulty
Copy link
Contributor

Because we're using Psalm already, if some of these rules (mostly type things) can be enforced by that instead / as well it'd be good to add them to the psalm config

@ciaranmcnulty
Copy link
Contributor

ciaranmcnulty commented May 21, 2023

my only historical hesitation has been the affect it has on git blame - is there a sensible way around that?

Aha https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view seems to address it

@ciaranmcnulty
Copy link
Contributor

If you can get the build passing and add a .git-blame-ignore-revs file to root as described above, we can merge this sort of change.

At some point we should/could set up a CS CI job

@helyakin
Copy link
Author

helyakin commented Jun 4, 2023

Hello @ciaranmcnulty

First of all thank you so much for your attention regarding this PR.

I have pushed:

  • The .php-cs-fixer.php with some rules, we can talk furthermore about it, and the CI could be set up using the following command php vendor/bin/php-cs-fixer fix --using-cache=no --verbose --diff --dry-run
  • Added a .git-blame-ignore-revs as requested but haven't successfully used it. I don't know what i'm doing wrong
  • Fixed the failing test

@helyakin
Copy link
Author

helyakin commented Jun 4, 2023

I also think a tools like phpstan and/or php code style might do some good.
What do you think ?

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

2 participants