]> 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)
ext/reflection/php_reflection.c
ext/reflection/tests/bug60357.phpt [new file with mode: 0644]

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 ]