-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[RFC] Add simplexml_load_stream(), HTMLDocument::createFromStream(), XMLDocument::createFromStream() #17522
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
706b4e2
to
fcc13f6
Compare
This an interesting feature (again). Another method I would love to see - which is very close to this PR - is XSLTProcessor::transformToStream. In that case XSLTProcessor::transformToUri would become a simplified version of the new transformToStream method.
Hi Frederik
That makes sense, and shouldn't be hard at all to add.
Something like public XSLTProcessor::transformToStream(object $document, /*resource*/ $stream): int
should do.
The return value is up to debate I suppose. transformToUri
returns an int that gives the number of written bytes on success, and -1 on failure. While transformToXml
returns false or null on error, confusingly. We aren't really a fan of int|false
returns any more because of the coercion between 0 and false when doing a ==
comparison. So I suppose in the exceptional case where no output could be generated an exception should be thrown. Feel free to give your opinion.
Not a fan of int|false
either. I'd prefer an exception when the method fails. So void would be sufficient. When one needs to know the number of bytes written, one could check the size of the stream before and after the operation.
fcc13f6
to
086ea4c
Compare
415c2fb
to
1e55758
Compare
Uh oh!
There was an error while loading. Please reload this page.
RFC text to be written, WIP
Adds functionality to load XML/HTML from an already opened stream.