maxMemory = $maxMemory; parent::__construct($this->tempFd(), true, $throwOnError); } /** @var int */ protected $maxMemory; protected function tempFd() { return fopen("php://temp/maxmemory:$this->maxMemory", "w+b"); } function getResource() { if ($this->fd === null) $this->fd = $this->tempFd(); return parent::getResource(); } }