]> granicus.if.org Git - php/commitdiff
Add test function arguments
authorReeze Xia <reeze@php.net>
Wed, 4 Feb 2015 17:21:42 +0000 (01:21 +0800)
committerReeze Xia <reeze@php.net>
Wed, 4 Feb 2015 17:21:42 +0000 (01:21 +0800)
Zend/tests/return_types/internal_functions001.phpt [new file with mode: 0644]
Zend/tests/return_types/internal_functions002.phpt [new file with mode: 0644]
Zend/zend_builtin_functions.c

diff --git a/Zend/tests/return_types/internal_functions001.phpt b/Zend/tests/return_types/internal_functions001.phpt
new file mode 100644 (file)
index 0000000..8204161
--- /dev/null
@@ -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
diff --git a/Zend/tests/return_types/internal_functions002.phpt b/Zend/tests/return_types/internal_functions002.phpt
new file mode 100644 (file)
index 0000000..65838a1
--- /dev/null
@@ -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==
index 2fce4b796434e6a45ffbd577deb58e3f0b76cf8c..fe7c8f7556580a9a9886f1b4b3487ff67af82187 100644 (file)
@@ -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)