> Which of the two below is clearer:
>
>     function CanDrive($age)
>     {
>         if( !is_numeric($age))
>           throw new Error("\$age is not integer (CanDrive())");
>
>       return $age >= 17;
>     }
>
>     function CanDrive(int $age)
>     {
>       return $age >= 17;
>     }

I think we're on the same page here that the 2nd one looks better, which
is the point of the RFC.

But the way I see it, the RFC should focus pretty much exclusively on
sanitizing information coming from the 'outer code' and into the 'inner
code', as opposed to enforcing strict typing within the inner code (a
function that unless I'm missing something it does not attempt to do,
thankfully).

The point of the RFC is that as the author of the API, you wouldn't have
to worry about input sanity, while still allowing the dynamic nature of
PHP - AKA type juggling - so that users who call that API don't need to be
bothered with the mechanics of their types either.

Zeev

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

Reply via email to