Re: echo new SplFileObject(__FILE__);
| From: | hakre | Date: | Wed, 30 Jan 2013 16:17:21 +0000 |
| Subject: | Re: echo new SplFileObject(__FILE__); | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-65511@lists.php.net to get a copy of this message | ||
> Von: Paul Dragoonis <dragoonis@gmail.com>
>Gesendet: 16:54 Mittwoch, 30.Januar 2013
>
>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.
Would this mean that changing it in PHP 5.5 (or 5.6) would not be an option because of the rules of
backwards compatibility?
>
>I'd try to avoid this casting magic and stick with ->current() if you actually mean it.
So do I. I mean, I often foreach anyway.
-- hakre