为什么包括调用stream_flush?

I have written a stream wrapper and when I call include foo://bar my stream_flush implementation gets called. stream_open gets called with rb. So... why is flush called? Since the file is opened read only I do not really have anything to do there if my understanding of stream_flush is correct but then again if my understanding would be correct it wouldn't be called in the first place.

Edit: since this got an "unclear what you are asking" close vote: the question really is, what should I do in my stream_flush implementation when it is called on a read only fie?

stream_flush was generally called when a stream is being closed. I don't really see any reason why it's done always. It makes sense when something was written, but not really when nothing was written at all (aka reading only).

In code is noted /* make sure everything is saved */, which is totally fine if anything has been written.

Fixed via http://git.php.net/?p=php-src.git;a=commitdiff;h=6ad9cd5367734276d624d6d2a03406ed0d0cd08b (PHP 7.0 tree) ... stream_flush now only ever is called when either explicitly flushed or upon close while something was written, but not yet flushed. Also clarified in docs http://svn.php.net/viewvc/phpdoc/en/trunk/reference/stream/streamwrapper/stream-flush.xml?r1=337084&r2=337083&pathrev=337084 (may take until Friday that all docs are rebuilt).