by Chintagious · 11y ago · 0 comments
"Whether or not the function being called was declared in a file that uses strict or weak type checking is irrelevant. The type checking mode depends on the file where the function is called."
That means that my function can have a parameter defined as an int in its strict file, but if it's called from outside of it, anything can still be passed to that parameter, right?
I'm not sure how I like that. What if you're passing input from class A into class BStrict then using BStrict to call a function in CStrict? BStrict and CStrict are defined as strict, where A is not. Would BStrict then be the one throwing the error because the "caller" is the issue?
From the description it seems that the parameters are effectively ignored in BStrict when A calls it.
Am I missing something or does this sound iffy?
Edit: Link for quote - https://wiki.php.net/rfc/scalar_type_hints_v5#parameter_type...
Not at all. It's "weak" typing, not no typing.
A small set of convertible values can be passed and will be converted to the type you asked for, while other values error as usual.
See the rest of the RFC.