Test Failed
Pull Request — develop (#90)
by Felipe
08:58
created

Kint::dump()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 2
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 7 and the first side effect is on line 34.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/**
4
 * JPGraph v4.1.0-beta.01
5
 */
6
if (!defined('STDIN')) {
7
    define('STDIN', fopen('php://stdin', 'rb'));
8
}
9
10
if (!defined('STDOUT')) {
11
    define('STDOUT', fopen('php://stdout', 'wb'));
12
}
13
14
if (!defined('STDERR')) {
15
    define('STDERR', fopen('php://stderr', 'wb'));
16
}
17
18
if (!class_exists('\Kint')) {
19
    /**
20
     * Class that mocks Kint
21
     * (will use this when dev dependencies are not installed).
22
     */
23
    class Kint
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
24
    {
25
        public static $enabled_mode     = true;
26
        public static $aliases          = [];
27
        public static $mode_default_cli = false;
28
        public static function dump()
29
        {
30
        }
31
    }
32
}
33
if (class_exists('\Kint\Renderer\RichRenderer')) {
34
    \Kint\Renderer\RichRenderer::$folder = false;
35
}
36
if (method_exists('\Kint', 'enabled')) {
37
    \Kint::enabled(DEBUGMODE);
38
} elseif (property_exists('\Kint', 'enabled_mode')) {
39
    \Kint::$enabled_mode = Kint::$mode_default_cli;
40
}
41
42
if (!class_exists('\PhpConsole\Handler')) {
43
    /**
44
     * Class that mocks PHP-Console debug feature.
45
     */
46
    class PC
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
47
    {
48
        public static function debug()
49
        {
50
        }
51
    }
52
}
53
function ddd(...$vars)
54
{
55
    Kint::dump(...$vars);
0 ignored issues
show
Unused Code introduced by
The call to Kint::dump() has too many arguments starting with $vars. ( Ignorable by Annotation )

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

55
    Kint::/** @scrutinizer ignore-call */ 
56
          dump(...$vars);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
56
    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...
57
}
58
59
function kdump(...$vars)
60
{
61
    ob_start();
62
63
    d(...$vars);
64
65
    $kintdump = (ob_get_clean());
66
67
    //dump($kintdump);
68
    fwrite(STDERR, $kintdump);
69
}
70
71
\Kint::$aliases[] = 'ddd';
72
\Kint::$aliases[] = 'kdump';
73
74
if (getenv('JPGRAPH_USE_PHPCONSOLE') &&
75
    isset($_SERVER['HTTP_USER_AGENT']) &&
76
    strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false
77
) {
78
    $handler = \PhpConsole\Handler::getInstance();
79
    \PhpConsole\Helper::register();
80
    $handler->start();
81
    \PC::debug('Started');
82
}
83