Re: What do we need strict scalar type hints for?

From: Date: Mon, 02 Feb 2015 21:41:50 +0000
Subject: Re: What do we need strict scalar type hints for?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-81659@lists.php.net to get a copy of this message
On 02/02/15 21:17, Christoph Becker wrote: >> Instead of multiple strict scalar hints (e.g. function addVat(int|float $amount){...}), I >> would prefer to have "numeric" as strict type: >> > function addVat(numeric $amount){...} > Have you considered > > addVat(-1); Also addVat(1.235); which will be rounded to two decimal places ... silently in this case. A negative amount may be acceptable - credit note - and a one off price may be a finer fraction, but this example shows a couple of other potential errors. As I have already said ... 'strict' may well only be a subset of the error check. A "numeric" type would introduce the problem of scale of number. Something which any of the database extensions already manage on a field by field basis. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

« previous php.internals (#81659) next »