Re: [RFC] Strict type hints (parameter and return value)
| From: | Sam Barrow | Date: | Thu, 17 Apr 2008 15:59:56 +0000 |
| Subject: | Re: [RFC] Strict type hints (parameter and return value) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-37078@lists.php.net to get a copy of this message | ||
On Thu, 2008-04-17 at 17:29 +0200, Paul Biggar wrote:
> On Thu, Apr 17, 2008 at 5:24 PM, Felipe Pena <felipensp@gmail.com> wrote:
> > > Thanks for making the change. This is much more consistent. It remains
> > > that there is no 'scalar' or 'numeric' hint. Are you planning on
> > > including them?
> >
> > No, i'm not planning to do that.
>
> Ah, I should have been more specific. I meant to ask for those
> changes. Can I ask why not?
I think scalar is very important. For any function where you are
interacting with the database values or echoing output, scalar is very
useful.
> > > I also wonder about allowing NULL for an 'array' type hint. Is this
> > > acceptable? The patch seems to indicate it is. If so, why is this
> > > allowed?
> >
> > I added yesterday an information about that in the doc:
> >
> > "Functions are now able to force parameters to be objects (by specifying
> > the name of the class in the function prototype) or arrays (since PHP
> > 5.1). However, if NULL is used as the default parameter value, it will
> > be allowed as an argument for any later call."
>
> That doesnt explain why its allowed. Can you elaborate?
>
The way i do it is to only allow null if null is the default. This way,
people cannot skip parameters using null unless specifically allowed to
in the function declaration.
>
> Thanks,
> Paul
>
>
>
> > > On Thu, Apr 17, 2008 at 4:42 PM, Felipe Pena <felipensp@gmail.com> wrote:
> > > > Hi.
> > > >
> > > > Well, thinking better about the behavior of type hinting, i decided to
> > > > change the proposal for strict type. I.e. don't accept numeric string
> > > > as an intenger, etc.
> > > >
> > > > If anyone wants use type hinting, i believe that it should be strict.
> > > > Otherwise, it makes more sense to not use it.
> > > >
> > > > Examples, patches and tests:
> > > > http://wiki.php.net/rfc/typehint
> > > >
> > > >
> > > > --
> > > > Regards,
> > > > Felipe Pena.
> > > >
> > > > --
> > > > PHP Internals - PHP Runtime Development Mailing List
> > > > To unsubscribe, visit:
> > > > http://www.php.net/unsub.php
> > > >
> > > >
> > >
> > >
> > >
> > --
> > Regards,
> > Felipe Pena.
> >
> >
>
>
>
> --
> Paul Biggar
> paul.biggar@gmail.com
>