-
Notifications
You must be signed in to change notification settings - Fork 16
Support PSR-17 StreamFactoryInterface #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Build is failing because PHP 5.4 is still supported (unsupported |
I think you are right. The whole PHP-HTTP ecosystem is moving around the v2 so its time to deprecate some old PHP versions. Regarding that update, maybe supporting both HttplugFactory and PSR17Factory is not relevant anymore... PSR17 will be the de facto standard. |
not just "de facto" but "officially accepted" standard :-) afaik @Nyholm did a lot of thinking to have a clean upgrade path for the PSR, maybe he can chime in on this? |
16de5ac
to
a282d11
Compare
Yes, let's wait for his comment(s). |
@Nyholm do you have input on this one? |
ping @Nyholm |
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.
Im sorry for the awful delay.
This looks super solid.
src/CachePlugin.php
Outdated
{ | ||
if (!($streamFactory instanceof StreamFactory) && !($streamFactory instanceof StreamFactoryInterface)) { | ||
throw new \LogicException(\sprintf('StreamFactory must be an instance of %s or %s', StreamFactory::class, StreamFactoryInterface::class)); |
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.
Why don't we throw a TypeError
here?
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.
oh good idea. @deguif could you change this to throw a TypeError instead?
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.
Yes I can change this ;)
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.
And ✅
a282d11
to
f2b89be
Compare
src/CachePlugin.php
Outdated
{ | ||
if (!($streamFactory instanceof StreamFactory) && !($streamFactory instanceof StreamFactoryInterface)) { | ||
throw new \TypeError(\sprintf('StreamFactory must be an instance of %s or %s.', StreamFactory::class, StreamFactoryInterface::class)); |
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.
Should be:
throw new \TypeError(\sprintf('Argument 2 passed to %s::__construct() must be of type %s|%s, %s given.', self::class, StreamFactory::class, StreamFactoryInterface::class, gettype($streamFactory)));
To match the message given by PHP 8 for type errors with union types.
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.
Even better: \is_object($streamFactory) ? \get_class($streamFactory) : \gettype($streamFactory)
for the given type ;)
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.
Ah, yes. 👍
f2b89be
to
0a2115c
Compare
0a2115c
to
a4e5617
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.
thanks a lot!
@@ -33,7 +34,7 @@ final class CachePlugin implements Plugin | |||
private $pool; | |||
|
|||
/** | |||
* @var StreamFactory | |||
* @var StreamFactory|StreamFactoryInterface |
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.
once php-http/message-factory#38 is released, we can raise our version constraint to get that version and only use the psr interface from then on.
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.
Yes, and let ping me at this moment, I will be glad to do the PR ;)
What's in this PR?
Support for PSR-17
StreamFactoryInterface