coding-standard icon indicating copy to clipboard operation
coding-standard copied to clipboard

`SlevomatCodingStandard.PHP.UselessParentheses` not picking up on `$var = (new ClassName());`

Open earthiverse opened this issue 1 year ago • 0 comments

Essentially what I wrote in the title.

I added the SlevomatCodingStandard.PHP.UselessParentheses sniff to try to pick up on these useless parentheses from a recent code review:

$remoteAddress = (new RemoteAddress());

but it never detected it. It did detect a lot of other useless parentheses, though :)

Of course, if I did something like this:

$ip = (new RemoteAddress())->getIpAddress();

I expect the sniff not to report as useless (but PHP 8.4 might allow no parentheses around new objects!?)

earthiverse avatar Jun 07 '24 07:06 earthiverse