2010-11-03 15:40:24 +00:00
|
|
|
--TEST--
|
|
|
|
Covariant return-by-ref constraints
|
|
|
|
--FILE--
|
|
|
|
<?php
|
|
|
|
|
|
|
|
class A implements ArrayAccess {
|
|
|
|
public $foo = array();
|
|
|
|
|
2021-07-19 11:44:20 +00:00
|
|
|
public function &offsetGet($n): mixed {
|
2010-11-03 15:40:24 +00:00
|
|
|
return $this->foo[$n];
|
|
|
|
}
|
|
|
|
|
2021-07-19 11:44:20 +00:00
|
|
|
public function offsetSet($n, $v): void {
|
2010-11-03 15:40:24 +00:00
|
|
|
}
|
2021-07-19 11:44:20 +00:00
|
|
|
public function offsetUnset($n): void {
|
2010-11-03 15:40:24 +00:00
|
|
|
}
|
2021-07-19 11:44:20 +00:00
|
|
|
public function offsetExists($n): bool {
|
2010-11-03 15:40:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$a = new A;
|
|
|
|
|
|
|
|
$a['foo']['bar'] = 2;
|
|
|
|
|
|
|
|
var_dump($a);
|
|
|
|
|
|
|
|
?>
|
2018-02-19 08:59:41 +00:00
|
|
|
--EXPECT--
|
2010-11-03 15:40:24 +00:00
|
|
|
object(A)#1 (1) {
|
|
|
|
["foo"]=>
|
|
|
|
array(1) {
|
|
|
|
["foo"]=>
|
|
|
|
array(1) {
|
|
|
|
["bar"]=>
|
|
|
|
int(2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|