Download src/php/php-src/Zend/tests/closures/closure_026.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 971 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/closures/closure_026.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/closures/closure_026.phpt
-
curl -L -o closure_026.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/closures/closure_026.phpt
971 Bytes
| --TEST-- | |
| Closure 026: Assigning a closure object to an array in $this | |
| --FILE-- | |
| class foo { | |
| public $a; | |
| public function __construct() { | |
| $a =& $this; | |
| $a->a[] = function() { | |
| return 1; | |
| }; | |
| var_dump($this); | |
| var_dump($this->a[0]()); | |
| } | |
| } | |
| $x = new foo; | |
| print "--------------\n"; | |
| foreach ($x as $b => $c) { | |
| var_dump($b, $c); | |
| var_dump($c[0]()); | |
| } | |
| --EXPECTF-- | |
| object(foo)#%d (1) { | |
| ["a"]=> | |
| array(1) { | |
| [0]=> | |
| object(Closure)#%d (4) { | |
| ["name"]=> | |
| string(%d) "{closure:%s:%d}" | |
| ["file"]=> | |
| string(%d) "%s" | |
| ["line"]=> | |
| int(%d) | |
| ["this"]=> | |
| *RECURSION* | |
| } | |
| } | |
| } | |
| int(1) | |
| -------------- | |
| string(1) "a" | |
| array(1) { | |
| [0]=> | |
| object(Closure)#%d (4) { | |
| ["name"]=> | |
| string(%d) "{closure:%s:%d}" | |
| ["file"]=> | |
| string(%d) "%s" | |
| ["line"]=> | |
| int(%d) | |
| ["this"]=> | |
| object(foo)#%d (1) { | |
| ["a"]=> | |
| *RECURSION* | |
| } | |
| } | |
| } | |
| int(1) | |