# [php-internals] SplFileObject interface

- Thread: https://externals.io/message/39668
- Original archive: https://news-web.php.net/php.internals/39668
- Started by Giorgio Sironi on 2008-08-05T18:17:06+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #39668 — Giorgio Sironi — 2008-08-05T18:17:06+00:00

URL: https://externals.io/message/39668#39668

Hello everyone, I had a thought about Standard Php Library extension
and his classes and I'd like to expose an idea to see if it can have a
real utility.
Spl has interfaces like Traversable and Iterator that can be
implemented by programmers classes. It also has some class of basic
use like SplFileObject that provide access to the filesystem.
However, unit testing rules, which make it differs from integration
testing, says that testing a class shouldn't affect filesystems,
database and external resources. So what I propose is the creation of
an interface (if it does not already exist in some place) for
SplFileObject: some name like SplFileInterface or iSplFile, using
preferred naming conventions.
That could make a developer be able to do something like:
class Logger
{
    public function __construct(SplFileInterface $file)
   {
    ....
making it easier to mock an object to test the class in isolation but
preserving type verification so that a `NULL` passed to constructor
produces a strict|fatal error.
Note that someone could also implements SplFileInterface with a
process similar to fopen url wrapper, making an external
resource|stream available as a file. I think it will be a clear way to
extend Php object orientation, now that Spl is doing that so much.
I'm looking for some comments and insults on this idea...
Greetings,

-- 
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://www.sourceforge.net/projects/ossigeno

---

## #39670 — Marcus Boerger — 2008-08-05T19:36:25+00:00

URL: https://externals.io/message/39668#39670 · In reply to: #39668

Hello Giorgio,

  you think to complex. Just use user streams and be done.

marcus

Tuesday, August 5, 2008, 8:17:06 PM, you wrote:

> Hello everyone, I had a thought about Standard Php Library extension
> and his classes and I'd like to expose an idea to see if it can have a
> real utility.
> Spl has interfaces like Traversable and Iterator that can be
> implemented by programmers classes. It also has some class of basic
> use like SplFileObject that provide access to the filesystem.
> However, unit testing rules, which make it differs from integration
> testing, says that testing a class shouldn't affect filesystems,
> database and external resources. So what I propose is the creation of
> an interface (if it does not already exist in some place) for
> SplFileObject: some name like SplFileInterface or iSplFile, using
> preferred naming conventions.
> That could make a developer be able to do something like:
> class Logger
> {
>     public function __construct(SplFileInterface $file)
>    {
>     ....
> making it easier to mock an object to test the class in isolation but
> preserving type verification so that a `NULL` passed to constructor
> produces a strict|fatal error.
> Note that someone could also implements SplFileInterface with a
> process similar to fopen url wrapper, making an external
> resource|stream available as a file. I think it will be a clear way to
> extend Php object orientation, now that Spl is doing that so much.
> I'm looking for some comments and insults on this idea...
> Greetings,

> -- 
> Giorgio Sironi
> Piccolo Principe & Ossigeno Scripter
> http://www.sourceforge.net/projects/ossigeno




Best regards,
 Marcus
