summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-04-02 14:19:52 +0300
committerDmitry Stogov <dmitry@zend.com>2015-04-02 14:19:52 +0300
commitad863c1740fb5719efa3a3fb3a796afd40b1a50f (patch)
treedebb56987aff5260bea4fd2a56b75c554e0b594b
parentbf259db82e000fcf05135245551348b5dc5cb489 (diff)
downloadphp-git-ad863c1740fb5719efa3a3fb3a796afd40b1a50f.tar.gz
Convert fatal errors into EngineException
-rw-r--r--Zend/zend_API.c4
-rw-r--r--Zend/zend_exceptions.c15
-rw-r--r--Zend/zend_interfaces.c3
-rw-r--r--Zend/zend_objects.c2
-rw-r--r--ext/standard/tests/general_functions/010.phpt11
5 files changed, 23 insertions, 12 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index bc7c0ffc46..310d9fb8e1 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -3119,7 +3119,7 @@ get_function_via_handler:
verb = "should not";
} else {
/* An internal function assumes $this is present and won't check that. So PHP would crash by allowing the call. */
- severity = E_ERROR; //TODO: add E_EXCEPTION???
+ severity = E_EXCEPTION | E_ERROR;
verb = "cannot";
}
if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) {
@@ -3127,7 +3127,7 @@ get_function_via_handler:
}
if (error) {
zend_spprintf(error, 0, "non-static method %s::%s() %s be called statically", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val, verb);
- if (severity == E_ERROR) {
+ if (severity != E_DEPRECATED) {
retval = 0;
}
} else if (retval) {
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index a139c62322..6eccc89723 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -48,7 +48,7 @@ void zend_exception_set_previous(zend_object *exception, zend_object *add_previo
}
ZVAL_OBJ(&tmp, add_previous);
if (!instanceof_function(Z_OBJCE(tmp), base_exception_ce)) {
- zend_error_noreturn(E_ERROR, "Cannot set non exception as previous exception");
+ zend_error_noreturn(E_CORE_ERROR, "Cannot set non exception as previous exception");
return;
}
ZVAL_OBJ(&zv, exception);
@@ -116,7 +116,7 @@ ZEND_API void zend_throw_exception_internal(zval *exception) /* {{{ */
if(EG(exception)) {
zend_exception_error(EG(exception), E_ERROR);
}
- zend_error_noreturn(E_ERROR, "Exception thrown without a stack frame");
+ zend_error_noreturn(E_CORE_ERROR, "Exception thrown without a stack frame");
}
if (zend_throw_exception_hook) {
@@ -215,7 +215,8 @@ ZEND_METHOD(exception, __construct)
int argc = ZEND_NUM_ARGS();
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|SlO!", &message, &code, &previous, base_exception_ce) == FAILURE) {
- zend_error_noreturn(E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])");
+ zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]])");
+ return;
}
object = getThis();
@@ -245,7 +246,8 @@ ZEND_METHOD(error_exception, __construct)
size_t message_len, filename_len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc, "|sllslO!", &message, &message_len, &code, &severity, &filename, &filename_len, &lineno, &previous, base_exception_ce) == FAILURE) {
- zend_error_noreturn(E_ERROR, "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])");
+ zend_error(E_EXCEPTION | E_ERROR, "Wrong parameters for ErrorException([string $exception [, long $code, [ long $severity, [ string $filename, [ long $lineno [, Exception $previous = NULL]]]]]])");
+ return;
}
object = getThis();
@@ -972,13 +974,14 @@ ZEND_API void zend_throw_exception_object(zval *exception) /* {{{ */
zend_class_entry *exception_ce;
if (exception == NULL || Z_TYPE_P(exception) != IS_OBJECT) {
- zend_error_noreturn(E_ERROR, "Need to supply an object when throwing an exception");
+ zend_error_noreturn(E_CORE_ERROR, "Need to supply an object when throwing an exception");
}
exception_ce = Z_OBJCE_P(exception);
if (!exception_ce || !instanceof_function(exception_ce, base_exception_ce)) {
- zend_error_noreturn(E_ERROR, "Exceptions must be valid objects derived from the Exception base class");
+ zend_error(E_EXCEPTION | E_ERROR, "Exceptions must be valid objects derived from the Exception base class");
+ return;
}
zend_throw_exception_internal(exception);
}
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index 93c0209a96..5cb7024706 100644
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -259,7 +259,8 @@ static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zva
zend_user_iterator *iterator;
if (by_ref) {
- zend_error_noreturn(E_ERROR, "An iterator cannot be used with foreach by reference");
+ zend_error(E_EXCEPTION | E_ERROR, "An iterator cannot be used with foreach by reference");
+ return NULL;
}
iterator = emalloc(sizeof(zend_user_iterator));
diff --git a/Zend/zend_objects.c b/Zend/zend_objects.c
index ffdd9df573..eda8f0c956 100644
--- a/Zend/zend_objects.c
+++ b/Zend/zend_objects.c
@@ -117,7 +117,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object)
old_exception = NULL;
if (EG(exception)) {
if (EG(exception) == object) {
- zend_error_noreturn(E_ERROR, "Attempt to destruct pending exception");
+ zend_error_noreturn(E_CORE_ERROR, "Attempt to destruct pending exception");
} else {
old_exception = EG(exception);
EG(exception) = NULL;
diff --git a/ext/standard/tests/general_functions/010.phpt b/ext/standard/tests/general_functions/010.phpt
index f576c7e8d7..a4802b0808 100644
--- a/ext/standard/tests/general_functions/010.phpt
+++ b/ext/standard/tests/general_functions/010.phpt
@@ -11,9 +11,16 @@ class test {
}
}
-var_dump(register_shutdown_function(array("test","__call")));
+try {
+ var_dump(register_shutdown_function(array("test","__call")));
+} catch (EngineException $e) {
+ echo "\nException: " . $e->getMessage() . "\n";
+}
echo "Done\n";
?>
---EXPECTF--
+--EXPECTF--
+Exception: Non-static method test::__call() cannot be called statically
+Done
+
Fatal error: Non-static method test::__call() cannot be called statically in %s on line %d