This is a longstanding issue which is requiring some advanced skills
so I'm begging for some help here.
To sum up the php feof()
function on memory based streams didn't work
the same way as on file based streams.
On a 10 bytes file eof is setted when 11 bytes is read.
While on a 10 bytes memory stream it requires to 12 bytes to be read
to get the correct eof value.
More details on the issue can be found there:
https://github.com/php/php-src/pull/1153
The source of the problem is related to the fact that the PHP core use
the C read() and fread()
functions indifferently.
While an attempt of a PR has been made to solve this issue
https://github.com/php/php-src/pull/1578, a complete refactoring of
the feof behavior would probably be a better option here, so that's
why I'm asking for some help/opinions.
Thank you.