Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Draft
nielsdos wants to merge 6 commits into php:master
base: master
Choose a base branch
Loading
from nielsdos:dom-sxe-streams

Conversation

Copy link
Member

@nielsdos nielsdos commented Jan 19, 2025
edited
Loading

RFC text to be written, WIP
Adds functionality to load XML/HTML from an already opened stream.

javiereguiluz and frederikbosch reacted with rocket emoji
Copy link
Member Author

cc @veewee @theseer maybe this is of interest for you

theseer reacted with laugh emoji veewee reacted with hooray emoji

Copy link
Contributor

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.

@veewee veewee mentioned this pull request Jan 29, 2025
1 task
Copy link
Member Author

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.

frederikbosch reacted with thumbs up emoji

Copy link
Contributor

Not a fan of int|falseeither. 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.

nielsdos reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@kocsismate kocsismate Awaiting requested review from kocsismate kocsismate will be requested when the pull request is marked ready for review kocsismate is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /