Kint_Parser_ToString::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_ToString extends Kint_Parser_Plugin
0 ignored issues
show
Coding Style introduced by
Kint_Parser_ToString 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 static $blacklist = array(
6
        'SimpleXMLElement',
7
    );
8
9
    public function getTypes()
10
    {
11
        return array('object');
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
        return Kint_Parser::TRIGGER_SUCCESS;
17
    }
18
19
    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...
20
    {
21
        $reflection = new ReflectionClass($var);
22
        if (!$reflection->hasMethod('__toString')) {
23
            return;
24
        }
25
26
        foreach (self::$blacklist as $class) {
27
            if ($var instanceof $class) {
28
                return;
29
            }
30
        }
31
32
        $r = new Kint_Object_Representation('toString');
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...
33
        $r->contents = (string) $var;
0 ignored issues
show
Documentation Bug introduced by
It seems like (string) $var of type string is incompatible with the declared type array of property $contents.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34
35
        $o->addRepresentation($r);
36
    }
37
}
38