awesomemotive / wpforms-phpcs

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

phpcs: Impossible to create one-liner methods with return type hinting #39

Closed dimitris-am closed 8 months ago

dimitris-am commented 8 months ago

Originally reported by @kkarpieszuk in https://github.com/awesomemotive/wpforms-plugin/issues/8417

Current Behavior

If you define method:

    public function is_entry_meta(): bool {

        return true;
    }

phpcs will tell you:

Remove empty line before return statement in ... line. (WPForms.Formatting.EmptyLineBeforeReturn.RemoveEmptyLineBeforeReturnStatement) phpcs

if you remove empty line so method will be:

    public function is_entry_meta(): bool {
        return true;
    }

phpcs will tell you:

Add empty line after is_entry_meta() function declaration. (WPForms.Formatting.EmptyLineAfterFunctionDeclaration.AddEmptyLineAfterFunctionDeclaration) phpcs

This problem does not exist if method does not have return type hinting:

    public function is_entry_meta() {

        return true;
    }

Expected Behavior

Methods - no matter if they have return type hinting or not, should have empty line after function declaration (so the first code snippet above should be valid).

slaFFik commented 8 months ago

This issue duplicates the one I created a while back :) See #32.

dimitris-am commented 8 months ago

Oh thanks @slaFFik - I just blindly copied it here, didn't really check 🤦🏽
Closing this one since it's newer