From 5c7b05c2ba7a7202666b0b0246f68cbe78f28a93 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 15 Mar 2020 15:48:09 +0000 Subject: [PATCH] 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. --- src/pocketmine/CrashDump.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/CrashDump.php b/src/pocketmine/CrashDump.php index 776989d24..49c0ff170 100644 --- a/src/pocketmine/CrashDump.php +++ b/src/pocketmine/CrashDump.php @@ -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));