Hi Andrea,

On 01/14/2015 11:20 AM, Andrea Faulds wrote:
Hi Thomas,

On 14 Jan 2015, at 10:08, Thomas Nunninger <tho...@nunninger.info> wrote:

----------------
$i = 1;
$a = myFunc( $i );

declare(strict_typehints=TRUE);

function myFunc( float $f )
{
    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.

I don’t understand, I’m sorry.

If you are using declare(strict_typehints=TRUE); then all calls in a file are 
“strict”. If you are not, all calls in a file are “weak”.


Sorry, if my mail was not clear. My point was: If I write a library in strict mode and someone else is using it from his non-strict mode, he can pass an integer to myFunc() without an error. If I use this integer in my library and hand it over to otherFunc() (in my library) this will fail as integer is not accepted for float.

Or did I misunderstood the RFC and there is a casting of the integer to a float when calling myFunc()?

Regards

Thomas




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

Reply via email to