You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, recently during development I found that the eof() method of StreamInterface does not work properly. I do not know if it is me who misunderstood the behavior or there is a bug regarding this issue. The code of me testing the case is like this.
$resource = fread('test.txt');//Any test txt file. Better not too large.
$content = Psr7\stream_for($resource);
$size = $content->getSize();
$content->read($size);//Read exactly the size of the file.
$isEof = $content->eof() == true? 'is end of file' : 'not end of file';
echo "{$size}\n{$isEof}\n";//Print the size of the file. Result also show 'not end of file';
If I get the remaining contents of the file using getContents or read($length) afterwards it returns an empty string, and then can have eof() returning the correct result.
The text was updated successfully, but these errors were encountered:
Hi, recently during development I found that the
eof()
method of StreamInterface does not work properly. I do not know if it is me who misunderstood the behavior or there is a bug regarding this issue. The code of me testing the case is like this.If I get the remaining contents of the file using
getContents
orread($length)
afterwards it returns an empty string, and then can haveeof()
returning the correct result.The text was updated successfully, but these errors were encountered: