- What language is this for?
PHP
- Which rule?
RSPEC-1808
- Why do you believe it’s a false-positive/false-negative?
SQ asks me to move the opening curly brace of an empty function statement (__construct
) to the next line.
According to PER section 4.4 Methods and functions a empty statement should be abbreviated to {}
and be placed on the same line as the function definition.
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.
-
Are you using
- SonarQube Community Build, v25.2.0.102705
-
How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
The code example in the standards document should be enough.
class Point
{
public function __construct(private int $x, private int $y) {}
// ...
}
or
class Point
{
public function __construct(
public readonly int $x,
public readonly int $y,
) {}
}