mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Merge branch 'PHP-7.0'
This commit is contained in:
commit
5c707a6cf8
@ -68,7 +68,7 @@ catch (Exception $e) {
|
||||
--EXPECTF--
|
||||
Hello World!
|
||||
===NONE===
|
||||
string(56) "Method NoneTest::__toString() must return a string value"
|
||||
string(%d) "Method NoneTest::__toString() must return a string value"
|
||||
===THROW===
|
||||
|
||||
Fatal error: Method ErrorTest::__toString() must not throw an exception in %sbug26166.php on line %d
|
||||
Fatal error: Method ErrorTest::__toString() must not throw an exception, caught Exception: This is an error! in %sbug26166.php on line %d
|
||||
|
@ -14,7 +14,7 @@ class Bad {
|
||||
$bad = new Bad();
|
||||
echo "$bad";
|
||||
--EXPECTF--
|
||||
Fatal error: Method Bad::__toString() must not throw an exception in %sbug60909_2.php on line 0
|
||||
Fatal error: Method Bad::__toString() must not throw an exception, caught Exception: Oops, I cannot do this in %sbug60909_2.php on line %d
|
||||
|
||||
|
||||
!!!shutdown!!!
|
||||
|
14
Zend/tests/bug70967.phpt
Normal file
14
Zend/tests/bug70967.phpt
Normal file
@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
Bug #70967 (Weird error handling for __toString when Error is thrown)
|
||||
--FILE--
|
||||
<?php
|
||||
class A {
|
||||
public function __toString() {
|
||||
undefined_function();
|
||||
}
|
||||
}
|
||||
|
||||
echo (new A);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Method A::__toString() must not throw an exception, caught Error: Call to undefined function undefined_function() in %sbug70967.php on line %d
|
@ -11,4 +11,4 @@ echo __NAMESPACE__ . "\n";
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
|
||||
Fatal error: Namespace declaration statement has to be the very first statement in the script in %sns_068.php on line %d
|
||||
Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in %sns_068.php on line %d
|
||||
|
@ -11,4 +11,4 @@ echo "ok\n";
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Namespace declaration statement has to be the very first statement in the script in %s on line %d
|
||||
Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in %sns_083.php on line %d
|
||||
|
@ -5843,7 +5843,7 @@ void zend_compile_namespace(zend_ast *ast) /* {{{ */
|
||||
}
|
||||
if (num > 0) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Namespace declaration statement has to be "
|
||||
"the very first statement in the script");
|
||||
"the very first statement or after any declare call in the script");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1526,9 +1526,18 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
|
||||
if (ce->__tostring &&
|
||||
(zend_call_method_with_0_params(readobj, ce, &ce->__tostring, "__tostring", &retval) || EG(exception))) {
|
||||
if (UNEXPECTED(EG(exception) != NULL)) {
|
||||
zval *msg, ex, rv;
|
||||
zval_ptr_dtor(&retval);
|
||||
ZVAL_OBJ(&ex, EG(exception));
|
||||
EG(exception) = NULL;
|
||||
zend_error_noreturn(E_ERROR, "Method %s::__toString() must not throw an exception", ZSTR_VAL(ce->name));
|
||||
msg = zend_read_property(Z_OBJCE(ex), &ex, "message", sizeof("message") - 1, 1, &rv);
|
||||
if (UNEXPECTED(Z_TYPE_P(msg) != IS_STRING)) {
|
||||
ZVAL_EMPTY_STRING(&rv);
|
||||
msg = &rv;
|
||||
}
|
||||
zend_error_noreturn(E_ERROR,
|
||||
"Method %s::__toString() must not throw an exception, caught %s: %s",
|
||||
ZSTR_VAL(ce->name), ZSTR_VAL(Z_OBJCE(ex)->name), Z_STRVAL_P(msg));
|
||||
return FAILURE;
|
||||
}
|
||||
if (EXPECTED(Z_TYPE(retval) == IS_STRING)) {
|
||||
|
@ -19,4 +19,4 @@ test(new CachingIterator($ar, 0));
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
|
||||
Fatal error: Method CachingIterator::__toString() must not throw an exception in %siterator_036.php on line %d
|
||||
Fatal error: Method CachingIterator::__toString() must not throw an exception, caught BadMethodCallException: CachingIterator does not fetch string value (see CachingIterator::__construct) in %siterator_036.php on line %d
|
||||
|
@ -30,4 +30,4 @@ catch(Exception $e)
|
||||
?>
|
||||
====DONE====
|
||||
--EXPECTF--
|
||||
Fatal error: Method Test::__toString() must not throw an exception in %stostring_003.php on line %d
|
||||
Fatal error: Method Test::__toString() must not throw an exception, caught Exception: Damn! in %stostring_003.php on line %d
|
||||
|
Loading…
Reference in New Issue
Block a user