Download src/php/php-src/Zend/tests/anon/004.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 899 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/anon/004.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/anon/004.phpt
-
curl -L -o 004.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/anon/004.phpt
899 Bytes
| --TEST-- | |
| testing anonymous inheritance | |
| --FILE-- | |
| 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): mixed { return $this->data[$offset]; } | |
| public function offsetSet($offset, $data): void { $this->data[$offset] = $data; } | |
| public function offsetUnset($offset): void { unset($this->data[$offset]); } | |
| public function offsetExists($offset): bool { return isset($this->data[$offset]); } | |
| }; | |
| } | |
| } | |
| $outer = new Outer(array( | |
| rand(1, 100) | |
| )); | |
| /* not null because inheritance */ | |
| var_dump($outer->getArrayAccess()[0]); | |
| --EXPECTF-- | |
| int(%d) | |