Stream::getSize()

Source

public function getSize(): ?int
{
    if (null !== $this->size) {
        return $this->size;
    }
    if (!isset($this->stream)) {
        return null;
    }
    // Clear the stat cache if the stream has a URI
    if ($uri = $this->getUri()) {
        \clearstatcache(\true, $uri);
    }
    $stats = \fstat($this->stream);
    if (isset($stats['size'])) {
        $this->size = $stats['size'];
        return $this->size;
    }
    return null;
}

User Contributed Notes

You must log in before being able to contribute a note or feedback.