summaryrefslogtreecommitdiff
path: root/ext/reflection/php_reflection.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-04-01 12:11:13 +0300
committerDmitry Stogov <dmitry@zend.com>2015-04-01 12:11:13 +0300
commit4796e0242b8cdd2a77b552fcbaa74d70d87f6d0a (patch)
tree0881d7c1a1775deb840ded202edc2c1de6e9abd6 /ext/reflection/php_reflection.c
parent52fcc74875b26a2d7000af23c1705516280a7634 (diff)
parent2afca9f179fca2e127d5da3e1cc6cf50ff47339c (diff)
downloadphp-git-4796e0242b8cdd2a77b552fcbaa74d70d87f6d0a.tar.gz
Merge branch 'InternalClassClean'
* InternalClassClean: Fixed test Patch improvement: Fixed indentation. Fixed comment style. Fixed commented out code. Reverted change to function name and added note of why it is different from the class it is actually changing. Made UConverter throw an exception if the constructor fails. Fixed PDO constructor to not return null. Fixed fileinfo behaviour. Made Phar throw exception on bad constructor. Converted intl extension to use IntlException in constructors. Fixed SplFixedArray and tests. Fixed ReflectionExtension and ReflectionProperty. Fixed ReflectionFunction, ReflectionMethod and ReflectionParameter. Fixed PDORow behaviour and message.
Diffstat (limited to 'ext/reflection/php_reflection.c')
-rw-r--r--ext/reflection/php_reflection.c80
1 files changed, 58 insertions, 22 deletions
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index e78410ec71..4dc0ed6868 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -1577,6 +1577,8 @@ ZEND_METHOD(reflection_function, __construct)
zend_function *fptr;
char *name_str;
size_t name_len;
+ int rv;
+ zend_error_handling zeh;
object = getThis();
intern = Z_REFLECTION_P(object);
@@ -1587,27 +1589,32 @@ ZEND_METHOD(reflection_function, __construct)
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "O", &closure, zend_ce_closure) == SUCCESS) {
fptr = (zend_function*)zend_get_closure_method_def(closure);
Z_ADDREF_P(closure);
- } else if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == SUCCESS) {
- char *nsname;
-
- lcname = zend_str_tolower_dup(name_str, name_len);
-
- /* Ignore leading "\" */
- nsname = lcname;
- if (lcname[0] == '\\') {
- nsname = &lcname[1];
- name_len--;
- }
-
- if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) {
+ } else {
+ zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
+ rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len);
+ zend_restore_error_handling(&zeh TSRMLS_CC);
+ if (rv == SUCCESS) {
+ char *nsname;
+ lcname = zend_str_tolower_dup(name_str, name_len);
+
+ /* Ignore leading "\" */
+ nsname = lcname;
+ if (lcname[0] == '\\') {
+ nsname = &lcname[1];
+ name_len--;
+ }
+
+ if ((fptr = zend_hash_str_find_ptr(EG(function_table), nsname, name_len)) == NULL) {
+ efree(lcname);
+ zend_throw_exception_ex(reflection_exception_ptr, 0,
+ "Function %s() does not exist", name_str);
+ return;
+ }
efree(lcname);
- zend_throw_exception_ex(reflection_exception_ptr, 0,
- "Function %s() does not exist", name_str);
+ } else {
+ /* Exception has been thrown. */
return;
}
- efree(lcname);
- } else {
- return;
}
ZVAL_STR_COPY(&name, fptr->common.function_name);
@@ -2129,10 +2136,14 @@ ZEND_METHOD(reflection_parameter, __construct)
zend_class_entry *ce = NULL;
zend_bool is_closure = 0;
zend_bool is_invoke = 0;
+ zend_error_handling zeh;
+ zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &reference, &parameter) == FAILURE) {
+ zend_restore_error_handling(&zeh TSRMLS_CC);
return;
}
+ zend_restore_error_handling(&zeh TSRMLS_CC);
object = getThis();
intern = Z_REFLECTION_P(object);
@@ -2713,7 +2724,13 @@ ZEND_METHOD(reflection_method, __construct)
zval ztmp;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len) == FAILURE) {
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
+ zend_error_handling zeh;
+ int rv;
+
+ zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
+ rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len);
+ zend_restore_error_handling(&zeh TSRMLS_CC);
+ if (rv == FAILURE) {
return;
}
if ((tmp = strstr(name_str, "::")) == NULL) {
@@ -4786,7 +4803,14 @@ ZEND_METHOD(reflection_property, __construct)
zend_property_info *property_info = NULL;
property_reference *reference;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len) == FAILURE) {
+ int rv;
+ zend_error_handling zeh;
+
+ zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
+ rv = zend_parse_parameters(ZEND_NUM_ARGS(), "zs", &classname, &name_str, &name_len);
+ zend_restore_error_handling(&zeh TSRMLS_CC);
+
+ if (rv == FAILURE) {
return;
}
@@ -5181,9 +5205,15 @@ ZEND_METHOD(reflection_extension, __construct)
zend_module_entry *module;
char *name_str;
size_t name_len;
+ int rv;
+ zend_error_handling zeh;
ALLOCA_FLAG(use_heap)
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
+ zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
+ rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len);
+ zend_restore_error_handling(&zeh TSRMLS_CC);
+
+ if (rv == FAILURE) {
return;
}
@@ -5550,8 +5580,14 @@ ZEND_METHOD(reflection_zend_extension, __construct)
zend_extension *extension;
char *name_str;
size_t name_len;
+ int rv;
+ zend_error_handling zeh;
+
+ zend_replace_error_handling(EH_THROW, reflection_exception_ptr, &zeh TSRMLS_CC);
+ rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len);
+ zend_restore_error_handling(&zeh TSRMLS_CC);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name_str, &name_len) == FAILURE) {
+ if (rv == FAILURE) {
return;
}