-
-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Allow Streams to be instantiated using GD resources #45
Allow Streams to be instantiated using GD resources #45
Conversation
Ping me for a review when it's ready, @settermjd ! Also, don't forget to use the |
Ready for review. It's not a big patch, and I hope that I understood what you were saying in our previous discussion a little while ago. |
I've been working on a patch to laminas-barcode to create a Stream from a GD resource, but am unable to, as the resource type has to be a stream. However, after talking to mwop, some time ago, he suggested that it'd be fine to patch Diactoros to allow for GD resource types to instantiate streams as well; hence, this patch. Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
As the same code was used in both Stream and StreamFactory, it, to me, made sense to make it reusable by creating a trait to store it and then reusing that code among Stream and StreamFactory.. Seeing that traits are already used in the library, it seemed okay to create another one for use in this context. Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
Thanks to feedback from @samsonasik. Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
e551b1e
to
21e4b65
Compare
I don't expect the visibility to be anything other than private, so setting it appropriately. The previous public visibility was an oversight on my part. Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
After quite a bit of thinking about this, I feel that @samsonasik is correct. It doesn't make sense, to me, to expose an internal detail for no good reason. Given that, this change moves the constant to the trait and sets its visibility to private. Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
Perhaps it's a minor thing, but @localheinz always pushed for readability wherever possible. So, to make the code just that much more readable is worth it; which is the motivation for this, minor, change. Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
Following on from the advice of @lcobucci, this change refactors the StreamTrait functionality into Stream, and removes the trait from both Stream and StreamFactory. On thinking about it, it makes most sense to have this functionality directly in Stream, and not, in effect, duplicated in multiple locations by another form. Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
955b975
to
2a04ab3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a teeny tiny thing! Thanks for your work here... things look much better and the stream class is much more coherent to me 👍
The failing integration test seems to come from |
Signed-off-by: Matthew Setter <matthew@matthewsetter.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
Big thanks to everyone for all your support on this PR. |
Description
I've been working on a patch to laminas-barcode, which requires a Stream to be able to be created from a GD resource. However, the patch fails, as Diactoros only allows resource types to be of type stream. So, this patch expands the list of types allowed to instantiate a Stream to include GD types. I'm submitting this after discussing the idea with @weierophinney some time ago. I hope that I understood what he meant.