Download src/php/php-src/Zend/tests/arrow_functions/006.phpt from meddyrat/dis-bench: direct link, hf CLI and curl.
- Browser
- Download file 811 Bytes
-
https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/arrow_functions/006.phpt
- Command line
-
hf download hf://datasets/meddyrat/dis-bench/src/php/php-src/Zend/tests/arrow_functions/006.phpt
-
curl -L -o 006.phpt https://huggingface.co/datasets/meddyrat/dis-bench/resolve/main/src/php/php-src/Zend/tests/arrow_functions/006.phpt
811 Bytes
| --TEST-- | |
| Arrow functions syntax variations | |
| --FILE-- | |
| // By-reference argument and return | |
| $var = 1; | |
| $id = fn&(&$x) => $x; | |
| $ref =& $id($var); | |
| $ref++; | |
| var_dump($var); | |
| // int argument and return type | |
| $var = 10; | |
| $int_fn = fn(int $x): int => $x; | |
| var_dump($int_fn($var)); | |
| try { | |
| $int_fn("foo"); | |
| } catch (TypeError $e) { | |
| echo $e->getMessage(), "\n"; | |
| } | |
| $varargs = fn(?int... $args): array => $args; | |
| var_dump($varargs(20, null, 30)); | |
| try { | |
| $varargs(40, "foo"); | |
| } catch (TypeError $e) { | |
| echo $e->getMessage(), "\n"; | |
| } | |
| --EXPECTF-- | |
| int(2) | |
| int(10) | |
| {closure:%s:%d}(): Argument #1 ($x) must be of type int, string given, called in %s on line %d | |
| array(3) { | |
| [0]=> | |
| int(20) | |
| [1]=> | |
| NULL | |
| [2]=> | |
| int(30) | |
| } | |
| {closure:%s:%d}(): Argument #2 must be of type ?int, string given, called in %s on line %d | |