pocketmine\CrashDump::baseCrash PHP Метод

baseCrash() приватный Метод

private baseCrash ( )
    private function baseCrash()
    {
        global $lastExceptionError, $lastError;
        if (isset($lastExceptionError)) {
            $error = $lastExceptionError;
        } else {
            $error = (array) error_get_last();
            $error["trace"] = @getTrace(3);
            $errorConversion = [E_ERROR => "E_ERROR", E_WARNING => "E_WARNING", E_PARSE => "E_PARSE", E_NOTICE => "E_NOTICE", E_CORE_ERROR => "E_CORE_ERROR", E_CORE_WARNING => "E_CORE_WARNING", E_COMPILE_ERROR => "E_COMPILE_ERROR", E_COMPILE_WARNING => "E_COMPILE_WARNING", E_USER_ERROR => "E_USER_ERROR", E_USER_WARNING => "E_USER_WARNING", E_USER_NOTICE => "E_USER_NOTICE", E_STRICT => "E_STRICT", E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR", E_DEPRECATED => "E_DEPRECATED", E_USER_DEPRECATED => "E_USER_DEPRECATED"];
            $error["fullFile"] = $error["file"];
            $error["file"] = cleanPath($error["file"]);
            $error["type"] = $errorConversion[$error["type"]] ?? $error["type"];
            if (($pos = strpos($error["message"], "\n")) !== false) {
                $error["message"] = substr($error["message"], 0, $pos);
            }
        }
        if (isset($lastError)) {
            $this->data["lastError"] = $lastError;
        }
        $this->data["error"] = $error;
        unset($this->data["error"]["fullFile"]);
        unset($this->data["error"]["trace"]);
        $this->addLine("Error: " . $error["message"]);
        $this->addLine("File: " . $error["file"]);
        $this->addLine("Line: " . $error["line"]);
        $this->addLine("Type: " . $error["type"]);
        if (strpos($error["file"], "src/pocketmine/") === false and strpos($error["file"], "src/raklib/") === false and file_exists($error["fullFile"])) {
            $this->addLine();
            $this->addLine("THIS CRASH WAS CAUSED BY A PLUGIN");
            $this->data["plugin"] = true;
            $reflection = new \ReflectionClass(PluginBase::class);
            $file = $reflection->getProperty("file");
            $file->setAccessible(true);
            foreach ($this->server->getPluginManager()->getPlugins() as $plugin) {
                $filePath = \pocketmine\cleanPath($file->getValue($plugin));
                if (strpos($error["file"], $filePath) === 0) {
                    $this->data["plugin"] = $plugin->getName();
                    $this->addLine("BAD PLUGIN: " . $plugin->getDescription()->getFullName());
                    break;
                }
            }
        } else {
            $this->data["plugin"] = false;
        }
        $this->addLine();
        $this->addLine("Code:");
        $this->data["code"] = [];
        if ($this->server->getProperty("auto-report.send-code", true) !== false) {
            $file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES);
            for ($l = max(0, $error["line"] - 10); $l < $error["line"] + 10; ++$l) {
                $this->addLine("[" . ($l + 1) . "] " . @$file[$l]);
                $this->data["code"][$l + 1] = @$file[$l];
            }
        }
        $this->addLine();
        $this->addLine("Backtrace:");
        foreach ($this->data["trace"] = $error["trace"] as $line) {
            $this->addLine($line);
        }
        $this->addLine();
    }