Skip to content

Maybe AddEmptyLineBeforeReturnStatement should check for <?php on previous line #48

Open
@slaFFik

Description

@slaFFik

Expected Behavior

Maybe it would be a good idea in cases like this:

<?php
return ob_get_clean();

to not throw AddEmptyLineBeforeReturnStatement warning and allow it?

Current Behavior

When I have this code:

<?php
return ob_get_clean();

wpforms-phpcs screams at me with WPForms.Formatting.EmptyLineBeforeReturn.AddEmptyLineBeforeReturnStatement.

The obvious fix in this case right now is having this:

<?php

return ob_get_clean();

But to my eye, that looks worse and actually hurts readability.

Possible Solution

When parsing tags check whether the previous line has a PHP opening tag, and if not - allow it being there instead of the empty line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions