php-src/Zend/tests/objects_032.phpt
Máté Kocsis 75a678a7e3
Declare tentative return types for Zend (#7251)
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 13:44:20 +02:00

39 lines
538 B
PHP

--TEST--
Covariant return-by-ref constraints
--FILE--
<?php
class A implements ArrayAccess {
public $foo = array();
public function &offsetGet($n): mixed {
return $this->foo[$n];
}
public function offsetSet($n, $v): void {
}
public function offsetUnset($n): void {
}
public function offsetExists($n): bool {
}
}
$a = new A;
$a['foo']['bar'] = 2;
var_dump($a);
?>
--EXPECT--
object(A)#1 (1) {
["foo"]=>
array(1) {
["foo"]=>
array(1) {
["bar"]=>
int(2)
}
}
}