[lang-ref] ( set_default_value_and_get ) ( php )

<?php
public function testSetDefaultValueAndGetAlternative(): void
{
	$d = [];

	$this->assertArrayNotHasKey('A', $d);

	if (!array_key_exists('A', $d)) {
		$d['A'] = -1;
	}
	$v = $d['A'];

	$this->assertSame(-1, $v);
	$this->assertArrayHasKey('A', $d);
}