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

Function return type breaks WPForms.Formatting.EmptyLineBeforeReturn sniff #32

Closed slaFFik closed 7 months ago

slaFFik commented 10 months ago

Here is what I found today:

public function all(): array {

    return $this->data;
}

This code will generate this notification: WPForms.Formatting.EmptyLineBeforeReturn.RemoveEmptyLineBeforeReturnStatement

When I remove empty line before return, I get this notification: WPForms.Formatting.EmptyLineAfterFunctionDeclaration.AddEmptyLineAfterFunctionDeclaration

The problem is in the return type added to the function declaration: : array. If I remove it - everything works just fine.

It looks like WPForms PHPCS is not aware of the function's return type and does not treat them properly.

Expected behavior: ignore them OR make sure the declared return type is the same as the actual return value of the function.

I'm using wpforms-phpcs@1.1.0