-
-
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
creating a stream from string has unexpected behaviour #177
Conversation
public function testBuildFromString() | ||
{ | ||
$stream = Stream::create('data'); | ||
$this->assertEquals('data', $stream->getContents()); |
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.
RE the discussion in #176, i find it highly unexpected that this does not work.
Thank you. See #176 for discussion. |
thanks! |
@Nyholm with this merged, should the next release be a major version bump per semver? Or do you want to run this as a bug fix only? It has the potential to break people’s implementations if they were building on top of what was previously a stable API from this library. |
the only scenario for this to fail is when you create a stream with a non-empty string and rely on the stream being empty because it is not rewinded. is there any use case where this could matter? maybe theoretically if you create the stream with a string but then want to append to the stream you now overwrite the string? no idea what people do and if this could happen, but maybe it can? |
I think the same principal should apply. You should never assume where the read pointer is. That is not part of any BC promise.
That is true, but I am arguing that this never was a part of the API. The correct way is to always place your pointer after you read/write from a stream. But we could maybe be more explicit about this by releasing a minor version instead and with a clear note in the changelog. What do you think? |
My argument would be that If only the PSR methods are seen as included in the promise (or in the “public API” as semver says), it can easily be argued that the promise specifically does not mention the pointer. This would just be a patch or minor release to bring us inline with another part of the ecosystem. But if our own static factory methods are part of the promise my hardliner stance would be that a major version increase is required per strict semver. (Alternatively both can be true, and one can argue the library never stated it was following strict semver.) I am not sure I have a strong opinion about this, if we accept that we change the library to match the ecosystem we can just change it, but I know some people might have higher expectancies of semver. |
True!
Hm... Im not 100% convinced my point is valid. But we never specified this behaviour and it was untested.. I do think we should follow semver and I do think we should avoid doing a new major release. Currently we annoy the people that expect the stream to be rewinded, if we release this patch, we will annoy all other people... Hm.. |
when creating a stream from a string, the resource should be rewinded.
fix #176