Re: echo new SplFileObject(__FILE__);
| From: | Charles PHP | Date: | Tue, 29 Jan 2013 23:00:27 +0000 |
| Subject: | Re: echo new SplFileObject(__FILE__); | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-65447@lists.php.net to get a copy of this message | ||
This feels like a bug to me. Why would SplFileObject::__toString return the
current line while SplFileInfo::__toString returns file path?
On Tue, Jan 29, 2013 at 5:51 PM, Ferenc Kovacs <tyra3l@gmail.com> wrote:
> On Tue, Jan 29, 2013 at 11:29 PM, hakre <hanskrentel@yahoo.de> wrote:
>
> > Can somebody shed some light why:
> >
> > <?php
> >
> > echo new SplFileObject(__FILE__);
> >
> > returns the first line of the file (in that case
> >
<?php)?
> >
> > SplFileInfo has the path and SplFileObject extends from it but it will
> > return the current line. I do not really understand why and I tend to
> > report this as a bug but I'm not sure.
> >
> >
> > --hakre
> >
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> SplFileObject->__toString() is an alias for current() which will return the
> current line of file
> http://lxr.php.net/xref/PHP_5_3/ext/spl/spl_directory.c#2954
> http://www.php.net/manual/en/splfileobject.tostring.php
> it seems that the class synopsis at
> http://www.php.net/manual/en/class.splfileobject.php is missing
> this
> method
> so it is easy to think that it isn't provided by the SplFileObject so the
> parent't method will be used, which isn't the case.
>
> --
> Ferenc Kovács
> @Tyr43l - http://tyrael.hu
>