Neil Drumm wrote:
Chris Johnson wrote:
Interesting idea. So I rewrote object2array() and better() like this:
function object2array($object) { return get_object_vars($object); }
function better($object) { return (array) $object; }
Why do we even need these one-line functions? Can't the calling code just do the casting?
-Neil
Yes, the calling code can be changed. It's just a much bigger patch, and documentation change. I'd like to see this change go through a beta release as-is to make sure there aren't any odd cases where it doesn't work. My test site works perfectly, but this seems like one of those places one would most likely trip over a bug or unexpected intended behavior in PHP itself. Undoing a few lines of code in common.inc is a lot easier than removing all the changes to the hundreds of calls throughout core and contrib. If it works fine in wide usage, I'll change all the core and contrib code to just use casting and suggest the documentation changes, too. ..chrisxj