]> granicus.if.org Git - php/commitdiff
Fixed bug #60357 (__toString() method triggers E_NOTICE "Array to string conversion")
authorXinchen Hui <laruence@php.net>
Tue, 22 Nov 2011 10:11:06 +0000 (10:11 +0000)
committerXinchen Hui <laruence@php.net>
Tue, 22 Nov 2011 10:11:06 +0000 (10:11 +0000)
NEWS
ext/reflection/php_reflection.c
ext/reflection/tests/bug60357.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index a472c323bbba800d7145b1a7464ab3517b0e07e3..dd331e9b9b03fdc11d402e9ec8fef0c58a1fd022 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index a6339fa56f8396654a8fefb17da178cff774be11..1e0386a601c64073ef6c4bcd4349372d3504c904 100644 (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));
diff --git a/ext/reflection/tests/bug60357.phpt b/ext/reflection/tests/bug60357.phpt
new file mode 100644 (file)
index 0000000..a5ddd40
--- /dev/null
@@ -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 ]