3 ms·
I’m not sure about the properties but on method parameters at least, they will cast, e.g. if you give foo(int $bar) the string “10” it will be cast to 10. It wi
by donatj 7y ago
I’m not sure about the properties but on method parameters at least, they will cast, e.g. if you give foo(int $bar) the string “10” it will be cast to 10. It will runtime error only if it cannot “safely” cast the value.
I’m not 100% that it is a wonderful behavior, and a lot of people turn it off (which can be done on a per file declaration of strict) but for us it’s genuinely helped eliminate an entire class of error where a runaway type error would result in a really whacky value way down the line, even occasionally ending up with that stored in the database for some calculation.
The kind of thing we still end up with in JavaScript to this day.