Just wanted to remind everyone that option #3 proposed earlier doesn't
include auto-casting when data loss is happening.

That means:

function hintMe(int $number) {
}

hintMe(1);
hintMe("1");
hintMe("1.0");
hintMe(array(1)); - Error or notice, no array -> int conversions
hintMe(1.25); - Error or notice because data is lost.
hintMe("1 abc"); - Error or notice because data is lost.

As I understood the author. So basically we are free of type juggling
in cases when strait forward conversion can be done. like "1" => 1
(int), "20.2" => 20.2 (float).
We receive a warning or  a fatal error when we pass something that
can't be converted straight forward like 1.01 => 1 (int) or "1 abs" =>
1 (int), array(20) => 20.0 (float) and so on. The basic concept as I
understood is: Convert if there is no data loss, else give an error.

So please, stop discussing this, it really annoys to read the same
thing over and over again.

As I said earlier, I'm against strict type checking and there is a
good reason for that: As someone already mentioned, in PHP we are
dealing with strings 90% of the time - GET, POST, data from databases
or any other external source. We get integers and floats only when
stuff is initialized or calculated inside the script. For the external
data we rely on type auto conversion with some additional checks if
needed (I don't think you will ever check the field type when
selecting from database, because I know it's type in schema - you just
use it and rely on automatic conversion).

So really - can we stop arguing, polish the rules and get to the
implementation? :)

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

Reply via email to