<?php

/*
 * OK.
 */
$a = new MyClass();

$anon = new class { // OK.
    public static function get_instance() {
        return new self(); // Even though within anon class, it's not the anon class instantiation we're looking for.
    }
}

$util->doSomething( new class {} ); // OK.
$b = new class( 10 ) extends SomeClass implements SomeInterface {}; // OK, has parameter.
$anon = new class // Comment
    ($param) {}; // OK, has parameter.

/*
 * Bad.
 */
$util->doSomething( new class {} );
$b = new class  extends SomeClass implements SomeInterface {};
$anon = new class // Comment
     {};

$b = new class /*comment*/ {};

/*
 * Safeguard handling of anon classes with attributes.
 */
$anon = new
#[AllowDynamicProperties]
#[MyAttribute, AnotherAttribute]
class {}; // Bad.

$anon = new
#[MyAttribute, AnotherAttribute]
class {}; // OK.

// Live coding.
// Intentional parse error. This has to be the last test in the file.
$anon = new class()
