php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60357 __toString() method triggers E_NOTICE "Array to string conversion"
Submitted: 2011-11-22 09:27 UTC Modified: 2011-11-22 10:11 UTC
From: mapi at pdepend dot org Assigned: laruence (profile)
Status: Closed Package: Reflection related
PHP Version: 5.4.0RC1 OS: Ubuntu 11.10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mapi at pdepend dot org
New email:
PHP Version: OS:

 

 [2011-11-22 09:27 UTC] 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 ]'

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-22 10:10 UTC] laruence@php.net
Automatic comment from SVN on behalf of laruence
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=319670
Log: Fixed bug #60357 (__toString() method triggers E_NOTICE &quot;Array to string conversion&quot;)
 [2011-11-22 10:11 UTC] laruence@php.net
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.


 [2011-11-22 10:11 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2012-04-18 09:47 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6f5ca6f28054e7a590b1aed9284c4c0e3b38ed30
Log: Fixed bug #60357 (__toString() method triggers E_NOTICE &quot;Array to string conversion&quot;)
 [2012-07-24 23:38 UTC] rasmus@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6f5ca6f28054e7a590b1aed9284c4c0e3b38ed30
Log: Fixed bug #60357 (__toString() method triggers E_NOTICE &quot;Array to string conversion&quot;)
 [2013-11-17 09:35 UTC] laruence@php.net
Automatic comment on behalf of laruence
Revision: http://git.php.net/?p=php-src.git;a=commit;h=6f5ca6f28054e7a590b1aed9284c4c0e3b38ed30
Log: Fixed bug #60357 (__toString() method triggers E_NOTICE &quot;Array to string conversion&quot;)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC