Re: Missing __toString() part

From: Date: Sun, 04 Jun 2006 03:20:11 +0000
Subject: Re: Missing __toString() part
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-23905@lists.php.net to get a copy of this message
Marcus Boerger wrote: > Hello guys, > > the attached patch closes one more __toString() part. It allows > to use objects that define __toString as indexes to arrays. What do > you guys think about this, should we add it or stay with the old > behavior that didn't allow objects as indexes at all. I prefer to require an explicit (string) cast to use an object as an array index. The "can't use objects as array index" has actually helped me catch many subtle bugs that were slipping through in earlier PHP versions, I very much like this fatal error. I don't see this: $a = $b[$c]; being much clearer to understand than: $a = $b[$c]; or better yet $a = $b[$c->person()]; which is by far the clearest and easiest to debug (and results in a fatal error if $c is the wrong kind of object or the wrong string - even better for debugging) Thanks, Greg

« previous php.internals (#23905) next »