Re: [RFC] Return type-hint
| From: | Ferenc Kovacs | Date: | Fri, 29 Apr 2011 07:37:51 +0000 |
| Subject: | Re: [RFC] Return type-hint | ||
| References: | 1 2 3 4 5 6 7 8 9 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52081@lists.php.net to get a copy of this message | ||
On Fri, Apr 29, 2011 at 7:04 AM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> Hi!
>
>
> yeah, but usually you return null/false in case of error when you write
>> procedural code.
>>
>
> Nope. I use it all the time when writing OO code and when "nothing" or "no
> object" or "can't do this" is a valid answer for a function to return.
>
>
> but since we wouldn't support the return typehint for scalars, maybe we
>> could assume that the only sane people who would use this feature would
>> also do the error handling will through Exceptions (@throws :P).
>>
>
> Exceptions are for _exceptional_ situations. If you query a DB for an
> object and there's no object like this, you don't want an exception if this
> situation is normal and handled in your code - you want a null or false or
> something like that. Exception is for situations that you code can not
> foresee or handle, they are not for regular data flow control.
>
>
some agree, some disagree with that.
http://barelyenough.org/blog/2007/11/when-to-use-exceptions/
Tyrael