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_TraceTest extends PHPUnit_Framework_TestCase |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | public function testParse() |
||
6 | { |
||
7 | $p = new Kint_Parser(); |
||
0 ignored issues
–
show
|
|||
8 | $p->addPlugin(new Kint_Parser_Trace()); |
||
9 | |||
10 | $bt = defined('DEBUG_BACKTRACE_IGNORE_ARGS') |
||
0 ignored issues
–
show
|
|||
11 | ? debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) |
||
12 | : debug_backtrace(); |
||
13 | |||
14 | $o = Kint_Object::blank(); |
||
0 ignored issues
–
show
|
|||
15 | |||
16 | $o = $p->parse($bt, $o); |
||
17 | |||
18 | $this->assertContains('trace', $o->hints); |
||
19 | $this->assertInstanceOf('Kint_Object_Trace', $o); |
||
20 | $this->assertInstanceOf('Kint_Object_TraceFrame', $o->value->contents[0]); |
||
21 | } |
||
22 | |||
23 | public function provideTraces() |
||
24 | { |
||
25 | $bt = debug_backtrace(true); |
||
0 ignored issues
–
show
|
|||
26 | $bad_bt_1 = $bt; |
||
0 ignored issues
–
show
$bad_bt_1 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. ![]() |
|||
27 | $bad_bt_1[0]['test'] = 'woot'; |
||
0 ignored issues
–
show
$bad_bt_1 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. ![]() |
|||
28 | $bad_bt_2 = $bt; |
||
0 ignored issues
–
show
$bad_bt_2 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. ![]() $bad_bt_2 is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
29 | $bat_bt_2[0]['function'] = 1234; |
||
0 ignored issues
–
show
$bat_bt_2 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. ![]() Coding Style
Comprehensibility
introduced
by
$bat_bt_2 was never initialized. Although not strictly required by PHP, it is generally a good practice to add $bat_bt_2 = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
30 | |||
31 | return array( |
||
32 | 'empty' => array( |
||
33 | 'trace' => array(), |
||
34 | 'expect' => false, |
||
35 | ), |
||
36 | 'backtrace' => array( |
||
37 | 'trace' => $bt, |
||
38 | 'expect' => true, |
||
39 | ), |
||
40 | 'bad backtrace, extra key' => array( |
||
41 | 'trace' => $bad_bt_1, |
||
0 ignored issues
–
show
$bad_bt_1 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. ![]() |
|||
42 | 'expect' => false, |
||
43 | ), |
||
44 | 'bad backtrace, wrong type' => array( |
||
45 | 'trace' => $bad_bt_1, |
||
0 ignored issues
–
show
$bad_bt_1 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. ![]() |
|||
46 | 'expect' => false, |
||
47 | ), |
||
48 | 'mythical' => array( |
||
49 | 'trace' => array( |
||
50 | array( |
||
51 | 'function' => 'mythical_internal_function_with_no_args_that_results_in_a_backtrace', |
||
52 | 'file' => __FILE__, |
||
53 | 'line' => 1, |
||
54 | ), |
||
55 | ), |
||
56 | 'expect' => true, |
||
57 | ), |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @dataProvider provideTraces |
||
63 | */ |
||
64 | public function testIsTrace(array $trace, $expected) |
||
65 | { |
||
66 | $this->assertEquals($expected, Kint_Parser_Trace::isTrace($trace)); |
||
67 | } |
||
68 | |||
69 | public function provideFrames() |
||
70 | { |
||
71 | return array( |
||
72 | 'function match' => array( |
||
73 | 'frame' => array( |
||
74 | 'function' => 'testAWeirdFunctionName', |
||
75 | ), |
||
76 | 'matches' => array('testaweirdfunctionname'), |
||
77 | 'expected' => true, |
||
78 | ), |
||
79 | 'function no match denormalized' => array( |
||
80 | 'frame' => array( |
||
81 | 'function' => 'testAWeirdFunctionName', |
||
82 | ), |
||
83 | 'matches' => array('testAWeirdFunctionName'), |
||
84 | 'expected' => false, |
||
85 | ), |
||
86 | 'function no match method' => array( |
||
87 | 'frame' => array( |
||
88 | 'function' => 'testAWeirdFunctionName', |
||
89 | ), |
||
90 | 'matches' => array(array('test', 'testaweirdfunctionname')), |
||
91 | 'expected' => false, |
||
92 | ), |
||
93 | 'method no match function' => array( |
||
94 | 'frame' => array( |
||
95 | 'function' => 'testAWeirdFunctionName', |
||
96 | 'class' => 'test', |
||
97 | ), |
||
98 | 'matches' => array('testAWeirdFunctionName'), |
||
99 | 'expected' => false, |
||
100 | ), |
||
101 | 'method match' => array( |
||
102 | 'frame' => array( |
||
103 | 'function' => 'testAWeirdFunctionName', |
||
104 | 'class' => 'test', |
||
105 | ), |
||
106 | 'matches' => array(array('test', 'testaweirdfunctionname')), |
||
107 | 'expected' => true, |
||
108 | ), |
||
109 | ); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @dataProvider provideFrames |
||
114 | */ |
||
115 | public function testFrameIsListed(array $frame, array $matches, $expected) |
||
116 | { |
||
117 | $this->assertEquals($expected, Kint_Parser_Trace::frameIsListed($frame, $matches)); |
||
118 | } |
||
119 | |||
120 | public function testNormalizeAliases() |
||
121 | { |
||
122 | $input = array( |
||
123 | 'CamelCaseFunction', |
||
124 | 'snake_case_function', |
||
125 | 'One_of_the_FunctionsMyColleaguesMADE__', |
||
126 | 'stringThatCan\'tBeAfunction', |
||
127 | 'another string that can not be a function', |
||
128 | array('clASs', 'meThod'), |
||
129 | array($this, 'meThod'), |
||
130 | array('a', 'b', 'c'), |
||
131 | ); |
||
132 | |||
133 | $expected = array( |
||
134 | 'camelcasefunction', |
||
135 | 'snake_case_function', |
||
136 | 'one_of_the_functionsmycolleaguesmade__', |
||
137 | array('class', 'method'), |
||
138 | ); |
||
139 | |||
140 | Kint_Parser_Trace::normalizeAliases($input); |
||
141 | |||
142 | $this->assertEquals($expected, $input); |
||
143 | } |
||
144 | } |
||
145 |
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.