Re: [PATCH] Notice on array to string convertion
| From: | Patrick ALLAERT | Date: | Thu, 02 Jun 2011 16:19:50 +0000 |
| Subject: | Re: [PATCH] Notice on array to string convertion | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52794@lists.php.net to get a copy of this message | ||
2011/6/2 Reindl Harald <h.reindl@thelounge.net>:
> Am 02.06.2011 16:24, schrieb Marcel Esser:
>> I am not convinced that making this an error is a good idea.
>>
>> If I receive a $_GET/$_POST value that I expect to be a string value, but I actually
>> received an array, this would
>> mean I need to now explicitly check for it, since it will stop the runtime otherwise.
>
> so fix your code jesus christ
I am not sure he has anything to do with that.
> what do you do if you expect a string and get an array?
> nothing useful!
That is not the point, when you cast an array as a string, you are
supposed to receive "Array" whether you like this or not. For now,
this is just a silent operation which I want to make some noise,
accordingly to the philosophy of PHP.
Most of the time, this is a sign of error, obviously, there are some
very few case where you want that conversion, may I point you to the
PHP unit tests (*.phpt files)?
> you can get this only by define name="multi[]" in a form
> and so if you define there post an array you should not
> expect a string in the code, this is exactly a sample where
> a fatal error should be thworn to force peopole not writing
> crappy code which floods my error-logs if anybody out there
> means to put a self-written script on our servers with
> E_ALL | E_STRICT which are running in this mode since years
>
> would this be an error the blind developers would see them
> even on their development-machines
I'm all for errors being reported as it should be, the key here is
that casting an array to string should remain a permitted operation.
The same is true when using a variable which is not declared.
If you don't agree with that, you don't agree with the whole principle
of PHP's notices which is of course debatable.
May I invite you to discuss the fact that PHP's notice are
inappropriate in software development in a specific thread? I am sure
some people could help you in this task or even to create an RFC about
how to change that in the future of PHP.
Regards
Patrick