This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | class Kint_Parser_ClassStatics extends Kint_Parser_Plugin |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | private static $cache = array(); |
||
6 | |||
7 | public function getTypes() |
||
8 | { |
||
9 | return array('object'); |
||
10 | } |
||
11 | |||
12 | public function getTriggers() |
||
0 ignored issues
–
show
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 ![]() |
|||
13 | { |
||
14 | return Kint_Parser::TRIGGER_SUCCESS; |
||
15 | } |
||
16 | |||
17 | public function parse(&$var, Kint_Object &$o, $trigger) |
||
0 ignored issues
–
show
|
|||
18 | { |
||
19 | $class = get_class($var); |
||
20 | $reflection = new ReflectionClass($class); |
||
21 | |||
22 | // Constants |
||
23 | // TODO: PHP 7.1 allows private consts but reflection doesn't have a way to check them yet |
||
24 | if (!isset(self::$cache[$class])) { |
||
25 | $consts = array(); |
||
26 | |||
27 | foreach ($reflection->getConstants() as $name => $val) { |
||
28 | $const = Kint_Object::blank($name); |
||
29 | $const->const = true; |
||
30 | $const->depth = $o->depth + 1; |
||
31 | $const->owner_class = $class; |
||
32 | View Code Duplication | if (KINT_PHP53) { |
|
0 ignored issues
–
show
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. ![]() |
|||
33 | $const->access_path = '\\'.$class.'::'.$const->name; |
||
34 | } else { |
||
35 | $const->access_path = $class.'::'.$const->name; |
||
36 | } |
||
37 | $const->operator = Kint_Object::OPERATOR_STATIC; |
||
38 | $const = $this->parser->parse($val, $const); |
||
39 | |||
40 | $consts[] = $const; |
||
41 | } |
||
42 | |||
43 | self::$cache[$class] = $consts; |
||
44 | } |
||
45 | |||
46 | $statics = new Kint_Object_Representation('Static class properties', 'statics'); |
||
47 | $statics->contents = self::$cache[$class]; |
||
48 | |||
49 | // Statics |
||
50 | |||
51 | if (!KINT_PHP53) { |
||
52 | $static_map = $reflection->getStaticProperties(); |
||
0 ignored issues
–
show
$static_map 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. ![]() |
|||
53 | } |
||
54 | |||
55 | foreach ($reflection->getProperties(ReflectionProperty::IS_STATIC) as $static) { |
||
56 | $prop = new Kint_Object(); |
||
57 | $prop->name = '$'.$static->getName(); |
||
58 | $prop->depth = $o->depth + 1; |
||
59 | $prop->static = true; |
||
60 | $prop->operator = Kint_Object::OPERATOR_STATIC; |
||
61 | |||
62 | if (KINT_PHP53) { |
||
63 | $prop->owner_class = $static->getDeclaringClass()->name; |
||
64 | } else { |
||
65 | // getDeclaringClass() is broke in old PHP versions, but getProperties() will only |
||
66 | // return accessible properties and we can access them through the parent class so |
||
67 | // we can just put the parent class here. It's not an accurate portrayal of where |
||
68 | // the static comes from, but it shows a working access path so it's good enough |
||
69 | $prop->owner_class = $class; |
||
70 | } |
||
71 | |||
72 | $prop->access = Kint_Object::ACCESS_PUBLIC; |
||
73 | View Code Duplication | if ($static->isProtected()) { |
|
0 ignored issues
–
show
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. ![]() |
|||
74 | $prop->access = Kint_Object::ACCESS_PROTECTED; |
||
75 | } elseif ($static->isPrivate()) { |
||
76 | $prop->access = Kint_Object::ACCESS_PRIVATE; |
||
77 | } |
||
78 | |||
79 | if ($this->parser->childHasPath($o, $prop)) { |
||
0 ignored issues
–
show
$o of type object<Kint_Object> is not a sub-type of object<Kint_Object_Instance> . It seems like you assume a child class of the class Kint_Object to be always present.
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass. Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type. ![]() |
|||
80 | View Code Duplication | if (KINT_PHP53) { |
|
0 ignored issues
–
show
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. ![]() |
|||
81 | $prop->access_path = '\\'.$prop->owner_class.'::'.$prop->name; |
||
82 | } else { |
||
83 | $prop->access_path = $prop->owner_class.'::'.$prop->name; |
||
84 | } |
||
85 | } |
||
86 | |||
87 | if (KINT_PHP53) { |
||
88 | $static->setAccessible(true); |
||
89 | $val = $static->getValue(); |
||
90 | } else { |
||
91 | switch ($prop->access) { |
||
92 | case Kint_Object::ACCESS_PUBLIC: |
||
93 | $val = $static_map[$static->getName()]; |
||
0 ignored issues
–
show
$static_map 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. ![]() The variable
$static_map does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
94 | break; |
||
95 | case Kint_Object::ACCESS_PROTECTED: |
||
96 | $val = $static_map["\0*\0".$static->getName()]; |
||
0 ignored issues
–
show
$static_map 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. ![]() |
|||
97 | break; |
||
98 | case Kint_Object::ACCESS_PRIVATE: |
||
99 | $val = $static_map["\0".$class."\0".$static->getName()]; |
||
0 ignored issues
–
show
$static_map 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. ![]() |
|||
100 | break; |
||
101 | } |
||
102 | } |
||
103 | |||
104 | $statics->contents[] = $this->parser->parse($val, $prop); |
||
105 | } |
||
106 | |||
107 | if (empty($statics->contents)) { |
||
108 | return; |
||
109 | } |
||
110 | |||
111 | usort($statics->contents, array('Kint_Parser_ClassStatics', 'sort')); |
||
112 | |||
113 | $o->addRepresentation($statics); |
||
114 | } |
||
115 | |||
116 | private static function sort(Kint_Object $a, Kint_Object $b) |
||
0 ignored issues
–
show
|
|||
117 | { |
||
118 | $sort = ((int) $a->const) - ((int) $b->const); |
||
119 | if ($sort) { |
||
120 | return $sort; |
||
121 | } |
||
122 | |||
123 | $sort = Kint_Object::sortByAccess($a, $b); |
||
124 | if ($sort) { |
||
125 | return $sort; |
||
126 | } |
||
127 | |||
128 | return Kint_Object_Instance::sortByHierarchy($a->owner_class, $b->owner_class); |
||
129 | } |
||
130 | } |
||
131 |
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.