mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
- Be more gracious in reflection API
This commit is contained in:
parent
a92ae61cb8
commit
a57b6bad69
3 changed files with 33 additions and 21 deletions
|
@ -952,15 +952,15 @@ ZEND_API int zend_lookup_class(char *name, int name_length, zend_class_entry ***
|
|||
return FAILURE;
|
||||
}
|
||||
|
||||
if (EG(exception)) {
|
||||
if (EG(exception) && exception) {
|
||||
free_alloca(lc_name);
|
||||
zend_error(E_ERROR, "Function %s(%s) threw an exception of type '%s'", ZEND_AUTOLOAD_FUNC_NAME, name, Z_OBJCE_P(EG(exception))->name);
|
||||
return FAILURE;
|
||||
}
|
||||
EG(exception) = exception;
|
||||
|
||||
/* If an exception is thrown retval_ptr will be NULL but we bailout before we reach this point */
|
||||
zval_ptr_dtor(&retval_ptr);
|
||||
if (!EG(exception)) {
|
||||
EG(exception) = exception;
|
||||
zval_ptr_dtor(&retval_ptr);
|
||||
}
|
||||
|
||||
retval = zend_hash_find(EG(class_table), lc_name, name_length + 1, (void **) ce);
|
||||
free_alloca(lc_name);
|
||||
|
|
|
@ -1027,17 +1027,21 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
|
|||
|
||||
result = zend_call_function(&fci, &fcc TSRMLS_CC);
|
||||
|
||||
RETURN_ON_EXCEPTION
|
||||
|
||||
if (result == FAILURE) {
|
||||
zval_dtor(&reflector);
|
||||
_DO_THROW("Could not create reflector");
|
||||
}
|
||||
|
||||
if (retval_ptr) {
|
||||
zval_ptr_dtor(&retval_ptr);
|
||||
}
|
||||
|
||||
RETURN_ON_EXCEPTION
|
||||
|
||||
if (EG(exception)) {
|
||||
zval_dtor(&reflector);
|
||||
return;
|
||||
}
|
||||
if (result == FAILURE || EG(exception)) {
|
||||
zval_dtor(&reflector);
|
||||
_DO_THROW("Could not create reflector");
|
||||
}
|
||||
|
||||
/* Call static reflection::export */
|
||||
ZVAL_BOOL(&output, return_output);
|
||||
params[0] = &reflector_ptr;
|
||||
|
@ -2263,7 +2267,9 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob
|
|||
} else {
|
||||
convert_to_string_ex(&argument);
|
||||
if (zend_lookup_class(Z_STRVAL_P(argument), Z_STRLEN_P(argument), &ce TSRMLS_CC) == FAILURE) {
|
||||
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(argument));
|
||||
if (!EG(exception)) {
|
||||
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(argument));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1027,17 +1027,21 @@ static void _reflection_export(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *c
|
|||
|
||||
result = zend_call_function(&fci, &fcc TSRMLS_CC);
|
||||
|
||||
RETURN_ON_EXCEPTION
|
||||
|
||||
if (result == FAILURE) {
|
||||
zval_dtor(&reflector);
|
||||
_DO_THROW("Could not create reflector");
|
||||
}
|
||||
|
||||
if (retval_ptr) {
|
||||
zval_ptr_dtor(&retval_ptr);
|
||||
}
|
||||
|
||||
RETURN_ON_EXCEPTION
|
||||
|
||||
if (EG(exception)) {
|
||||
zval_dtor(&reflector);
|
||||
return;
|
||||
}
|
||||
if (result == FAILURE || EG(exception)) {
|
||||
zval_dtor(&reflector);
|
||||
_DO_THROW("Could not create reflector");
|
||||
}
|
||||
|
||||
/* Call static reflection::export */
|
||||
ZVAL_BOOL(&output, return_output);
|
||||
params[0] = &reflector_ptr;
|
||||
|
@ -2263,7 +2267,9 @@ static void reflection_class_object_ctor(INTERNAL_FUNCTION_PARAMETERS, int is_ob
|
|||
} else {
|
||||
convert_to_string_ex(&argument);
|
||||
if (zend_lookup_class(Z_STRVAL_P(argument), Z_STRLEN_P(argument), &ce TSRMLS_CC) == FAILURE) {
|
||||
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(argument));
|
||||
if (!EG(exception)) {
|
||||
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", Z_STRVAL_P(argument));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue