Edward Z. Yang wrote: > Jared Williams wrote: >> Don't think that's what he said... More like... >> >> assert(is_object($foo) || is_array($foo)); // ensure strictly conforming >> $json = json_encode($foo); > > Which is, for all intents and purposes, the same thing. (Since you can't > pass json_encode(34) for strict JSON). > > PHP has always erred on the side of "Just do it", and punting the "Do > the right thing" to the consumer. Maybe passing an E_STRICT error would > be the right combo of 1 and 2?
There has to be a way to do a basic type without any sort of error or warning. E_STRICT, even if turned off, is slow. It ends up calling php_verror to construct the entire error string before it checks and sees that it isn't going to be written or displayed anywhere. That'd be another thing to look at eventually, of course, but for now, sprinkling the code with E_STRICT warnings in cases where there is a legitimate case for the usage, is a really bad idea. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php