Issues (4)

src/functions.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
use Yiisoft\VarDumper\VarDumper;
6
7
if (!function_exists('d')) {
8
    /**
9
     * Prints variables.
10
     *
11
     * @param mixed ...$variables Variables to be dumped.
12
     *
13
     * @see \Yiisoft\VarDumper\VarDumper::dump()
14
     *
15
     * @psalm-suppress MixedAssignment
16
     */
17
    function d(mixed ...$variables): void
18
    {
19 2
        $highlight = PHP_SAPI !== 'cli';
20
21 2
        foreach ($variables as $variable) {
22 2
            VarDumper::dump($variable, 10, $highlight);
23 2
            echo $highlight ? '<br>' : PHP_EOL;
24
        }
25
    }
26
}
27
28
if (!function_exists('dd')) {
29
    /**
30
     * Prints variables and terminate the current script.
31
     *
32
     * @param mixed ...$variables Variables to be dumped.
33
     *
34
     * @see \Yiisoft\VarDumper\VarDumper::dump()
35
     *
36
     * @psalm-suppress MixedAssignment
37
     */
38
    function dd(mixed ...$variables): void
39
    {
40
        d(...$variables);
41
42
        die(0);
0 ignored issues
show
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
43
    }
44
}
45
46
if (!function_exists('dump')) {
47
    /**
48
     * Prints variables and terminate the current script.
49
     *
50
     * @param mixed ...$variables Variables to be dumped.
51
     *
52
     * @see d()
53
     *
54
     * @psalm-suppress MixedAssignment
55
     */
56
    function dump(mixed ...$variables): void
57
    {
58
        d(...$variables);
59
    }
60
}
61