To be honest, it looks like __toString() was just added in there for the sake of it without any real thought as to what casting an entier SplFileObject to a string. This to me implies the entire object( i.e: the entire file ) should be returned as a string rather than aliasing it to a method because why would you cast something to a string if you can call ->current() anyway.
Since it's been baked into the object for some time now it can't even be changed now. I'd try to avoid this casting magic and stick with ->current() if you actually mean it. Thanks, Paul Dragoonis. On Wed, Jan 30, 2013 at 3:44 PM, hakre <hanskren...@yahoo.de> wrote: > > > ----- Ursprüngliche Message ----- > > > Von: Stas Malyshev <smalys...@sugarcrm.com> > > Gesendet: 0:00 Mittwoch, 30.Januar 2013 > > Betreff: Re: [PHP-DEV] echo new SplFileObject(__FILE__); > > > > > > __toString is mapped to current() for SplFileObject: > > http://www.php.net/manual/en/splfileobject.current.php > > > > it's not documented for some reason, I think it makes sense to file a > > docs bug on that. > > Thanks for your answer. > > I know that there is code in there that does this and I also got into the > know that it is not properly documented. > > I just write this to clarify that I'm more interested in the why it has > been coded that way. > > It does not make much *sense* to me and I want to learn more. > > Also I don't mean this explicit technically. I could blame the version > control, pick the authors name and email that person; however some time has > passed and more users are using it not only the original author so I ask in > internals first. Just for clarification. > > -- hakre > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >