On 10 March 2017 10:57:42 GMT+00:00, Andrey Andreev <n...@devilix.net> wrote: >I'm not really interested in making "strict mode" less strict - it's >already opt-in and non-enforceable. >I want ways to write stonger-type code in "non-strict mode", because >the fact that "strict mode" is non-enforceable means I can never rely >on it.
This is a common misconception - you can absolutely rely on strict mode enforcing your contract. Basically all that happens in non-strict mode is that if the caller writes: foo($value); The compiler automatically changes that to: foo((string)$value); (That's not literally how it's implemented, but it's the effect you get.) As the receiver of that parameter, you can't tell, and don't care, if it was the human writing the code who added the cast, or the compiler adding it for them. You can't detect someone blindly writing "(string)" everywhere any more than you can detect whether they are running in strict mode. Nor can you know if they took it straight from unfiltered user input, or copy-pasted a literal string to 10 different files, or a hundred other things you'd really like them not to do. All you know is, you asked for a string, and you got one. Regards, -- Rowan Collins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php