Code Duplication    Length = 15-15 lines in 2 locations

htdocs/install/include/common.inc.php 1 location

@@ 36-50 (lines=15) @@
33
34
define('XOOPS_INSTALL', 1);
35
36
function fatalPhpErrorHandler($e = null) {
37
    $messageFormat = '<br><div>Fatal %s %s file: %s : %d </div>';
38
    $exceptionClass = '\Exception';
39
    $throwableClass = '\Throwable';
40
    if ($e === null) {
41
        $lastError = error_get_last();
42
        if ($lastError['type'] === E_ERROR) {
43
            // fatal error
44
            printf($messageFormat, 'Error', $lastError['message'], $lastError['file'], $lastError['line']);
45
        }
46
    } elseif ($e instanceof $exceptionClass || $e instanceof $throwableClass) {
47
        /** @var $e \Exception */
48
        printf($messageFormat, get_class($e), $e->getMessage(), $e->getFile(), $e->getLine());
49
    }
50
}
51
register_shutdown_function('fatalPhpErrorHandler');
52
set_exception_handler('fatalPhpErrorHandler');
53

upgrade/index.php 1 location

@@ 21-35 (lines=15) @@
18
 */
19
/* @var  $xoopsUser XoopsUser */
20
21
function fatalPhpErrorHandler($e = null) {
22
    $messageFormat = '<br><div>Fatal %s %s file: %s : %d </div>';
23
    $exceptionClass = '\Exception';
24
    $throwableClass = '\Throwable';
25
    if ($e === null) {
26
        $lastError = error_get_last();
27
        if ($lastError['type'] === E_ERROR) {
28
            // fatal error
29
            printf($messageFormat, 'Error', $lastError['message'], $lastError['file'], $lastError['line']);
30
        }
31
    } elseif ($e instanceof $exceptionClass || $e instanceof $throwableClass) {
32
        /** @var $e \Exception */
33
        printf($messageFormat, get_class($e), $e->getMessage(), $e->getFile(), $e->getLine());
34
    }
35
}
36
register_shutdown_function('fatalPhpErrorHandler');
37
set_exception_handler('fatalPhpErrorHandler');
38