Re: echo new SplFileObject(__FILE__);

From: Date: Wed, 30 Jan 2013 15:57:23 +0000
Subject: Re: echo new SplFileObject(__FILE__);
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-65509@lists.php.net to get a copy of this message
On Wed, Jan 30, 2013 at 4:44 PM, hakre <hanskrentel@yahoo.de> wrote: > > > ----- Ursprüngliche Message ----- > > > Von: Stas Malyshev <smalyshev@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. > > I would guess the idea was that SplFileObject already implements the Iterator interfaces and iterating the object would give you the lines of the file, so echo $object should echo the current line. But this isn't that strong of an argument, and I think that following what SplFileInfo does would be more sensible (echoing the filename), but I'm not sure change would worth breaking BC for. -- Ferenc Kovács @Tyr43l - http://tyrael.hu

« previous php.internals (#65509) next »