Fixed strict zpp arginfo test

This commit is contained in:
Derick Rethans 2023-03-09 11:32:58 +00:00
parent 8a9b80cfe0
commit f8891f2861
2 changed files with 57 additions and 2 deletions

View file

@ -413,14 +413,25 @@ static ZEND_METHOD(_ZendTestClass, returnsThrowable)
}
static ZEND_METHOD(_ZendTestClass, variadicTest) {
int argc;
int argc, i;
zval *args = NULL;
ZEND_PARSE_PARAMETERS_START(0, -1)
Z_PARAM_VARIADIC('*', args, argc)
ZEND_PARSE_PARAMETERS_END();
(void) (args + argc);
for (i = 0; i < argc; i++) {
zval *arg = args + i;
if (Z_TYPE_P(arg) == IS_STRING) {
continue;
}
if (Z_TYPE_P(arg) == IS_OBJECT && instanceof_function(Z_OBJ_P(arg)->ce, zend_ce_iterator)) {
continue;
}
zend_argument_type_error(i + 1, "must be of class Iterator or a string, %s given", zend_zval_type_name(arg));
}
object_init_ex(return_value, zend_get_called_scope(execute_data));
}

View file

@ -0,0 +1,44 @@
--TEST--
Verify that variadic arguments create proper stub
--EXTENSIONS--
zend_test
--FILE--
<?php
$reflection = new ReflectionMethod("_ZendTestClass", "variadicTest");
$arguments = $reflection->getParameters();
echo (string) $arguments[0], "\n";
var_dump($arguments[0]->isVariadic());
$type = $arguments[0]->getType();
var_dump($type instanceof ReflectionUnionType);
echo "\n";
$types = $type->getTypes();
var_dump($types[0]->getName());
var_dump($types[0] instanceof ReflectionNamedType);
var_dump($types[0]->allowsNull());
echo "\n";
var_dump($types[1]->getName());
var_dump($types[1] instanceof ReflectionNamedType);
var_dump($types[1]->allowsNull());
?>
--EXPECTF--
Parameter #0 [ <optional> Iterator|string ...$elements ]
bool(true)
bool(true)
string(8) "Iterator"
bool(true)
bool(false)
string(6) "string"
bool(true)
bool(false)