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

Review braces_position coding style enforcement in PHP CS Fixer #1261

Open
JakeQZ opened this issue May 24, 2024 · 2 comments
Open

Review braces_position coding style enforcement in PHP CS Fixer #1261

JakeQZ opened this issue May 24, 2024 · 2 comments
Assignees
Labels
coding style Issues with tools that enforce certain code formatting discussion

Comments

@JakeQZ
Copy link
Contributor

JakeQZ commented May 24, 2024

A single-line function/method declaration has the code-block opening brace on the next line:

function a()
{

Multiline declarations have this on the same line as the closing parenthesis for the arguments:

function longFunctionName(
  string $param
) {

This works for readability, because the ) { don't interfere with the first line of the function.

But consider a function with a type-hinted return value:

function longFunctionName(
  string $param
): TypeName {
  $value = \intval($param)';

  if ($value < 0) {

For readability, it seems like it would be better if the code block opening brance ({) were on a new line.

However, the current PHP CS Fixer rules we have in place forbid that. Ref: #1236 (comment)

@JakeQZ JakeQZ added discussion coding style Issues with tools that enforce certain code formatting labels May 24, 2024
@JakeQZ JakeQZ self-assigned this May 24, 2024
@oliverklee
Copy link
Contributor

In general, I'd suggest to update our CS-Fixer rules to the PER-2 set (which seems to be the current recommended common ground for PHP projects) including the risky rules and drop our custom rules. This way, we'll be consistent with other projects while reducing the maintenance effort for our own configuration.

What do you think?

@JakeQZ
Copy link
Contributor Author

JakeQZ commented May 24, 2024

What do you think?

I think that makes sense (though I don't know what the 'risky rules' are offhand).

Edit: oh, I see the 'risky rules' relate to migration between PHP versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coding style Issues with tools that enforce certain code formatting discussion
Projects
None yet
Development

No branches or pull requests

2 participants