summaryrefslogtreecommitdiff
path: root/Zend/zend_execute.c
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2010-05-20 19:18:35 +0000
committerDerick Rethans <derick@php.net>2010-05-20 19:18:35 +0000
commit1bc92476518307a4eacc5d5e81be0f535a14fe4a (patch)
tree57b0cf247f38f2c0bf5a41c29ce3dc90a25156bc /Zend/zend_execute.c
parentf291a1253d1e428f51aacf4ddec297a5de8f518c (diff)
downloadphp-git-1bc92476518307a4eacc5d5e81be0f535a14fe4a.tar.gz
- Added scalar typehinting.
Diffstat (limited to 'Zend/zend_execute.c')
-rw-r--r--Zend/zend_execute.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index d573bdc5c6..1756a74968 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -671,13 +671,21 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
need_msg = zend_verify_arg_class_kind(cur_arg_info, fetch_type, &class_name, &ce TSRMLS_CC);
return zend_verify_arg_error(zf, arg_num, need_msg, class_name, zend_zval_type_name(arg), "" TSRMLS_CC);
}
- } else if (cur_arg_info->array_type_hint) {
+ } else if (cur_arg_info->type_hint) {
if (!arg) {
- return zend_verify_arg_error(zf, arg_num, "be an array", "", "none", "" TSRMLS_CC);
+ return zend_verify_arg_error(zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), "none", "" TSRMLS_CC);
}
- if (Z_TYPE_P(arg) != IS_ARRAY && (Z_TYPE_P(arg) != IS_NULL || !cur_arg_info->allow_null)) {
- return zend_verify_arg_error(zf, arg_num, "be an array", "", zend_zval_type_name(arg), "" TSRMLS_CC);
+
+ /* existing type already matches the hint or forced type */
+ if (Z_TYPE_P(arg) == cur_arg_info->type_hint) {
+ return 1;
+ }
+
+ /* NULL type given, check if parameter is optional */
+ if (Z_TYPE_P(arg) == IS_NULL && cur_arg_info->allow_null) {
+ return 1;
}
+ return zend_verify_arg_error(zf, arg_num, "be of the type ", zend_get_type_by_const(cur_arg_info->type_hint), "", zend_zval_type_name(arg) TSRMLS_CC);
}
return 1;
}