On Mon, Jul 14, 2014 at 06:09:22PM +0100, Andrea Faulds wrote:
> 
> On 14 Jul 2014, at 18:01, Alain Williams <a...@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.)

I trust that you meant 1.5 not 0.666.

I would have expected 1 - since it appears, from the code, that $a should only 
contain integers.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h>

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

Reply via email to