-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Closed
Copy link
Description
Description
The following code:
<?php
final class ErrorTypeToStringMap{
private const ERROR_STRINGS = [
E_STRICT => "E_STRICT",
];
private function __construct(){
}
public static function get(int $errorType) : string{
if(!isset(self::ERROR_STRINGS[$errorType])){
throw new \InvalidArgumentException("Invalid error type $errorType");
}
return self::ERROR_STRINGS[$errorType];
}
}
set_error_handler(function(int $severity, string $message, string $file, int $line): bool{
throw new \ErrorException($message, 0, $severity, $file, $line);
});
var_dump(ErrorTypeToStringMap::get(E_ERROR));Resulted in this output:
Assertion failed: !(((zend_executor_globals *) (((char*) _tsrm_ls_cache)+(executor_globals_offset)))->exception), file C:\pocketmine-php-8.4.12-debug\php-src\Zend\zend_vm_execute.h, line 35382
But I expected this output instead:
Fatal error: Uncaught InvalidArgumentException: Invalid error type 1 in C:\Users\dylan-work\Documents\projects\pocketmine-mp\stable\test4.php:16
Stack trace:
#0 C:\Users\dylan-work\Documents\projects\pocketmine-mp\stable\test4.php(30): ErrorTypeToStringMap::get(1)
#1 {main}
thrown in C:\Users\dylan-work\Documents\projects\pocketmine-mp\stable\test4.php on line 16
PHP Version
PHP 8.4.12 (cli) (built: Sep 5 2025 15:31:51) (ZTS Visual C++ 2022 x64 DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.4.12, Copyright (c) Zend Technologies
with Zend OPcache v8.4.12, Copyright (c), by Zend Technologies
Operating System
Windows 11
Reactions are currently unavailable