-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Revert #177 #182
Revert #177 #182
Conversation
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.
imho this is overthinking it.
if you really think its better to have it this way, i suggest to explain why the behaviour is this way in the StreamTest::testBuildFromString.
and to clarify the behaviour in the documentation.
the readme example on $psr17Factory->createStream should have the rewind and a note why you need to rewind.
and the phpdoc for Stream::create and for the psr17 factory createStream methods should also have a warning that you need to rewind the stream you just created if you want it to work.
I agree with you that your way would make more sense. In #180 we discussed that this change would be a BC break because there might be application that will break if this was released. What is your opinion on the BC issue? |
thats what i meant with "overthinking" it. i consider rewinding the stream a DX fix that can have side effects if somebody relied on undocumented behaviour. but i can't really claim it is a bug fix either, as the behaviour is unspecified in the spec, so it is not strictly a bug. if it was a straight up bug, i think BC considerations would not make sense, but with this situation it is really an edge case. maybe we should simply release a new major if there is too much worry about side effects? |
in the end its your call. if i was the author of the library, i would consider it a fix and accept the risk that it could be a problem in an edge case... but it your library, so do what you think is right ;-) |
Like I said in the previous discussion: I do consider this a semver BC break, but have no real opinion on how strictly we are supposed to be following semver. I am very much of the opinion that not documenting the stream cursor position has been a big miss on the PSR mapping of PHP streams into PSR-7/PSR-17, and maybe when I have the time to do so I will try to reignite the discussion on that in the mailing list again. I wonder if reverting this and then planning for a 2.0 release might be a good plan, where we specifically make the goal of 2.0 to compare with default behaviours of other PSR-7 implementations? #181 comes to mind as another one where the spec may be a slightly ambiguous and following convention might be a good idea. I would just like to see the data that there actually exists consensus amongst implementations :) |
I really do want to avoid a version 2.0 of this library. Could we make sure the (soon to be released) Guzzlehttp/psr7:2.0 is aligned with us instead?
Has this "feature" ever been documented? It sure has not been tested. If it has not been tested or documented, is it really a feature? |
Surely the fact that the PR changes a test, means it is tested? 😉 But yeah, as said in the original discussion, hard to say. Honestly this library does not make any other promises than PSR does. And with that said, PSR makes no promises about the cursor ever (as far as I can recall right now). So in some way, all behaviour around the cursor is undocumented behaviour. And the only way to ensure Stream is ever right is to rewind after the fact, to use Annoylingly enough, projects following pure PSR defined behaviour would never notice this difference. Because they should be using
Have they answered the cursor question? Has it been documented why certain decisions were reached? I would describe our behaviour to be:
To me it sounds like the alternative is:
It is clear from PSR-7 that Steam object matches closely to the functions around |
We may be overthinking. But not merging this PR might lead to more head aches. I'll marge this and then tell users to never use |
This will revert #177 so we don't introduce new behaviour. This will fix #180.
FYI @Zegnat @dbu. The discussion in #180 stalled a bit. By reverting this we are predictable (but maybe wrong), we are also consistent between creating a stream from string compared to from resource.