<?php
/*
 * All OK.
 */
$a = new MyClass();
$a = new MyClass( $something );
$a = new $varHoldingClassName();
$a = new self::$transport[$cap_string]();
$renderer = new $this->inline_diff_renderer();
$b = ( new MyClass() )->my_function();
$b = ( new MyClass() )::$property;

class ClassA {
	public static function get_instance() {
		return new self();
	}

	public static function get_other_instance() {
		return new static();
	}
}

class ClassB extends ClassA {
	public function get_parent_instance() {
		return new parent();
	}
}

// PHP 7: Anonymous classes.
$util->setLogger( new class() {} );
$b = new class( 10 ) extends SomeClass implements SomeInterface {};


/*
 * Bad.
 */
$a = new MyClass();
$a = new $varHoldingClassName();
$a = new self::$transport[$cap_string]();
$renderer = new $this->inline_diff_renderer();
$b = ( new MyClass() )->my_function();
$b = ( new MyClass() )::$property;

class ClassAA {
	public static function get_instance() {
		return new self();
	}

	public static function get_other_instance() {
		return new static();
	}
}

class ClassBB extends ClassA {
	public function get_parent_instance() {
		return new parent();
	}
}

// PHP 7: Anonymous classes.
$util->setLogger( new class() {} );
$b = new class() extends SomeClass implements SomeInterface {};


// Test some non-typical spacing.
$renderer = new $this->
					inline_diff_renderer();
$renderer = new $this-> // There can be a comment here.
					inline_diff_renderer();
$renderer = new $this->
					inline_diff_renderer /* or here */ ();
$a = new self :: $transport [ $cap_string ]();

$renderer = new $this->
					inline_diff_renderer();
$renderer = new $this-> // There can be a comment here.
					inline_diff_renderer();
$renderer = new $this->
					inline_diff_renderer() /* or here */ ;
$a = new self :: $transport [ $cap_string ]();


// Assigning new by reference.
$b = &new Foobar();
$b = & new Foobar();


// Currently not accounted for by the sniff, i.e. false negatives.
$a = new $$varHoldingClassName;
$a = new ${$varHoldingClassName};

// Namespaced classes: OK.
$a = new \MyClass();
$a = new \MyNamespace\MyClass();

// Namespaced classes: Bad.
$a = new \MyClass();
$a = new \MyNamespace\MyClass();

// Non-variable keys: OK.
$a = new $array['key']();
$a = new $array[0]();

// Non-variable keys: Bad.
$a = new $array['key']();
$a = new $array[0]();
