laruence                                 Tue, 22 Nov 2011 10:11:06 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=319670

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

Bug: https://bugs.php.net/60357 (Open) __toString() method triggers E_NOTICE 
"Array to string conversion"
      
Changed paths:
    U   php/php-src/branches/PHP_5_4/NEWS
    U   php/php-src/branches/PHP_5_4/ext/reflection/php_reflection.c
    A   php/php-src/branches/PHP_5_4/ext/reflection/tests/bug60357.phpt
    U   php/php-src/trunk/ext/reflection/php_reflection.c
    A   php/php-src/trunk/ext/reflection/tests/bug60357.phpt

Modified: php/php-src/branches/PHP_5_4/NEWS
===================================================================
--- php/php-src/branches/PHP_5_4/NEWS   2011-11-22 09:44:11 UTC (rev 319669)
+++ php/php-src/branches/PHP_5_4/NEWS   2011-11-22 10:11:06 UTC (rev 319670)
@@ -60,6 +60,10 @@
 - 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)

Modified: php/php-src/branches/PHP_5_4/ext/reflection/php_reflection.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/reflection/php_reflection.c        
2011-11-22 09:44:11 UTC (rev 319669)
+++ php/php-src/branches/PHP_5_4/ext/reflection/php_reflection.c        
2011-11-22 10:11:06 UTC (rev 319670)
@@ -746,6 +746,8 @@
                                        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));

Added: php/php-src/branches/PHP_5_4/ext/reflection/tests/bug60357.phpt
===================================================================
--- php/php-src/branches/PHP_5_4/ext/reflection/tests/bug60357.phpt             
                (rev 0)
+++ php/php-src/branches/PHP_5_4/ext/reflection/tests/bug60357.phpt     
2011-11-22 10:11:06 UTC (rev 319670)
@@ -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 ]

Modified: php/php-src/trunk/ext/reflection/php_reflection.c
===================================================================
--- php/php-src/trunk/ext/reflection/php_reflection.c   2011-11-22 09:44:11 UTC 
(rev 319669)
+++ php/php-src/trunk/ext/reflection/php_reflection.c   2011-11-22 10:11:06 UTC 
(rev 319670)
@@ -746,6 +746,8 @@
                                        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));

Added: php/php-src/trunk/ext/reflection/tests/bug60357.phpt
===================================================================
--- php/php-src/trunk/ext/reflection/tests/bug60357.phpt                        
        (rev 0)
+++ php/php-src/trunk/ext/reflection/tests/bug60357.phpt        2011-11-22 
10:11:06 UTC (rev 319670)
@@ -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 ]

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to