diff options
author | Stanislav Malyshev <stas@php.net> | 2013-01-22 00:36:26 -0800 |
---|---|---|
committer | Stanislav Malyshev <stas@php.net> | 2013-01-22 00:36:26 -0800 |
commit | 92b5bdc231ede3879df048d9ba061d2369c3102e (patch) | |
tree | 905ec84741dceba1b0b4a5d7effd783eb64504fd /ext/reflection/php_reflection.c | |
parent | d78f5ababe4ce5503feead535308715f27727c50 (diff) | |
parent | 85fae636d09a08b53ffd7244cc6e8ec4d4cdab7c (diff) | |
download | php-git-92b5bdc231ede3879df048d9ba061d2369c3102e.tar.gz |
Merge branch 'PHP-5.5' of git.php.net:php-src into PHP-5.5
* 'PHP-5.5' of git.php.net:php-src:
Merge fix of #62836 to ?.re, and regenerate ?.c
Fixed bug #64007 (There is an ability to create instance of Generator by hand).
- Fixed ZTS build
Class Name Resolution As Scalar Via "class" Keyword
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r-- | ext/reflection/php_reflection.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index ff3a6a5087..5c844b8d4d 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -4192,13 +4192,21 @@ ZEND_METHOD(reflection_class, newInstance) { zval *retval_ptr = NULL; reflection_object *intern; - zend_class_entry *ce; + zend_class_entry *ce, *old_scope; + zend_function *constructor; METHOD_NOTSTATIC(reflection_class_ptr); GET_REFLECTION_OBJECT_PTR(ce); + object_init_ex(return_value, ce); + + old_scope = EG(scope); + EG(scope) = ce; + constructor = Z_OBJ_HT_P(return_value)->get_constructor(return_value TSRMLS_CC); + EG(scope) = old_scope; + /* Run the constructor if there is one */ - if (ce->constructor) { + if (constructor) { zval ***params = NULL; int num_args = 0; zend_fcall_info fci; @@ -4206,18 +4214,18 @@ ZEND_METHOD(reflection_class, newInstance) if (!(ce->constructor->common.fn_flags & ZEND_ACC_PUBLIC)) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Access to non-public constructor of class %s", ce->name); - return; + zval_dtor(return_value); + RETURN_NULL(); } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "*", ¶ms, &num_args) == FAILURE) { if (params) { efree(params); } + zval_dtor(return_value); RETURN_FALSE; } - object_init_ex(return_value, ce); - fci.size = sizeof(fci); fci.function_table = EG(function_table); fci.function_name = NULL; @@ -4242,6 +4250,7 @@ ZEND_METHOD(reflection_class, newInstance) zval_ptr_dtor(&retval_ptr); } php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invocation of %s's constructor failed", ce->name); + zval_dtor(return_value); RETURN_NULL(); } if (retval_ptr) { @@ -4250,9 +4259,7 @@ ZEND_METHOD(reflection_class, newInstance) if (params) { efree(params); } - } else if (!ZEND_NUM_ARGS()) { - object_init_ex(return_value, ce); - } else { + } else if (ZEND_NUM_ARGS()) { zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s does not have a constructor, so you cannot pass any constructor arguments", ce->name); } } |