On Wed, 11 Aug 2010, Stas Malyshev wrote:
> So I'd propose doing the following:
>
> 1. Moving parameter typing to a feature branch (by branching current trunk and
> then rolling back the typing part in the trunk).
> 2. Starting 5.4 alpha process after that basing on trunk.
>
> Any objections to this?
A little bit; yes. There is indeed 0 consensus for having the strict
typehints. However, instead of removing it altogether, and instead
answering every mail in this thread :P, I wrote/am writing a patch that
removes the hard type checks. It however keeps the parsed structures and
reflection API for it. In this sense, they're actually real hints. The
patch also adds a mechanism similariy to the zend_error_cb mechanism so
that extensions could override the argument type checking. As my use
case for strict checking is development I'd be happy to just move the
hard checks into an extension. I could even offer a soft check. It also
allows some type inference which might be useful for webservice
introspecition generation. I am sure SOAP might have some benefit of
this, and I know that at least pecl/dbus does. The patch is attached,
but not ready (I haven't remove the hard checks yet because things got
busy at work).
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Index: ext/standard/var_unserializer.c
===================================================================
--- ext/standard/var_unserializer.c (revision 302073)
+++ ext/standard/var_unserializer.c (working copy)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Fri Aug 6 19:20:07 2010 */
+/* Generated by re2c 0.13.5 on Tue Aug 10 15:20:52 2010 */
#line 1 "ext/standard/var_unserializer.re"
/*
+----------------------------------------------------------------------+
Index: Zend/zend.c
===================================================================
--- Zend/zend.c (revision 302073)
+++ Zend/zend.c (working copy)
@@ -648,6 +648,7 @@
zend_vspprintf = utility_functions->vspprintf_function;
zend_getenv = utility_functions->getenv_function;
zend_resolve_path = utility_functions->resolve_path_function;
+ zend_verify_arg_type = utility_functions->verify_arg_type_function;
#if HAVE_DTRACE
/* build with dtrace support */
Index: Zend/zend.h
===================================================================
--- Zend/zend.h (revision 302073)
+++ Zend/zend.h (working copy)
@@ -536,6 +536,7 @@
int (*vspprintf_function)(char **pbuf, size_t max_len, const char
*format, va_list ap);
char *(*getenv_function)(char *name, size_t name_len TSRMLS_DC);
char *(*resolve_path_function)(const char *filename, int filename_len
TSRMLS_DC);
+ int (*verify_arg_type_function)(union _zend_function *zf, zend_uint
arg_num, zval *arg, ulong fetch_type TSRMLS_DC);
} zend_utility_functions;
typedef struct _zend_utility_values {
Index: Zend/zend_execute.c
===================================================================
--- Zend/zend_execute.c (revision 302073)
+++ Zend/zend_execute.c (working copy)
@@ -589,7 +589,7 @@
}
}
-static inline int zend_verify_arg_error(const zend_function *zf, zend_uint
arg_num, const char *need_msg, const char *need_kind, const char *given_msg,
char *given_kind TSRMLS_DC)
+ZEND_API int zend_verify_arg_error(const zend_function *zf, zend_uint arg_num,
const char *need_msg, const char *need_kind, const char *given_msg, char
*given_kind TSRMLS_DC)
{
zend_execute_data *ptr = EG(current_execute_data)->prev_execute_data;
char *fname = zf->common.function_name;
@@ -612,7 +612,7 @@
return 0;
}
-static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num,
zval *arg, ulong fetch_type TSRMLS_DC)
+ZEND_API int zend_original_verify_arg_type(zend_function *zf, zend_uint
arg_num, zval *arg, ulong fetch_type TSRMLS_DC)
{
zend_arg_info *cur_arg_info;
char *need_msg;
Index: Zend/zend_execute.h
===================================================================
--- Zend/zend_execute.h (revision 302073)
+++ Zend/zend_execute.h (working copy)
@@ -389,7 +389,11 @@
ZEND_API zend_class_entry *zend_fetch_class(const char *class_name, uint
class_name_len, int fetch_type TSRMLS_DC);
ZEND_API zend_class_entry *zend_fetch_class_by_name(const char *class_name,
uint class_name_len, const zend_literal *key, int fetch_type TSRMLS_DC);
void zend_verify_abstract_class(zend_class_entry *ce TSRMLS_DC);
+ZEND_API int zend_verify_arg_error(const zend_function *zf, zend_uint arg_num,
const char *need_msg, const char *need_kind, const char *given_msg, char
*given_kind TSRMLS_DC);
+ZEND_API int zend_original_verify_arg_type(zend_function *zf, zend_uint
arg_num, zval *arg, ulong fetch_type TSRMLS_DC);
+ZEND_API int (*zend_verify_arg_type)(zend_function *zf, zend_uint arg_num,
zval *arg, ulong fetch_type TSRMLS_DC);
+
#ifdef ZEND_WIN32
void zend_init_timeout_thread(void);
void zend_shutdown_timeout_thread(void);
Index: main/main.c
===================================================================
--- main/main.c (revision 302073)
+++ main/main.c (working copy)
@@ -1885,6 +1885,7 @@
zuf.vspprintf_function = vspprintf;
zuf.getenv_function = sapi_getenv;
zuf.resolve_path_function = php_resolve_path_for_zend;
+ zuf.verify_arg_type_function = zend_original_verify_arg_type;
zend_startup(&zuf, NULL TSRMLS_CC);
#ifdef ZTS
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php