Now that I have a (more or less) functioning IO\Resource class, it's time to refactor IO\Stream to make use of it. I haven't quite figured out how this is going to go yet, but the general idea is that the interface for IO\Stream will stay largely the same. You still instantiate it exactly the same way and everything, but internally it will be using an IO\Resource in place of the usual stream resource object. The connection will lazy load by default and only connect when $sr->getResource() is called. If the end-user wants to make use of the IO\Resource class, they can instantiate a resource object and pass it to a new method on the stream class... it will likely be something like IO\Stream::open($resource)
[x] Refactor IO\Stream to accept a IO\Resource in its constructor
[x] From now on to open a stream the old way you will do IO\Stream::open($uri, $mode, $context)
[x] Add __invoke() magic method to IO\Resource so that you can pass it to fopen like this fopen($this->resource()) from within the IO\Stream class
Actually I think it probably makes more sense to accept a Resource class in the constructor and provide a Stream::open() method that accepts all the individual params...
Now that I have a (more or less) functioning
IO\Resource
class, it's time to refactorIO\Stream
to make use of it. I haven't quite figured out how this is going to go yet, but the general idea is that the interface forIO\Stream
will stay largely the same. You still instantiate it exactly the same way and everything, but internally it will be using anIO\Resource
in place of the usual stream resource object. The connection will lazy load by default and only connect when$sr->getResource()
is called. If the end-user wants to make use of theIO\Resource
class, they can instantiate a resource object and pass it to a new method on the stream class... it will likely be something likeIO\Stream::open($resource)
IO\Stream
to accept aIO\Resource
in its constructorIO\Stream::open($uri, $mode, $context)
__invoke()
magic method toIO\Resource
so that you can pass it tofopen
like thisfopen($this->resource())
from within theIO\Stream
class