Download src/php/php-src/Zend/tests/arrow_functions/005.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 975 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/arrow_functions/005.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/arrow_functions/005.phpt
-
curl -L -o 005.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/arrow_functions/005.phpt
975 Bytes
| --TEST-- | |
| Arrow function $this binding | |
| --FILE-- | |
| class Test { | |
| public function method() { | |
| // It would be okay if this is NULL, but the rest should work | |
| $fn = fn() => 42; | |
| $r = new ReflectionFunction($fn); | |
| var_dump($r->getClosureThis()); | |
| $fn = fn() => $this; | |
| var_dump($fn()); | |
| $fn = fn() => Test::method2(); | |
| $fn(); | |
| $fn = fn() => call_user_func('Test::method2'); | |
| $fn(); | |
| $thisName = "this"; | |
| $fn = fn() => $$thisName; | |
| var_dump($fn()); | |
| $fn = fn() => self::class; | |
| var_dump($fn()); | |
| // static can be used to unbind $this | |
| $fn = static fn() => isset($this); | |
| var_dump($fn()); | |
| } | |
| public function method2() { | |
| var_dump($this); | |
| } | |
| } | |
| (new Test)->method(); | |
| --EXPECT-- | |
| object(Test)#1 (0) { | |
| } | |
| object(Test)#1 (0) { | |
| } | |
| object(Test)#1 (0) { | |
| } | |
| object(Test)#1 (0) { | |
| } | |
| object(Test)#1 (0) { | |
| } | |
| string(4) "Test" | |
| bool(false) | |