PSR12 4.4 Methods and Functions close braces same line
Closed this issue · 5 comments
Is your feature request related to a problem?
It is related to PHP8 and PSR12 standard
Describe the solution you'd like
As described in PSR12 item 4.4
If a function or method contains no statements or comments (such as an empty no-op implementation or when using constructor property promotion), then the body SHOULD be abbreviated as {} and placed on the same line as the previous symbol, separated by a space. For example:
class Point
{
public function __construct(private int $x, private int $y) {}
// ...
}
class Point
{
public function __construct(
public readonly int $x,
public readonly int $y,
) {}
}
Additional context (optional)
Exists some discussion and "suggestions" in this topic - squizlabs/PHP_CodeSniffer#3291
- I have read the Contribution Guidelines and this is not a support question.
Don't know where you're getting your information from, but this is not part of PSR12.
This is the literal text of PSR12 section 4.4:
4.4 Methods and Functions
Visibility MUST be declared on all methods.
Method names MUST NOT be prefixed with a single underscore to indicate protected or private visibility. That is, an underscore prefix explicitly has no meaning.
Method and function names MUST NOT be declared with space after the method name. The opening brace MUST go on its own line, and the closing brace MUST go on the next line following the body. There MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis.
A method declaration looks like the following. Note the placement of parentheses, commas, spaces, and braces:
... code sample...
https://www.php-fig.org/psr/psr-12/#44-methods-and-functions
I took it from - https://www.php-fig.org/per/coding-style/#44-methods-and-functions that can be accessed in the page https://www.php-fig.org/psr/psr-12/ and click on the link "PER Coding Style" on the right top menu (Additional info)
@junior-paytech PSR-PER is not the same as PSR12 and for those things for which PSR12 has its own rules, PSR-12 sniffs cannot be updated to follow PSR-PER as in that case, the PSR 12 sniff would no longer enforce PSR12.
I understand your point, but I believe that the PER is more "actual" and aligned with the current php development.
Anyway, thank you your support.