Skip to content

Closures in PSR2 are not checked for a space after the function keyword #496

@lukaszmoroz

Description

@lukaszmoroz

Currently phpcs doesn't check for a space between the function keyword and argument list in closures, so following code doesn't raise any warning:

$callback = function() { };

I'm trying to follow PSR-2 and it's somewhat annoying because i make that mistake rather often.

Also, this code passes without any warning:

$callback = function () use ($this){ };

Although it is not explicitly said that there must be a space after closing parenthesis of use list, it remains inconsistent with following case, for which there isn't an explicit rule either yet it actually raises an error:

$callback = function (){ };

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions