Change code style to PSR-12#738
Conversation
This reverts commit 3d7718a.
BC: do not set visibility on class constants
|
Good point 👍
SimplePie does not support PHP 5.4 anymore. And the only rule in
I don't have any particular preferences about this. It's enough for me if rules are defined and these can be implemented automatically by running a script. |
Right, but we did not ever migrate to the newly introduced syntax so we still use long array syntax. PHP54MigrationSet would fix that. |
Oh, wow, you are right. I would have guessed that the short array syntax was already defined in PSR-2. 😅 |
|
PSR does not cover many things we take for granted, which is why I suggested the Symfony ruleset (even though it contains some questionable or even choices potentially hindering comprehension of code like the yoda style – we read left to right so having the object that introduces the most information on the left side is clearly preferable. And in most cases that will be the variable. Really, Yoda style only makes sense if you are comparing multiple values against the same variable – but then maybe you should use |
Do you have a tip or example for me on how to make this happen?
I've added all non-risky Migration rules, namely @PHP54Migration. I would not automate risky changes, but require a human to watch over changes.
I would like to move these decisions to a separate PR. In this PR, I would like to have a basic set of rules that everyone can agree on. |
I would probably add Having it in composer dev dependencies would be nicer but would force us to stay with old version of php-cs-fixer, as the latest version requires PHP 7.4. Edit: Actually, it looks like having a separate composer file is recommended upstream: https://cs.symfony.com/#installation
On the other hand, we are already changing the coding style significantly (replacing tabs with spaces) so this might be a best time for establishing a coding style once and for all. Each time we change it adds another obstacle to |
|
nice work I prefer this coding style too |
|
I've resolved the merge conflicts.
After reading up a bit, I have to say that I don't feel confident enough in this area. I would like to leave this topic to someone else.
@mblaney Any preferences about this? I could easily define some more rules in this PR. |
|
sorry looks like I missed that this was ready to merge? happy with the composer change but not familiar with the symfony requirements and doesn't feel like something we need to add here? |
We could remove the "friendsofphp/php-cs-fixer" library from "require-dev", but it allows every contributor to simply run
Yes, it is. As long as there are no change requests, this PR is ready for merge from my side. |
Fix regression from simplepie#738 See simplepie#724 Sad to see all these wasted / inefficient / hard-coded spaces though... Tabs ❤️
This PR changes the code style in all classes and tests to PSR-12. As discussed with @jtojnar in #734 (comment) I think that after the huge changes from #722 the timing is ideal.