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

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

Open
slaFFik opened this issue Mar 17, 2024 · 0 comments
Labels

Comments

@slaFFik
Copy link
Member

slaFFik commented Mar 17, 2024

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.

@slaFFik slaFFik added the bug label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant