Browse Source

Add test function arguments

pull/1050/head
Reeze Xia 11 years ago
parent
commit
2c84006f5a
  1. 15
      Zend/tests/return_types/internal_functions001.phpt
  2. 16
      Zend/tests/return_types/internal_functions002.phpt
  3. 19
      Zend/zend_builtin_functions.c

15
Zend/tests/return_types/internal_functions001.phpt

@ -0,0 +1,15 @@
--TEST--
Return type hinting for internal functions
--SKIPIF--
<?php
if (!function_exists('zend_test_func')) {
print 'skip';
}
--FILE--
<?php
zend_test_func();
?>
--EXPECTF--
Catchable fatal error: Return value of zend_test_func() must be of the type array, null returned in %s on line %d

16
Zend/tests/return_types/internal_functions002.phpt

@ -0,0 +1,16 @@
--TEST--
Return type hinting for internal functions 2
--SKIPIF--
<?php
if (!function_exists('zend_test_func2')) {
print 'skip';
}
--FILE--
<?php
zend_test_func2();
echo "==DONE==\n"
?>
--EXPECTF--
==DONE==

19
Zend/zend_builtin_functions.c

@ -87,6 +87,7 @@ static ZEND_FUNCTION(debug_backtrace);
static ZEND_FUNCTION(debug_print_backtrace);
#if ZEND_DEBUG
static ZEND_FUNCTION(zend_test_func);
static ZEND_FUNCTION(zend_test_func2);
#ifdef ZTS
static ZEND_FUNCTION(zend_thread_id);
#endif
@ -243,6 +244,14 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_extension_loaded, 0, 0, 1)
ZEND_ARG_INFO(0, extension_name)
ZEND_END_ARG_INFO()
#ifdef ZEND_DEBUG
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func, IS_ARRAY, NULL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO(arginfo_zend_test_func2, IS_ARRAY, NULL, 1)
ZEND_END_ARG_INFO()
#endif
/* }}} */
static const zend_function_entry builtin_functions[] = { /* {{{ */
@ -304,7 +313,8 @@ static const zend_function_entry builtin_functions[] = { /* {{{ */
ZEND_FE(debug_backtrace, arginfo_debug_backtrace)
ZEND_FE(debug_print_backtrace, arginfo_debug_print_backtrace)
#if ZEND_DEBUG
ZEND_FE(zend_test_func, NULL)
ZEND_FE(zend_test_func, arginfo_zend_test_func)
ZEND_FE(zend_test_func2, arginfo_zend_test_func2)
#ifdef ZTS
ZEND_FE(zend_thread_id, NULL)
#endif
@ -1954,6 +1964,13 @@ ZEND_FUNCTION(zend_test_func)
zend_get_parameters(ZEND_NUM_ARGS(), 2, &arg1, &arg2);
}
ZEND_FUNCTION(zend_test_func2)
{
zval *arg1, *arg2;
zend_get_parameters(ZEND_NUM_ARGS(), 2, &arg1, &arg2);
}
#ifdef ZTS
ZEND_FUNCTION(zend_thread_id)

Loading…
Cancel
Save