consistence / coding-standard

Consistence - Coding Standard - PHP Code Sniffer rules

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Closure variables from use are handled same way as its parameters

jaCUBE opened this issue · comments

When using closure with multiple parameters each on new line, sniffer requires every variable in use to be each on new line too.

Example:

$foo = 1;
$bar = 2;

static function (
	bool $param1,
	bool $param2
) use ($foo, $bar): int {
	return $foo + $bar;
}

…leads to…

ERROR | [x] Multi-line use declarations must define one parameter per line
      |     (Squiz.Functions.MultiLineFunctionDeclaration.UseOneParamPerLine)

Expected behaviour:
This should be fine since each parameter is defined on separate line. To put variables in use each on new line indeed let sniffer to pass; but it leads to worse code readability.