Passed
Push — master ( 63d396...d8391b )
by
unknown
15:36 queued 06:10
created

strIncrement85()   A

Complexity

Conditions 6
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 13
rs 9.2222
c 1
b 0
f 0
cc 6
nc 4
nop 4
1
<?php
2
3
declare(strict_types=1);
4
5
setlocale(LC_ALL, 'en_US.utf8');
6
7
function phpunit10ErrorHandler(int $errno, string $errstr, string $filename, int $lineno): bool
8
{
9
    if (strIncrement85(PHP_VERSION_ID, $errno, $errstr, $filename)) {
10
        return true; // message suppressed - stop error handling
11
    }
12
    $x = error_reporting() & $errno;
13
    if (
14
        in_array(
15
            $errno,
16
            [
17
                E_DEPRECATED,
18
                E_WARNING,
19
                E_NOTICE,
20
                E_USER_DEPRECATED,
21
                E_USER_NOTICE,
22
                E_USER_WARNING,
23
            ],
24
            true
25
        )
26
    ) {
27
        if (0 === $x) {
28
            return true; // message suppressed - stop error handling
29
        }
30
31
        throw new Exception("$errstr $filename $lineno");
32
    }
33
34
    return false; // continue error handling
35
}
36
37
function strIncrement85(int $version, int $errno, string $errstr, string $filename): bool
38
{
39
    if ($version < 80500 || $errno !== E_DEPRECATED) {
40
        return false;
41
    }
42
    if (preg_match('/Increment on non-numeric string/', $errstr) === 1) {
43
        return true;
44
    }
45
    if (preg_match('/canonical/', $errstr) === 1 && preg_match('/mitoteam/', $filename) === 1) {
46
        return true;
47
    }
48
49
    return false;
50
}
51
52
if (!method_exists(PHPUnit\Framework\TestCase::class, 'setOutputCallback')) {
53
    set_error_handler('phpunit10ErrorHandler');
54
}
55