-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PSR-12 / PER-CS v1 Support #4502
Comments
What about this - specifically the part about spaces between class/function/const imports. It this possible currently? |
No, the newlines between different use types is not yet possible, however there is a longstanding issue (without PR) addressing it: #3582 edit: I would like to see that being resolved as well as part of this meta-issue |
Is this part already covered somewhere? As to your boolean operator fixer: I'd like the fixer to be able to do both, depending on config (always_front, always_back, when_mixed_front, when_mixed_back). It was not clear from your suggestion if you meant this, or just let it do only one of the bullet-points. |
@kbond Indeed, I updated my post with PR ref given by @dmvdbrugge. @dmvdbrugge Actually even the "each subsequent line is indented at least once" isn't supported currently. I updated my post to add the rules. As they both deal with whitespace, maybe we could implement them in a single fixer? I also updated my suggestion for the boolean operator position fixer, hope it's better now :) Thanks! |
From #4568, perhaps PSR-12 should be the default configuration for v3. |
Since PHP-CS-Fixer/PHP-CS-Fixer#4502 has been merged and is now supported, the documentation should mention this too
Any update on psr-12 support? |
Nope, nobody gave it a try yet. |
Perhaps it makes sense to create a branch that aggregates a |
We can create a |
Since this issue has not had any activity within the last 90 days, I have marked it as stale. I will close it if no further activity occurs within the next 30 days. |
@Wirone what about splitting this issue into the separate ones? I want to comment on 5.x, but the discussion here on multitopic is quite too long to be helpful. |
@mvorisek I agree, that's why I unpinned this issue some time ago. First of all I believe we should focus on PER-CS now, since #6707 was merged it's now possible to work on v2. I am not sure if investing time in PSR-12 is good at this point. Anyway, if we want to continue working on this, we should create milestone with dedicated issues for each remaining task from this issue's checklist. @keradus what do you think about this idea? I could split this issue in the meantime. |
@Wirone keep in mind that PER-CS 1.0 is (intentionally) basically the same as PSR-12: https://groups.google.com/g/php-fig/c/bBh4Y-R5gxE So you could split this up in sub-issues and keep them as valid, and just review them against the PER-CS 2.0 change list: https://github.com/php-fig/per-coding-style/releases/tag/2.0.0 |
This comment was marked as outdated.
This comment was marked as outdated.
Hi @Wirone, what about adding The rule seems pretty similar to what is asked in PSR12. Currently it's used by Symfony Ruleset and PSR12 ruleset. |
@VincentLanglet yeah, it looks like |
I agree.
I have made the PR #7868 (comment) but this seemed refused at this time. I can reopen the PR but this might require some discussion with keradus. |
there doesn't seem to be a check re line length? ( cf https://www.php-fig.org/per/coding-style/#23-lines ) |
No, because:
This is not something that can be automated in sensible way. |
Would it not then be possible to just emit a warning in that case? (Which is what PHPCodeSniffer does) |
Unlike PHPCodesniffer, php-cs-fixer doesn't have a concept of warning or error violations (non automatically fixable error), all the violations it has must be fixable. What it could do is to have some fixer which splits the code to multiple lines according some rules, like https://github.com/symplify/coding-standard?tab=readme-ov-file#linelengthfixer |
|
PSR-12 just got approved. PER-CS v1 is the same in terms of rules, so all the changes must be included in both of them (
@PSR12
,@PER-CS1.0
).I think PHP CS Fixer already supports almost all of its rules. The missing cases I could notice are the following:
3. Declare Statements, Namespace, and Import Statements
ordered_imports
currently sorts imports without considering their type. We should add an option to sort by type first. We should also add an option (or dedicated rule) to add a separation line between each import group.We need to create a fixer that could force boolean operators to always be at the same position with two options like e.g.:
position
(beginning
orend
): choose whether the operators should be at the beginning or end of the lines;when
(always
ormixed
): whether the rule should always be applied or only when a mix of positions is found.We also need to support the multiple lines part of the rule:
You need to update
class_definition
to support adding a spacing before the parentheses innew class()
.I think this is currently covered by the rule
braces
. Not sure if we should add a new option to it or create a new fixer.TODO
single_space_after_...
config #8171)implements
list wraps (info, needs exact reference)new class()
(ClassDefinitionFixer - PSR12 for anonymous class #5877)@PSR12
ruleset (Add PSR12 ruleset #4943)The text was updated successfully, but these errors were encountered: