You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am experiencing a formatting inconsistency in the phpfmt formatter when the phpfmt.psr2 setting is set to false. Specifically, the formatter does not automatically align the opening braces { on the same line as the method signature for certain return types, though it maintains the brace position if manually adjusted.
Steps to Reproduce
Set the phpfmt.psr2 configuration to false.
Apply phpfmt formatting to a PHP class with methods having different return types.
Observe the position of the opening brace in relation to the method signatures.
Current Behavior
With phpfmt.psr2 set to false, the formatter does not automatically place the opening brace on the same line for some method return types:
class ExampleClass {
// Not automatically formatted correctlypublicfunctionsetCreator(?User$creator): static
{
$this->creator = $creator;
return$this;
}
// Also not automatically formatted correctlypublicfunctiongetCreatedAt(): ?\DateTimeImmutable
{
return$this->createdAt;
}
}
However, if the braces are manually placed on the same line, the formatter does not move them:
class ExampleClass {
// Manually corrected format is maintainedpublicfunctionsetCreator(?User$creator): static {
$this->creator = $creator;
return$this;
}
}
Expected Behavior
The formatter should automatically place the opening brace on the same line as the method signature for all methods:
I understand your point, but "automatically place the opening brace on the same line", unless you ask specifically for it, shouldn't be enforced by the tool.
We may talk about creating a rule something like "CurlyOpenSameLine" you could opt in, the contrary of "PSR2CurlyOpenNextLine" which is the one causing the formating under PSR2.
I am experiencing a formatting inconsistency in the
phpfmt
formatter when thephpfmt.psr2
setting is set to false. Specifically, the formatter does not automatically align the opening braces{
on the same line as the method signature for certain return types, though it maintains the brace position if manually adjusted.Steps to Reproduce
phpfmt.psr2
configuration to false.phpfmt
formatting to a PHP class with methods having different return types.Current Behavior
With
phpfmt.psr2
set to false, the formatter does not automatically place the opening brace on the same line for some method return types:However, if the braces are manually placed on the same line, the formatter does not move them:
Expected Behavior
The formatter should automatically place the opening brace on the same line as the method signature for all methods:
The text was updated successfully, but these errors were encountered: