PocketMine-MP 5.39.4 git-a2b7d660558310260c376d1eeaff549367b9fc6e
Loading...
Searching...
No Matches
ErrorTypeToStringMap.php
1<?php
2
3/*
4 * PocketMine Standard PHP Library
5 * Copyright (C) 2019 PocketMine Team <https://github.com/pmmp/PocketMine-SPL>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16*/
17
18declare(strict_types=1);
19
20namespace pocketmine\errorhandler;
21
23 private const ERROR_STRINGS = [
24 0 => "EXCEPTION",
25 E_ERROR => "E_ERROR",
26 E_WARNING => "E_WARNING",
27 E_PARSE => "E_PARSE",
28 E_NOTICE => "E_NOTICE",
29 E_CORE_ERROR => "E_CORE_ERROR",
30 E_CORE_WARNING => "E_CORE_WARNING",
31 E_COMPILE_ERROR => "E_COMPILE_ERROR",
32 E_COMPILE_WARNING => "E_COMPILE_WARNING",
33 E_USER_ERROR => "E_USER_ERROR",
34 E_USER_WARNING => "E_USER_WARNING",
35 E_USER_NOTICE => "E_USER_NOTICE",
36 E_RECOVERABLE_ERROR => "E_RECOVERABLE_ERROR",
37 E_DEPRECATED => "E_DEPRECATED",
38 E_USER_DEPRECATED => "E_USER_DEPRECATED"
39 ];
40
41 private function __construct(){
42
43 }
44
50 public static function get(int $errorType) : string{
51 if(!isset(self::ERROR_STRINGS[$errorType])){
52 //E_STRICT constant is deprecated in PHP 8.4
53 //we can't use it without polluting global error state, so the value is hardcoded for BC instead
54 if(defined("E_STRICT") && $errorType === 2048){
55 return "E_STRICT";
56 }
57 throw new \InvalidArgumentException("Invalid error type $errorType");
58 }
59
60 return self::ERROR_STRINGS[$errorType];
61 }
62}