CrashDump: do not assign possibly-false return value of fopen() directly to non-union field

this would become a problem with typed properties, and also phpstan level 7 doesn't like it.
This commit is contained in:
Dylan K. Taylor 2020-03-15 15:48:09 +00:00
parent 9c86763322
commit 5c7b05c2ba

View File

@ -117,10 +117,11 @@ class CrashDump{
mkdir($this->server->getDataPath() . "crashdumps");
}
$this->path = $this->server->getDataPath() . "crashdumps/" . date("D_M_j-H.i.s-T_Y", $this->time) . ".log";
$this->fp = @fopen($this->path, "wb");
if(!is_resource($this->fp)){
$fp = @fopen($this->path, "wb");
if(!is_resource($fp)){
throw new \RuntimeException("Could not create Crash Dump");
}
$this->fp = $fp;
$this->data["format_version"] = self::FORMAT_VERSION;
$this->data["time"] = $this->time;
$this->addLine($this->server->getName() . " Crash Dump " . date("D M j H:i:s T Y", $this->time));