Issues (1165)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/Object/MethodTest.php (24 issues)

Upgrade to new PHP Analysis Engine

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
Kint_Object_MethodTest 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 testConstruct()
6
    {
7
        $reflection = new ReflectionMethod('TestClass', 'mix');
8
        $m = new Kint_Object_Method($reflection);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
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.

Loading history...
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.

Loading history...
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 $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
45
    }
46
47
    public function testSetAccessPathFrom()
48
    {
49
        $o = Kint_Object::blank('$tc');
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...
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.

Loading history...
52
53
        $m = new Kint_Object_Method(new ReflectionMethod('TestClass', '__construct'));
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
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.

Loading history...
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.

Loading history...
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.

Loading history...
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.

Loading history...
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.

Loading history...
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.

Loading history...
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.

Loading history...
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.

Loading history...
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
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
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
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
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
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
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
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
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
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
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
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
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
Comprehensibility introduced by
Avoid variables with short names like $m. 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...
180
        $this->assertNull($m->getPhpDocUrl());
181
    }
182
}
183