-
-
Notifications
You must be signed in to change notification settings - Fork 141
Suggestion: Skip empty_line_before_return when method contains only a single return statement #208
Description
Hi 👋,
This is more of a suggestion than a bug report.
Currently, with empty_line_before_return enabled, Mago correctly adds an empty line before every return statement. However, this also applies to methods that contain only a single return statement and no other logic, like typical getters:
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}This gets transformed into:
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}While technically correct according to the rule, the extra empty line adds unnecessary vertical space for these simple one-liner methods. It might be more readable and compact to skip the empty line in such cases.
Suggestion
Enhance the empty_line_before_return rule with an option to ignore single-return-only methods or by default ?
This would allow a cleaner, more compact format for typical getters or one-liner functions, without sacrificing the benefits of the rule elsewhere.
Let me know what you think !
Thanks for your work on this tool 🙌