Bug #64955 [Nab]: "array to string conversion" notice should contain more information
| From: | matteosistisette at gmail dot com | Date: | Sun, 02 Jun 2013 11:49:58 +0000 |
| Subject: | Bug #64955 [Nab]: "array to string conversion" notice should contain more information | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-179284@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64955&edit=1
ID: 64955
User updated by: matteosistisette at gmail dot com
Reported by: matteosistisette at gmail dot com
Summary: "array to string conversion" notice should contain
more information
Status: Not a bug
Type: Bug
Package: *General Issues
PHP Version: 5.4.15
Block user comment: N
Private report: N
New Comment:
Ok. The correct status would be "won't fix", however.
This is a more general issue, actually. It applies to most error messages. Line
number is often not enough, and having to split a line of code into multiple
lines every time you have to debug an error (and then, get them back to one line
so the code doesn't become unreadable) is definitely not viable.
Previous Comments:
------------------------------------------------------------------------
[2013-06-02 01:01:45] rasmus@php.net
That's actually surprisingly difficult to do given how bison (the parser
generator) works. You can do it quite easily in userspace though. Just break up
the line you are having trouble with over multiple lines and the line number will
tell you which variable it is.
------------------------------------------------------------------------
[2013-06-01 15:23:05] matteosistisette at gmail dot com
Description:
------------
The "Array to string conversion" notice message should at the very least include
the name of the array variable that is being converted to string.
A line of code may contain a lot of variables, so figuring out which one is the
unexpected array can be a pain in the ass.
Even the backtrace won't contain enough information since it only gives the line
but not the position within the line.
Test script:
---------------
$string1="foo";
$string2="bar";
$string3=array("Whoops, this is an array");
$string4="bla bla";
echo $string1.$string2.$string3.$string4.
Expected result:
----------------
PHP NOTICE at /path/to/file.php (6): Array to string conversion for variable
'string3'
Actual result:
--------------
PHP NOTICE at /path/to/file.php (6): Array to string conversion
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64955&edit=1