diff options
| author | Nikita Popov <nikic@php.net> | 2013-09-26 18:39:17 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2013-09-26 18:39:17 +0200 |
| commit | 0d7a6388663b76ebed6585ac92dfca5ef65fa7af (patch) | |
| tree | 1317a8a47c0e4bd1193c8fbf705d91ae75140f78 /Zend/tests/variadic/optional_params.phpt | |
| parent | 6daa04a4f606f8121d9f1ea6cd90c1c8a684500e (diff) | |
| download | php-git-0d7a6388663b76ebed6585ac92dfca5ef65fa7af.tar.gz | |
Implement variadic function syntax
As per RFC: https://wiki.php.net/rfc/variadics
Diffstat (limited to 'Zend/tests/variadic/optional_params.phpt')
| -rw-r--r-- | Zend/tests/variadic/optional_params.phpt | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Zend/tests/variadic/optional_params.phpt b/Zend/tests/variadic/optional_params.phpt new file mode 100644 index 0000000000..ba965e538c --- /dev/null +++ b/Zend/tests/variadic/optional_params.phpt @@ -0,0 +1,49 @@ +--TEST-- +Optional parameter before variadic parameter +--FILE-- +<?php + +function fn($reqParam, $optParam = null, ...$params) { + var_dump($reqParam, $optParam, $params); +} + +fn(1); +fn(1, 2); +fn(1, 2, 3); +fn(1, 2, 3, 4); +fn(1, 2, 3, 4, 5); + +?> +--EXPECT-- +int(1) +NULL +array(0) { +} +int(1) +int(2) +array(0) { +} +int(1) +int(2) +array(1) { + [0]=> + int(3) +} +int(1) +int(2) +array(2) { + [0]=> + int(3) + [1]=> + int(4) +} +int(1) +int(2) +array(3) { + [0]=> + int(3) + [1]=> + int(4) + [2]=> + int(5) +} |
