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_Object_MethodTest extends PHPUnit_Framework_TestCase |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | public function testConstruct() |
||
6 | { |
||
7 | $reflection = new ReflectionMethod('TestClass', 'mix'); |
||
8 | $m = new Kint_Object_Method($reflection); |
||
0 ignored issues
–
show
|
|||
9 | $this->assertEquals('mix', $m->name); |
||
10 | $this->assertEquals($reflection->getFilename(), $m->filename); |
||
11 | $this->assertEquals($reflection->getStartLine(), $m->startline); |
||
12 | $this->assertEquals($reflection->getEndLine(), $m->endline); |
||
13 | $this->assertEquals(false, $m->internal); |
||
14 | $this->assertEquals($reflection->getDocComment(), $m->docstring); |
||
15 | $this->assertEquals(Kint_Object::OPERATOR_STATIC, $m->operator); |
||
16 | $this->assertEquals(Kint_Object::ACCESS_PROTECTED, $m->access); |
||
17 | $this->assertEquals('TestClass', $m->owner_class); |
||
18 | $this->assertTrue($m->static); |
||
19 | $this->assertTrue($m->final); |
||
20 | $this->assertFalse($m->abstract); |
||
21 | $this->assertFalse($m->internal); |
||
22 | |||
23 | $reflection = new ReflectionMethod('ChildTestClass', '__construct'); |
||
24 | $parent_reflection = new ReflectionMethod('TestClass', '__construct'); |
||
0 ignored issues
–
show
$parent_reflection 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. ![]() |
|||
25 | $m = new Kint_Object_Method($reflection); |
||
26 | $this->assertEquals($parent_reflection->getDocComment(), $m->docstring); |
||
0 ignored issues
–
show
$parent_reflection 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 | $this->assertEquals(Kint_Object::OPERATOR_OBJECT, $m->operator); |
||
28 | $this->assertEquals(Kint_Object::ACCESS_PUBLIC, $m->access); |
||
29 | $this->assertEquals('TestClass', $m->owner_class); |
||
30 | |||
31 | $reflection = new ReflectionFunction('explode'); |
||
32 | $m = new Kint_Object_Method($reflection); |
||
33 | $this->assertTrue($m->internal); |
||
34 | $this->assertEquals(Kint_Object::OPERATOR_NONE, $m->operator); |
||
35 | $this->assertEquals(Kint_Object::ACCESS_NONE, $m->access); |
||
36 | $this->assertEquals(null, $m->owner_class); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * @expectedException \InvalidArgumentException |
||
41 | */ |
||
42 | public function testConstructWrongType() |
||
43 | { |
||
44 | $m = new Kint_Object_Method(new stdClass()); |
||
0 ignored issues
–
show
$m 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 ![]() |
|||
45 | } |
||
46 | |||
47 | public function testSetAccessPathFrom() |
||
48 | { |
||
49 | $o = Kint_Object::blank('$tc'); |
||
0 ignored issues
–
show
|
|||
50 | $o = $o->transplant(new Kint_Object_Instance()); |
||
51 | $o->classname = 'TestClass'; |
||
0 ignored issues
–
show
The property
classname 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. ![]() |
|||
52 | |||
53 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', '__construct')); |
||
0 ignored issues
–
show
|
|||
54 | $this->assertNull($m->getAccessPath()); |
||
55 | $m->setAccessPathFrom($o); |
||
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. ![]() |
|||
56 | $this->assertEquals('new \\TestClass()', $m->getAccessPath()); |
||
57 | |||
58 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'static_method')); |
||
59 | $this->assertNull($m->getAccessPath()); |
||
60 | $m->setAccessPathFrom($o); |
||
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. ![]() |
|||
61 | $this->assertEquals('\\TestClass::static_method()', $m->getAccessPath()); |
||
62 | |||
63 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'final_method')); |
||
64 | $this->assertNull($m->getAccessPath()); |
||
65 | $m->setAccessPathFrom($o); |
||
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. ![]() |
|||
66 | $this->assertEquals('$tc->final_method()', $m->getAccessPath()); |
||
67 | |||
68 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'mix')); |
||
69 | $this->assertNull($m->getAccessPath()); |
||
70 | $m->setAccessPathFrom($o); |
||
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. ![]() |
|||
71 | $this->assertEquals( |
||
72 | '\\TestClass::mix(array &$x, TestClass $y = null, $z = array(...), $_ = \'string\')', |
||
73 | $m->getAccessPath() |
||
74 | ); |
||
75 | |||
76 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', '__clone')); |
||
77 | $this->assertNull($m->getAccessPath()); |
||
78 | $m->setAccessPathFrom($o); |
||
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. ![]() |
|||
79 | $this->assertEquals('clone $tc', $m->getAccessPath()); |
||
80 | |||
81 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', '__invoke')); |
||
82 | $this->assertNull($m->getAccessPath()); |
||
83 | $m->setAccessPathFrom($o); |
||
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. ![]() |
|||
84 | $this->assertEquals('$tc($x)', $m->getAccessPath()); |
||
85 | |||
86 | // Tests both tostring and case insensitivity |
||
87 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', '__tostring')); |
||
88 | $this->assertNull($m->getAccessPath()); |
||
89 | $m->setAccessPathFrom($o); |
||
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. ![]() |
|||
90 | $this->assertEquals('__ToStRiNg', $m->name); |
||
91 | $this->assertEquals('(string) $tc', $m->getAccessPath()); |
||
92 | |||
93 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', '__get')); |
||
94 | $this->assertNull($m->getAccessPath()); |
||
95 | $m->setAccessPathFrom($o); |
||
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. ![]() |
|||
96 | $this->assertNull($m->getAccessPath()); |
||
97 | } |
||
98 | |||
99 | public function testGetValueShort() |
||
100 | { |
||
101 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', '__construct')); |
||
0 ignored issues
–
show
|
|||
102 | $this->assertEquals( |
||
103 | 'This is a constructor for a TestClass with the first line of the docstring split into two different lines.', |
||
104 | $m->getValueShort() |
||
105 | ); |
||
106 | } |
||
107 | |||
108 | public function testGetModifiers() |
||
109 | { |
||
110 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'static_method')); |
||
0 ignored issues
–
show
|
|||
111 | $this->assertEquals('private static', $m->getModifiers()); |
||
112 | |||
113 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'final_method')); |
||
114 | $this->assertEquals('final public', $m->getModifiers()); |
||
115 | |||
116 | $m = new Kint_Object_Method(new ReflectionMethod('ReflectionFunctionAbstract', '__toString')); |
||
117 | $this->assertEquals('abstract public', $m->getModifiers()); |
||
118 | |||
119 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'mix')); |
||
120 | $this->assertEquals('final protected static', $m->getModifiers()); |
||
121 | } |
||
122 | |||
123 | public function testGetAccessPath() |
||
124 | { |
||
125 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'array_hint')); |
||
0 ignored issues
–
show
|
|||
126 | $this->assertNull($m->getAccessPath()); |
||
127 | $m->access_path = '$m->array_hint'; |
||
128 | $this->assertEquals('$m->array_hint(array $x)', $m->getAccessPath()); |
||
129 | } |
||
130 | |||
131 | public function testGetParams() |
||
132 | { |
||
133 | $m = new Kint_Object_Method(new ReflectionFunction('explode')); |
||
0 ignored issues
–
show
|
|||
134 | if (defined('HHVM_VERSION')) { |
||
135 | $this->assertStringStartsWith('HH\\string $delimiter, HH\\string $str, HH\\int $limit = ', $m->getParams()); |
||
136 | } else { |
||
137 | $this->assertEquals('$separator, $str, $limit', $m->getParams()); |
||
138 | } |
||
139 | |||
140 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'array_hint')); |
||
141 | $this->assertEquals('array $x', $m->getParams()); |
||
142 | |||
143 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'class_hint')); |
||
144 | $this->assertEquals('TestClass $x', $m->getParams()); |
||
145 | |||
146 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'ref')); |
||
147 | $this->assertEquals('&$x', $m->getParams()); |
||
148 | |||
149 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'default_method')); |
||
150 | $this->assertEquals('$x = 1234', $m->getParams()); |
||
151 | |||
152 | $m = new Kint_Object_Method(new ReflectionMethod('TestClass', 'mix')); |
||
153 | $this->assertEquals( |
||
154 | 'array &$x, TestClass $y = null, $z = array(...), $_ = \'string\'', |
||
155 | $m->getParams() |
||
156 | ); |
||
157 | } |
||
158 | |||
159 | public function testGetPhpDocUrl() |
||
160 | { |
||
161 | $m = new Kint_Object_Method(new ReflectionMethod('ReflectionMethod', '__construct')); |
||
0 ignored issues
–
show
|
|||
162 | $this->assertEquals( |
||
163 | 'https://secure.php.net/reflectionmethod.construct', |
||
164 | $m->getPhpDocUrl() |
||
165 | ); |
||
166 | } |
||
167 | |||
168 | public function testGetPhpDocUrlParent() |
||
169 | { |
||
170 | $m = new Kint_Object_Method(new ReflectionMethod('ReflectionMethod', '__clone')); |
||
0 ignored issues
–
show
|
|||
171 | $this->assertEquals( |
||
172 | 'https://secure.php.net/reflectionfunctionabstract.clone', |
||
173 | $m->getPhpDocUrl() |
||
174 | ); |
||
175 | } |
||
176 | |||
177 | public function testGetPhpDocUrlUserDefined() |
||
178 | { |
||
179 | $m = new Kint_Object_Method(new ReflectionMethod(__CLASS__, __FUNCTION__)); |
||
0 ignored issues
–
show
|
|||
180 | $this->assertNull($m->getPhpDocUrl()); |
||
181 | } |
||
182 | } |
||
183 |
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.