-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Adding PSR12 coding standard #56
Conversation
@ChrisB9 thanks for the PR, really appreciate! |
@@ -1,5 +1,6 @@ | |||
<?php | |||
declare(strict_types = 1); | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which rule from PSR-12 applies here? in TYPO3 Core it's formatted with spaces around "="
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My checks went entirely after PSR12, no additional special configuration
Declare statements MUST contain no spaces and MUST be exactly declare(strict_types=1) (with an optional semi-colon terminator).
https://www.php-fig.org/psr/psr-12/#3-declare-statements-namespace-and-import-statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right!
@@ -167,7 +168,7 @@ protected function recursiveFind(array $haystack, $needle) | |||
* @param array $data | |||
* @return array | |||
*/ | |||
protected function decodeFieldsIfRequired(array $data) : array | |||
protected function decodeFieldsIfRequired(array $data): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, I've added a rule to check this one in #58
@tmotyl I did my checks with grumphp (pluswerk/grumphp-config does provide php_cs built-in with psr12 enabled). And yes i am aware that the php_cs does this and because you added it i wanted to already provide the base for it
|
I was convinced that php_cs_fixer doesn't support '@psr12' rules yet. |
I will update it accordingly 👍 And yes, the PHP-CS-Fixer/PHP-CS-Fixer#4502 was not too long ago, we updated our config earlier this month - so very recent |
Would it be okay, if i merge your #58 into my PR to incorporate all changes? |
yes, you can merge or just copy paste the file content (I'll be squashing the commits before merging to master anyway). |
I have now updated the branch, but i realized, that i did get php-cs-fixer and phpcs mixed up. So you guys were totally right, the fixer does not yet support the new standard while phpcs does. |
@@ -14,6 +11,10 @@ | |||
* | |||
***/ | |||
|
|||
declare(strict_types=1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this change intended (moving declare and namespace after comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes it's intended:
https://www.php-fig.org/psr/psr-12/#3-declare-statements-namespace-and-import-statements
The order now is first open tag, then file-comment, then declare, then import, then rest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, looks good then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'no how that rule got accepted to the standard. Can only assume the reviewers missed it. I've never seen any code before that followed that rule of having the doc above the declares. The 2 authors of the PSR must have wanted it, only...
there is one more issue to fix see https://travis-ci.com/TYPO3-Initiatives/headless/builds/133514433 |
Yes, i just saw it and fixed that one directly |
Thank you! |
Since PSR2 has been replaced with PSR12 and the source code is still fresh and little, i thought it might be good to provide this setup (Not much changes anyway).
Fits also good together with #52, since such a check could be automated in the future.