Hello together, today I noticed that the order in which stream_flush/stream_close and the destructor of a (userspace implemented) stream wrapper are called is weird:
When a stream is closed with fclose(), the call order is as expected: stream_flush, stream_close, finally the destructor. But if the stream is closed automatically on program exit, the order seems wrong: stream_flush and stream_close are called AFTER the destructor was called (and so the object should be destroyed!) The documentation (http://php.net/manual/en/streamwrapper.destruct.php) for the destructor contains the ominous sentence "Called when closing the stream wrapper, right before streamWrapper::stream_flush()." which is clearly only half of the truth. Example: https://3v4l.org/CMItP Is this some kind of "desired" behavior? Should I open a bug? Greets, Dennis P.s.: In addition to the call order, in auto-close case autoloading with registered autoloaders does not work inside stream_flush and stream_close, it seems registered autoloaders (maybe all objects) have been dispatched when the calls happen, see: https://3v4l.org/GB7Mm (I also appended both example files as I don't know how long snippets at 3v4l.org persist)
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php