Re: return false if error
| From: | Pierre Joye | Date: | Thu, 20 Mar 2014 05:43:27 +0000 |
| Subject: | Re: return false if error | ||
| References: | 1 2 3 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969384887@lists.php.net to get a copy of this message | ||
hi,
On Wed, Mar 19, 2014 at 2:03 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
> Hi all,
>
> On Wed, Mar 19, 2014 at 9:52 AM, Hannes Magnusson
> <hannes.magnusson@gmail.com> wrote:
>>
>> I don't know why or when strpos docs got changed to 'mixed', that
>> definitely is not how it was originally:
>> http://www.php.net/manual/en/about.prototypes.php
>>
>> The docs consistently white-lie with "on failure" return value, for
>> example; if you pass 10 arguments to strpos() it will not return
>> false, it will actually return null.
>>
>> This is true for ~98% of the documented functions.
>
>
> We are getting bug reports that function returns NULL for invalid arguments.
There is no bug in this case. Whether it is a good design or not is
disputable but this is how it is now. It is one of the causes of how
PHP manages errors. We had a similar discussion for some of the filter
functions back then, which clearly show why and how it should be done,
given the current situation of the error management in php.
> We might be better to consider change it to FALSE for invalid arguments
> someday. We should be careful for edge case, though.
>
> Documenting almost all return value as mixed would not be a good idea.
Documenting what is actually implemented is what we do or should do.
Cheers,
--
Pierre
@pierrejoye | http://www.libgd.org