Martin Scotta

On Mon, Jun 6, 2011 at 8:02 PM, Stas Malyshev <smalys...@sugarcrm.com>wrote:

> Hi!
>
>
>  The point, though, is that with such a typehint available, we can reduce
>> boilerplate code like the following:
>>
>
> Sure. How about reducing boilterplate code like this:
>
> if(is_readable($foo)) {
>  $var = file_get_contents($foo);
> } else {
>  throw  InvalidArgumentException();
> }
>

trol?



>
> Why won't we make language construct to do that too? I don't think these
> things belong in the language syntax.
>
>
>
>>     public function addCallback($callback)
>>     {
>>         if (!is_callback($callback)) {
>>             throw new InvalidArgumentException();
>>         }
>>
>> The typehint makes this simpler:
>>
>>     public function addCallback(callback $callback)
>>
>>
> You understand that these two pieces of code are completely different - for
> one, you can't catch failing strict type check upstream of addCallback and
> recover.
>
>
>  which allows us to rely on PHP's native error handling. I, for one,
>> would love to see this.
>>
>
> I wouldn't love it a bit, frankly, as "rely on PHP's native error handling"
> in this context means "bombing out in runtime without any idea what went
> wrong". When you have exception, you could make it print what happened and
> recover, if you want. When you have fatal error, you can't do much at all.
>
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to