Kint_Parser_Closure   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 66
rs 10
c 0
b 0
f 0
wmc 12
lcom 1
cbo 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTypes() 0 8 2
A getTriggers() 0 8 2
C parse() 0 45 8
1
<?php
2
3
class Kint_Parser_Closure extends Kint_Parser_Plugin
0 ignored issues
show
Coding Style introduced by
Kint_Parser_Closure 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...
4
{
5
    public function getTypes()
6
    {
7
        if (KINT_PHP53) {
8
            return array('object');
9
        } else {
10
            return array();
11
        }
12
    }
13
14
    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...
15
    {
16
        if (KINT_PHP53) {
17
            return Kint_Parser::TRIGGER_SUCCESS;
18
        } else {
19
            return Kint_Parser::TRIGGER_NONE;
20
        }
21
    }
22
23
    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...
24
    {
25
        if (!$var instanceof Closure) {
26
            return;
27
        }
28
29
        $o = $o->transplant(new Kint_Object_Closure());
30
        $o->removeRepresentation('properties');
31
32
        $closure = new ReflectionFunction($var);
33
34
        $o->filename = $closure->getFileName();
0 ignored issues
show
Bug introduced by
The property filename does not seem to exist in Kint_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
35
        $o->startline = $closure->getStartLine();
0 ignored issues
show
Bug introduced by
The property startline does not seem to exist in Kint_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
36
37
        foreach ($closure->getParameters() as $param) {
38
            $o->parameters[] = new Kint_Object_Parameter($param);
0 ignored issues
show
Bug introduced by
The property parameters does not seem to exist in Kint_Object.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
39
        }
40
41
        $p = new Kint_Object_Representation('Parameters');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $p. 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...
42
        $p->contents = &$o->parameters;
43
        $o->addRepresentation($p, 0);
44
45
        $statics = array();
46
47
        if (method_exists($closure, 'getClosureThis') && $v = $closure->getClosureThis()) {
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $v. 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...
48
            $statics = array('this' => $v);
49
        }
50
51
        if (count($statics = $statics + $closure->getStaticVariables())) {
52
            $statics_parsed = array();
0 ignored issues
show
Coding Style introduced by
$statics_parsed 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...
53
54
            foreach ($statics as $name => &$static) {
55
                $obj = Kint_Object::blank('$'.$name);
56
                $obj->depth = $o->depth + 1;
57
                $statics_parsed[$name] = $this->parser->parse($static, $obj);
0 ignored issues
show
Coding Style introduced by
$statics_parsed 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...
58
                if ($statics_parsed[$name]->value === null) {
0 ignored issues
show
Coding Style introduced by
$statics_parsed 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...
59
                    $statics_parsed[$name]->access_path = null;
0 ignored issues
show
Coding Style introduced by
$statics_parsed 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...
60
                }
61
            }
62
63
            $r = new Kint_Object_Representation('Uses');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. 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...
64
            $r->contents = $statics_parsed;
0 ignored issues
show
Coding Style introduced by
$statics_parsed 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...
65
            $o->addRepresentation($r, 0);
66
        }
67
    }
68
}
69