Re: [RFC] Scalar Type Hinting With Casts (re-opening)
| From: | Kristopher | Date: | Mon, 14 Jul 2014 17:19:53 +0000 |
| Subject: | Re: [RFC] Scalar Type Hinting With Casts (re-opening) | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75496@lists.php.net to get a copy of this message | ||
On Mon, Jul 14, 2014 at 1:14 PM, Alain Williams <addw@phcomp.co.uk> wrote:
> On Mon, Jul 14, 2014 at 06:09:22PM +0100, Andrea Faulds wrote:
> >
> > On 14 Jul 2014, at 18:01, Alain Williams <addw@phcomp.co.uk> wrote:
> >
> > > But if you have:
> > >
> > > function foo(int $a) {
> > > ...
> > > $a = 3 / 2;
> > > }
> > >
> > > What do you expect $a to contain ? I would suggest integer 1.
> >
>
I would have expected 1 - since it appears, from the code, that $a should
> only contain integers.
What about the current type hinting we have, then?
function foo(Bar $a) {
$a = 3 / 2;
}
Perfectly OK. Why would we treat scalars any different?