private function calculateSize()
    {
        // Clear the stat cache if the stream has a URI
        if ($this->uri) {
            clearstatcache(true, $this->uri);
        }

        $stats = fstat($this->stream);
        if (isset($stats[static::META_SIZE])) {
            $this->size = $stats[static::META_SIZE];

            return $this->size;
        }

        return null;
    }