Automattic / phpcs-neutron-standard

A set of phpcs sniffs for PHP >7 development
MIT License
94 stars 7 forks source link

Check for proper whitespaces for function return types #82

Closed hambai closed 4 years ago

hambai commented 4 years ago

We noticed that there is WPCS rule for spacing around the colon in function return types. We had some discrepancies in how we were spacing the colon and since most of our team is using the Neutron coding standards I decided we should implement that check too.

The idea is that there should be no space between the function declaration and the colon, but then there should be a space between the colon and the return type.

So basically:

// valid
function(): bool {...
// invalid
function() : bool {...
// invalid
function() :bool {...

see the "return type" example here - https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#space-usage

hambai commented 4 years ago

Since we're at it I decided to add a check that there is a space after the return type

sirbrillig commented 4 years ago

Nice work.