Closed rikvdh closed 3 months ago
@rikvdh Please add a code sample of the desired behaviour (and what's not working).
This is invalid, the parentheses are not allowed there:
<?php
$foo = new class() {};
Valid should be:
<?php
$foo = new class {};
This is currently not covered by any sniff.
Confirmed for PHPCS. For what it's worth, PHPCSExtra does contain a sniff for this: Universal.Classes.DisallowAnonClassParentheses
.
Ok, I've overlooked this one. We'll go with this one for now.. 👍
For PER 2.0 we need a sniff to check the absence of parentheses when no arguments are needed for an anonymous class.
The current existing sniff for 'anonymous classes' (
PSR12.Classes.AnonClassDeclaration
) could be extended with an configuration option. But maybe this specific behavior is easily checked in a new Sniff as well.