Fixed bug #60357 (__toString() method triggers E_NOTICE "Array to string conversion")

This commit is contained in:
Xinchen Hui 2011-11-22 10:11:06 +00:00
parent ecc6c335c5
commit b548293b99
3 changed files with 16 additions and 0 deletions

4
NEWS
View File

@ -60,6 +60,10 @@ PHP NEWS
- BCmath:
. Fixed bug #60377 (bcscale related crashes on 64bits platforms) (shm)
- Reflection:
. Fixed bug #60357 (__toString() method triggers E_NOTICE "Array to string
conversion"). (Laruence)
11 Nov 2011, PHP 5.4.0 RC1
- General improvements:
. Changed silent conversion of array to string to produce a notice. (Patrick)

View File

@ -746,6 +746,8 @@ static void _parameter_string(string *str, zend_function *fptr, struct _zend_arg
string_write(str, "...", sizeof("...")-1);
}
string_write(str, "'", sizeof("'")-1);
} else if (Z_TYPE_P(zv) == IS_ARRAY) {
string_write(str, "Array", sizeof("Array")-1);
} else {
zend_make_printable_zval(zv, &zv_copy, &use_copy);
string_write(str, Z_STRVAL(zv_copy), Z_STRLEN(zv_copy));

View File

@ -0,0 +1,10 @@
--TEST--
Bug #60357 (__toString() method triggers E_NOTICE "Array to string conversion")
--FILE--
<?php
function foo( array $x = array( 'a', 'b' ) ) {}
$r = new ReflectionParameter( 'foo', 0 );
echo $r->__toString();
?>
--EXPECTF--
Parameter #0 [ <optional> array $x = Array ]