1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 23:48:14 +02:00
Files
archived-php-src/Zend/tests/anon/004.phpt
T
Máté Kocsis 7aacc705d0 Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00

32 lines
883 B
PHP

--TEST--
testing anonymous inheritance
--FILE--
<?php
class Outer {
protected $data;
public function __construct($data) {
$this->data = $data;
}
public function getArrayAccess() {
/* create a proxy object implementing array access */
return new class($this->data) extends Outer implements ArrayAccess {
public function offsetGet($offset) { return $this->data[$offset]; }
public function offsetSet($offset, $data) { return ($this->data[$offset] = $data); }
public function offsetUnset($offset) { unset($this->data[$offset]); }
public function offsetExists($offset) { return isset($this->data[$offset]); }
};
}
}
$outer = new Outer(array(
rand(1, 100)
));
/* not null because inheritance */
var_dump($outer->getArrayAccess()[0]);
?>
--EXPECTF--
int(%d)