Test Failed
Push — develop ( 48349f...3c7590 )
by Felipe
15:17
created

dump()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 10
1
<?php
2
3
/**
4
 * JPGraph v4.1.0-beta.01
5
 */
6
7
use Kint\Kint;
8
9
if (!\function_exists('tap')) {
10
    /**
11
     * Call the given Closure with the given value then return the value.
12
     *
13
     * @param mixed $value
14
     *
15
     * @return mixed
16
     */
17
    function tap($value, ?callable $callback = null)
18
    {
19
        if (null !== $callback) {
20
            $callback($value);
21
        }
22
23
        return $value;
24
    }
25
}
26
27
/*
28
 * Unless there's a dump function declared already, declare
29
 * one so we can use it safely elsewhere. Mostly used while developing
30
 */
31
if (!\function_exists('dump')) {
32
    // I'm sure this can be improved... just not today
33
    if (class_exists(Kint::class)) {
34
        function dump(...$vars)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
        {
36
            Kint::$enabled_mode = Kint::MODE_CLI;
37
            $return             = Kint::$return;
0 ignored issues
show
Unused Code introduced by
The assignment to $return is dead and can be removed.
Loading history...
38
            Kint::$return       = true;
39
            $fp                 = \fopen('php://stderr', 'ab');
40
            \fwrite($fp, Kint::dump(...$vars));
41
            \fclose($fp);
42
            $return       = Kint::$return;
43
            Kint::$return = $return;
44
        }
45
46
        Kint::$aliases[] = 'dump';
47
    } else {
48
        function dump(...$vars)
0 ignored issues
show
Unused Code introduced by
The parameter $vars is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

48
        function dump(/** @scrutinizer ignore-unused */ ...$vars)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
49
        {
50
        }
51
    }
52
}
53
54
/*
55
 * Dump to stderr and exit
56
 */
57
if (!\function_exists('dd')) {
58
    function dd(...$vars): void
59
    {
60
        dump(...$vars);
61
62
        exit();
0 ignored issues
show
Best Practice introduced by
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...
63
    }
64
    if (class_exists(Kint::class)) {
65
        Kint::$aliases[] = 'dd';
66
    }
67
}
68