diff --git a/generated/array.php b/generated/array.php index 5b99c713..ecde0ef6 100644 --- a/generated/array.php +++ b/generated/array.php @@ -67,8 +67,8 @@ function array_multisort(array &$array1, $array1_sort_order = SORT_ASC, $array1_sort_flags = SORT_REGULAR, ...$params): void { error_clear_last(); - if ($params !== null) { - $result = \array_multisort($array1, $array1_sort_order, $array1_sort_flags, $params); + if ($params !== []) { + $result = \array_multisort($array1, $array1_sort_order, $array1_sort_flags, ...$params); } else { $result = \array_multisort($array1, $array1_sort_order, $array1_sort_flags); } diff --git a/generated/funchand.php b/generated/funchand.php index a6379920..16921886 100644 --- a/generated/funchand.php +++ b/generated/funchand.php @@ -62,8 +62,8 @@ function func_get_arg(int $arg_num) function register_tick_function(callable $function, $arg = null, ...$params): void { error_clear_last(); - if ($params !== null) { - $result = \register_tick_function($function, $arg, $params); + if ($params !== []) { + $result = \register_tick_function($function, $arg, ...$params); } elseif ($arg !== null) { $result = \register_tick_function($function, $arg); } else { diff --git a/generated/session.php b/generated/session.php index 5e3184ad..9e84d68a 100644 --- a/generated/session.php +++ b/generated/session.php @@ -124,8 +124,8 @@ function session_regenerate_id(bool $delete_old_session = false): void function session_register($name, ...$params): void { error_clear_last(); - if ($params !== null) { - $result = \session_register($name, $params); + if ($params !== []) { + $result = \session_register($name, ...$params); } else { $result = \session_register($name); } diff --git a/generated/strings.php b/generated/strings.php index f6c11ecc..dc5f25ac 100644 --- a/generated/strings.php +++ b/generated/strings.php @@ -439,8 +439,8 @@ function metaphone(string $str, int $phonemes = 0): string function sprintf(string $format, $args = null, ...$params): string { error_clear_last(); - if ($params !== null) { - $result = \sprintf($format, $args, $params); + if ($params !== []) { + $result = \sprintf($format, $args, ...$params); } elseif ($args !== null) { $result = \sprintf($format, $args); } else { diff --git a/generator/src/WritePhpFunction.php b/generator/src/WritePhpFunction.php index a9f814a6..d9d8f134 100644 --- a/generator/src/WritePhpFunction.php +++ b/generator/src/WritePhpFunction.php @@ -71,8 +71,12 @@ private function writePhpFunction(): string } else { $phpFunction .= ' '; } - $defaultValue = $lastParameter->getDefaultValue(); - $defaultValueToString = ($defaultValue === null) ? 'null' : $defaultValue; + if ($lastParameter->isVariadic()) { + $defaultValueToString = '[]'; + } else { + $defaultValue = $lastParameter->getDefaultValue(); + $defaultValueToString = ($defaultValue === null) ? 'null' : $defaultValue; + } $phpFunction .= 'if ($'.$lastParameter->getParameter().' !== '.$defaultValueToString.') {'."\n"; $phpFunction .= ' $result = '.$this->printFunctionCall($method)."\n"; $phpFunction .= ' }'; @@ -161,7 +165,11 @@ private function printFunctionCall(Method $function): string { $functionCall = '\\'.$function->getFunctionName().'('; $functionCall .= implode(', ', \array_map(function (Parameter $parameter) { - return '$'.$parameter->getParameter(); + $str = ''; + if ($parameter->isVariadic()) { + $str = '...'; + } + return $str.'$'.$parameter->getParameter(); }, $function->getFunctionParam())); $functionCall .= ');'; return $functionCall;