awesomemotive / wpforms-phpcs

PHP Coding Standards used by the WPForms team.
https://wpforms.com
GNU General Public License v2.0
12 stars 1 forks source link

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

Open slaFFik opened 7 months ago

slaFFik commented 7 months ago

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.