Skip to content
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

feat(iterator): add helper for zend_object_iterator and iterable type #268

Merged
merged 132 commits into from
Nov 24, 2023

Conversation

joelwurtz
Copy link
Contributor

@joelwurtz joelwurtz commented Oct 17, 2023

Not sure if this is wanted, so this is a first shot into adding a ZendIterator type to handle all objects that have an iterator and allow custom extension to use them in a more friendly way

It should work for any class that extends Traversable, but not for array, a super type may be needed if we want to support iterable type : which is mainly either an array or a Traversable

TODO:

  • documentation

joehoyle and others added 30 commits December 20, 2022 14:19
Currently we only support throwing exception class entries, i.e. stateless exceptions. Ideally we also want to support throwing a ZVal which has a ClassEntry that extends the Exception PHP class. This can be used to throw stateful exceptions which is not uncommon.

This PR is missing one piece: `throw_object` will currently `drop` the Zval when the function is completed, causing reference / null pointer errors. It seems `ZVal::Drop` doesn't actually free the zval currently, it just sets the type to NULL (which also breaks things.) Discussed briefly in https://discord.com/channels/115233111977099271/1025314959179120714 on how best to solve this, but I'm not totally clear still! Ideally I think we want `throw_object` to own the `zval` but not free it once the function returns.
This is akin to ExecutorGlobals, but for the process globals
This allows extensions to register and unregister custom stream wrappers
@danog
Copy link
Collaborator

danog commented Nov 24, 2023

Changed my mind on the design a bit, refactoring...

@danog danog merged commit 3d66f17 into davidcole1340:master Nov 24, 2023
26 checks passed
@danog
Copy link
Collaborator

danog commented Nov 24, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants