On Tue, Nov 4, 2025, 8:18 PM Larry Garfield <[email protected]> wrote:
> Arnaud and I would like to present another RFC for consideration: Context > Managers. > > https://wiki.php.net/rfc/context-managers > > You'll probably note that is very similar to the recent proposal from Tim > and Seifeddine. Both proposals grew out of casual discussion several > months ago; I don't believe either team was aware that the other was also > actively working on such a proposal, so we now have two. C'est la vie. :-) > > Naturally, Arnaud and I feel that our approach is the better one. In > particular, as Arnaud noted in an earlier reply, __destruct() is unreliable > if timing matters. It also does not allow differentiating between a > success or failure exit condition, which for many use cases is absolutely > mandatory (as shown in the examples in the context manager RFC). > > The Context Manager proposal is a near direct port of Python's approach, > which is generally very well thought-out. However, there are a few open > questions as listed in the RFC that we are seeking feedback on. > > Discuss. :-) > Great idea, I'm definitely behind this. I've also read through all the PR code. I have a few questions 1. Apart from wrapping zend_resource into ResourceContext, has there been discussions or ideas to wrap other things ? 2. Are there any scenarios where using with() is a bad idea or has "side effects"? 3. In the implementation code there is a lot of mention of "list" and zend_list .. why? Maybe the answer is obvious but I can't see, at first glance, why we are implementing list under the hood. Thanks, and great work to both of you! > -- > Larry Garfield > [email protected] >
