doSomething( new class() {} ); // OK. $b = new class( 10 ) extends SomeClass implements SomeInterface {}; // OK. $anon = new class // Comment () {}; // OK. /* * Bad. */ $util->doSomething( new class() {} ); $b = new class() extends SomeClass implements SomeInterface {}; /* * Safeguard handling of anon classes with attributes. */ $anon = new #[MyAttribute, AnotherAttribute] class() {}; // OK. $anon = new #[AllowDynamicProperties] #[MyAttribute, AnotherAttribute] class() {}; // Bad. /* * Safeguard handling of PHP 8.3 readonly anon classes. */ $anon = new readonly class() {}; $anon = new readonly class() {}; // Live coding. // Intentional parse error. This has to be the last test in the file. $anon = new class