Re: [RFC] Scalar Type Hints v0.2
| From: | Thomas Nunninger | Date: | Wed, 14 Jan 2015 10:08:43 +0000 |
| Subject: | Re: [RFC] Scalar Type Hints v0.2 | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-80452@lists.php.net to get a copy of this message | ||
Hi,
On 01/14/2015 10:32 AM, Andrea Faulds wrote:
Hi Leigh,What happens with that code: ---------------- $i = 1; $a = myFunc( $i ); declare(strict_typehints=TRUE); function myFunc( float $f ) {On 14 Jan 2015, at 09:17, Leigh <leight@gmail.com> wrote: I really don't like this behaviour being changed at the call site. If I design a function that I _know_ should only take a string, then I want it to be an error if the user supplies anything else, so that they know they messed up.I don’t like the idea of being forced to use strict (or weak) type checking because the API author decided as much.
return otherFunc( $f );} function otherFunc( float $f ) {
...} ---------------- As author of strict code I need to replace
return otherFunc( $f );by
return otherFunc( (float) $f );I'm not sure - if this is what a strict coder wants and - if you find an acceptable way to test your strict code if it works with non-strict code. Regards Thomas