mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Convert fatal errors into EngineExceptions
This commit is contained in:
parent
0cad725886
commit
780a8123fe
36
Zend/tests/exception_017.phpt
Normal file
36
Zend/tests/exception_017.phpt
Normal file
@ -0,0 +1,36 @@
|
||||
--TEST--
|
||||
Exceptions on improper usage of $this
|
||||
--FILE--
|
||||
<?php
|
||||
abstract class C {
|
||||
abstract static function foo();
|
||||
}
|
||||
|
||||
function foo(callable $x) {
|
||||
}
|
||||
|
||||
try {
|
||||
C::foo();
|
||||
} catch (EngineException $e) {
|
||||
echo "\nException: " . $e->getMessage() . " in " , $e->getFile() . " on line " . $e->getLine() . "\n";
|
||||
}
|
||||
|
||||
try {
|
||||
foo("C::foo");
|
||||
} catch (EngineException $e) {
|
||||
echo "\n";
|
||||
do {
|
||||
echo "Exception: " . $e->getMessage() . "\n";
|
||||
$e = $e->getPrevious();
|
||||
} while ($e instanceof EngineException);
|
||||
}
|
||||
|
||||
C::foo();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Exception: Cannot call abstract method C::foo() in %sexception_017.php on line %d
|
||||
|
||||
Exception: Argument 1 passed to foo() must be callable, string given, called in %sexception_017.php on line %d
|
||||
Exception: Cannot call abstract method C::foo()
|
||||
|
||||
Fatal error: Cannot call abstract method C::foo() in %sexception_017.php on line %d
|
@ -3092,7 +3092,8 @@ get_function_via_handler:
|
||||
zend_spprintf(error, 0, "cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val);
|
||||
retval = 0;
|
||||
} else {
|
||||
zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val);
|
||||
zend_error(E_EXCEPTION | E_ERROR, "Cannot call abstract method %s::%s()", fcc->calling_scope->name->val, fcc->function_handler->common.function_name->val);
|
||||
return 0;
|
||||
}
|
||||
} else if (!fcc->object && !(fcc->function_handler->common.fn_flags & ZEND_ACC_STATIC)) {
|
||||
int severity;
|
||||
|
@ -774,7 +774,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
|
||||
|
||||
if (func->common.fn_flags & (ZEND_ACC_ABSTRACT|ZEND_ACC_DEPRECATED)) {
|
||||
if (func->common.fn_flags & ZEND_ACC_ABSTRACT) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", func->common.scope->name->val, func->common.function_name->val);
|
||||
zend_error(E_EXCEPTION | E_ERROR, "Cannot call abstract method %s::%s()", func->common.scope->name->val, func->common.function_name->val);
|
||||
return FAILURE;
|
||||
}
|
||||
if (func->common.fn_flags & ZEND_ACC_DEPRECATED) {
|
||||
zend_error(E_DEPRECATED, "Function %s%s%s() is deprecated",
|
||||
@ -919,7 +920,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
|
||||
fci->object->handlers->call_method(func->common.function_name, fci->object, call, fci->retval);
|
||||
EG(current_execute_data) = call->prev_execute_data;
|
||||
} else {
|
||||
zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object");
|
||||
zend_error(E_EXCEPTION | E_ERROR, "Cannot call overloaded function for non-object");
|
||||
}
|
||||
|
||||
zend_vm_stack_free_args(call);
|
||||
|
@ -1545,7 +1545,9 @@ ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) /
|
||||
zend_string *result_str;
|
||||
|
||||
if (op1_len > SIZE_MAX - op2_len) {
|
||||
zend_error_noreturn(E_ERROR, "String size overflow");
|
||||
zend_error(E_EXCEPTION | E_ERROR, "String size overflow");
|
||||
ZVAL_FALSE(result);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == op1 && Z_REFCOUNTED_P(result)) {
|
||||
|
Loading…
Reference in New Issue
Block a user