Re: [RFC] Scalar Type Hinting With Casts (re-opening)

From: Date: Mon, 14 Jul 2014 17:09:22 +0000
Subject: Re: [RFC] Scalar Type Hinting With Casts (re-opening)
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-75491@lists.php.net to get a copy of this message
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’d expect (and I think most people new to PHP would expect) what 3/2 would be in normal maths, i.e. the fractional value 0.666…. Actually, this makes a good case for return type hinting, as you could ensure you’d get an integer result here. (But that is another matter.) -- Andrea Faulds http://ajf.me/

« previous php.internals (#75491) next »