Bug #60357 [Opn->Csd]: __toString() method triggers E_NOTICE "Array to string conversion"
| From: | laruence@php.net | Date: | Tue, 22 Nov 2011 10:11:04 +0000 |
| Subject: | Bug #60357 [Opn->Csd]: __toString() method triggers E_NOTICE "Array to string conversion" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165422@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60357&edit=1
ID: 60357
Updated by: laruence@php.net
Reported by: mapi at pdepend dot org
Summary: __toString() method triggers E_NOTICE "Array to
string conversion"
-Status: Open
+Status: Closed
Type: Bug
Package: Reflection related
Operating System: Ubuntu 11.10
PHP Version: 5.4.0RC1
-Assigned To:
+Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in SVN.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
For Windows:
http://windows.php.net/snapshots/
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2011-11-22 10:10:54] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&revision=319670
Log: Fixed bug #60357 (__toString() method triggers E_NOTICE "Array to string
conversion")
------------------------------------------------------------------------
[2011-11-22 09:27:17] mapi at pdepend dot org
Description:
------------
When a function defines an array parameter with a default value, the __toString()
method of the ReflectionParameter class will trigger an E_NOTICE. See the
attached test script.
Test script:
---------------
<?php
function foo( array $x = array( 'a', 'b' ) ) {}
$r = new ReflectionParameter( 'foo', 0 );
var_dump( $r->__toString() );
Expected result:
----------------
string(44) "Parameter #0 [ <optional> array $x = Array ]"
Actual result:
--------------
PHP Notice: Array to string conversion in /tmp/ref.php on line 5
PHP Stack trace:
PHP 1. {main}() /tmp/ref.php:0
PHP 2. ReflectionParameter->__toString() /tmp/ref.php:5
Notice: Array to string conversion in /tmp/ref.php on line 5
Call Stack:
0.0002 230464 1. {main}() /tmp/ref.php:0
0.0002 231488 2. ReflectionParameter->__toString() /tmp/ref.php:5
string(44) 'Parameter #0 [ <optional> array $x = Array ]'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60357&edit=1