E_NOTICE. The current conversion is so completely useless, that whenever it 
happens, it is almost certainly an error. Any implicit conversion here would 
perpetuate problems in code that was probably wrong in the first place.

John Crenshaw
Priacta, Inc.
 
-----Original Message-----
From: John LeSueur [mailto:john.lesu...@gmail.com] 
Sent: Thursday, June 02, 2011 9:04 AM
To: Reindl Harald
Cc: internals@lists.php.net
Subject: Re: [PHP-DEV] [PATCH] Notice on array to string convertion

On Thu, Jun 2, 2011 at 6:24 AM, Reindl Harald <h.rei...@thelounge.net>wrote:

>
>
> Am 02.06.2011 13:54, schrieb Hannes Magnusson:
> > On Thu, Jun 2, 2011 at 12:11, Patrick ALLAERT <patrickalla...@php.net>
> wrote:
> >> Hi,
> >>
> >> I would like to introduce an E_NOTICE when an array is silently
> >> converted to a string.
> >> This isn't very useful as it constantly produces the following string:
> >> "Array" and in most of the case, this is a sign of an error.
> >
> > How about making it useful rather then just throwing an notice?
> > Recursive implode maybe? Or json/php serialized? :)
>
> it is braindead to expect such bad magic in a programing-language
> normally this convertion happens when the programmer had made
> something wrong (forgot serialize as example), now you are coming
> and think JSON is cool and convert silently, so what will unserialize()
> do with this crap after reading the data from mysql?
>
> this conversion should never happen and throw a fatal error since this
> action is destructive to data and never useful nor will warnings/notices
> helps in the real world
>
>
>
First, I agree that converting to json/imploding would be a bad idea.
There's
no guarantee that the developer wanted to use the array in that way, or even
that he wanted to use the array at all instead of some element inside the
array.
Instead, this is an indication that you're probably doing something wrong.

However, fatal errors should be reserved for when the engine cannot
continue.
Disallowing the ability to catch and handle an error, even if it is just to
display
a prettier notification, is something to be avoided.

P.S. your use of the words braindead/crap hurts your argument. :)

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to