Kint_Parser_Blacklist::getTriggers()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
class Kint_Parser_Blacklist extends Kint_Parser_Plugin
0 ignored issues
show
Coding Style introduced by
Kint_Parser_Blacklist does not seem to conform to the naming convention (^[A-Z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
Coding Style introduced by
The property $shallow_blacklist is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
4
{
5
    /**
6
     * List of classes and interfaces to blacklist.
7
     *
8
     * @var array
9
     */
10
    public static $blacklist = array();
11
12
    /**
13
     * List of classes and interfaces to blacklist except when dumped directly.
14
     *
15
     * @var array
16
     */
17
    public static $shallow_blacklist = array();
0 ignored issues
show
Coding Style introduced by
$shallow_blacklist does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
18
19
    public function getTypes()
20
    {
21
        return array('object');
22
    }
23
24
    public function getTriggers()
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
25
    {
26
        return Kint_Parser::TRIGGER_BEGIN;
27
    }
28
29
    public function parse(&$var, Kint_Object &$o, $trigger)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
30
    {
31
        foreach (self::$blacklist as $class) {
32
            if ($var instanceof $class) {
33
                return $this->blacklist($var, $o);
34
            }
35
        }
36
37
        if ($o->depth <= 0) {
38
            return;
39
        }
40
41
        foreach (self::$shallow_blacklist as $class) {
42
            if ($var instanceof $class) {
43
                return $this->blacklist($var, $o);
44
            }
45
        }
46
    }
47
48
    protected function blacklist(&$var, &$o)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
49
    {
50 View Code Duplication
        if (function_exists('spl_object_hash')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
            $hash = spl_object_hash($var);
52
        } else {
53
            ob_start();
54
            var_dump($var);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($var); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
55
            preg_match('/#(\d+)/', ob_get_clean(), $match);
56
            $hash = $match[1];
57
        }
58
59
        $object = $o->transplant(new Kint_Object_Instance());
60
        $object->classname = get_class($var);
61
        $object->hash = $hash;
62
        $object->clearRepresentations();
63
        $object->value = null;
64
        $object->size = null;
65
        $object->hints[] = 'blacklist';
66
67
        $o = $object;
68
69
        $this->parser->haltParse();
70
71
        return;
72
    }
73
}
74