Re: [RFC] Safe Casting Functions
| From: | Marc Bennewitz | Date: | Wed, 22 Oct 2014 19:12:14 +0000 |
| Subject: | Re: [RFC] Safe Casting Functions | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78234@lists.php.net to get a copy of this message | ||
On 22.10.2014 10:37, Bob Weinand wrote:
> I know we have that already discussed a lot now, but I’d like to expose my points on the
> return value here:
>
> I imagine code like (supposing that we ever will have scalar typehints):
>
> function acceptsInt (int $i = null) {
> if ($i === null) {
> $i = 2 /* default value */;
> }
> /* do something with $i */
> }
NULL isn't a pointer for a default value - it's simply a type with no
value - no more - no less.
From your example: why do you accept NULL if you need a integer default
value?
function acceptsInt (int $i = 2) { ...
Marc