in src/io/BufferedReader.php [288:318]
public function isEndOfFile(): bool {
if ($this->eof) {
return true;
}
if ($this->buffer !== '') {
return false;
}
// attempt to make `while (!$handle->isEOF()) {` safe on a closed file
// handle, e.g. STDIN; if we just return `$this->eof`, the caller loop
// body must check for EPIPE and EBADF which is unexpected.
try {
// Calling the non-async (but still non-blocking) version as the async
// version could wait for the other end to send data - which could lead
// to both ends of a pipe/socket waiting on each other.
$this->buffer = $this->handle->readImpl();
if ($this->buffer === '') {
$this->eof = true;
return true;
}
} catch (OS\BlockingIOException $_EWOULDBLOCK) {
return false;
} catch (OS\ErrnoException $ex) {
if ($ex->getErrno() === OS\Errno::EBADF) {
$this->eof = true;
return true;
}
// ignore; they'll hit it again when they try a real read
}
return false;
}