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/Kint_ObjectTest.php (42 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_ObjectTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Kint_ObjectTest 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 testAddRepresentation()
6
    {
7
        $o = new Kint_Object();
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...
8
9
        $this->assertSame(array(), $o->representations);
10
        $this->assertSame(null, $o->value);
11
12
        $this->assertTrue($o->addRepresentation($r1 = new Kint_Object_Representation('Rep 1')));
13
        $this->assertSame(
14
            array(
15
                $r1->name => $r1,
16
            ),
17
            $o->representations
18
        );
19
        $this->assertSame($r1, $o->value);
20
21
        $this->assertFalse($o->addRepresentation($r1));
22
        $this->assertSame(
23
            array(
24
                $r1->name => $r1,
25
            ),
26
            $o->representations
27
        );
28
29
        $this->assertTrue($o->addRepresentation($r2 = new Kint_Object_Representation('Rep 2')));
30
        $this->assertSame(
31
            array(
32
                $r1->name => $r1,
33
                $r2->name => $r2,
34
            ),
35
            $o->representations
36
        );
37
38
        $this->assertTrue($o->addRepresentation($r3 = new Kint_Object_Representation('Rep 3'), 0));
39
        $this->assertSame(
40
            array(
41
                $r3->name => $r3,
42
                $r1->name => $r1,
43
                $r2->name => $r2,
44
            ),
45
            $o->representations
46
        );
47
48
        $this->assertTrue($o->addRepresentation($r4 = new Kint_Object_Representation('Rep 4'), 1));
49
        $this->assertSame(
50
            array(
51
                $r3->name => $r3,
52
                $r4->name => $r4,
53
                $r1->name => $r1,
54
                $r2->name => $r2,
55
            ),
56
            $o->representations
57
        );
58
59
        $this->assertTrue($o->addRepresentation($r5 = new Kint_Object_Representation('Rep 5'), 100));
60
        $this->assertSame(
61
            array(
62
                $r3->name => $r3,
63
                $r4->name => $r4,
64
                $r1->name => $r1,
65
                $r2->name => $r2,
66
                $r5->name => $r5,
67
            ),
68
            $o->representations
69
        );
70
71
        $this->assertTrue($o->addRepresentation($r6 = new Kint_Object_Representation('Rep 6'), -100));
72
        $this->assertSame(
73
            array(
74
                $r6->name => $r6,
75
                $r3->name => $r3,
76
                $r4->name => $r4,
77
                $r1->name => $r1,
78
                $r2->name => $r2,
79
                $r5->name => $r5,
80
            ),
81
            $o->representations
82
        );
83
84
        $this->assertSame($r1, $o->value);
85
    }
86
87
    public function testReplaceRepresentation()
88
    {
89
        $o = new Kint_Object();
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...
90
        $o->addRepresentation($r1 = new Kint_Object_Representation('Rep 1'));
91
        $o->addRepresentation($r2 = new Kint_Object_Representation('Rep 2'));
92
        $o->addRepresentation($r3 = new Kint_Object_Representation('Rep 3'));
93
94
        $this->assertSame(
95
            array(
96
                $r1->name => $r1,
97
                $r2->name => $r2,
98
                $r3->name => $r3,
99
            ),
100
            $o->representations
101
        );
102
103
        $o->replaceRepresentation($r2_2 = new Kint_Object_Representation('Rep 2'));
0 ignored issues
show
$r2_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.

Loading history...
104
105
        $this->assertSame(
106
            array(
107
                $r1->name => $r1,
108
                $r2_2->name => $r2_2,
0 ignored issues
show
$r2_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.

Loading history...
109
                $r3->name => $r3,
110
            ),
111
            $o->representations
112
        );
113
114
        $o->replaceRepresentation($r2, 0);
115
116
        $this->assertSame(
117
            array(
118
                $r2->name => $r2,
119
                $r1->name => $r1,
120
                $r3->name => $r3,
121
            ),
122
            $o->representations
123
        );
124
125
        $o->replaceRepresentation($r2_2, 1);
0 ignored issues
show
$r2_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.

Loading history...
126
127
        $this->assertSame(
128
            array(
129
                $r1->name => $r1,
130
                $r2_2->name => $r2_2,
0 ignored issues
show
$r2_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.

Loading history...
131
                $r3->name => $r3,
132
            ),
133
            $o->representations
134
        );
135
    }
136
137
    public function testRemoveRepresentation()
138
    {
139
        $o = new Kint_Object();
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...
140
        $o->addRepresentation($r1 = new Kint_Object_Representation('Rep 1'));
141
        $o->addRepresentation($r2 = new Kint_Object_Representation('Rep 2'));
142
        $o->addRepresentation($r3 = new Kint_Object_Representation('Rep 3'));
143
144
        $this->assertSame(
145
            array(
146
                $r1->name => $r1,
147
                $r2->name => $r2,
148
                $r3->name => $r3,
149
            ),
150
            $o->representations
151
        );
152
153
        $o->removeRepresentation($r2->name);
154
155
        $this->assertSame(
156
            array(
157
                $r1->name => $r1,
158
                $r3->name => $r3,
159
            ),
160
            $o->representations
161
        );
162
    }
163
164
    public function testGetRepresentation()
165
    {
166
        $o = new Kint_Object();
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...
167
        $o->addRepresentation($r1 = new Kint_Object_Representation('Rep 1'));
168
        $o->addRepresentation($r2 = new Kint_Object_Representation('Rep 2'));
169
        $o->addRepresentation($r3 = new Kint_Object_Representation('Rep 3'));
170
171
        $this->assertSame($r1, $o->getRepresentation($r1->name));
172
        $this->assertSame($r2, $o->getRepresentation($r2->name));
173
        $this->assertSame($r3, $o->getRepresentation($r3->name));
174
        $this->assertSame(null, $o->getRepresentation('Non-existant representation name'));
175
    }
176
177
    public function testGetRepresentations()
178
    {
179
        $o = new Kint_Object();
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...
180
        $o->addRepresentation($r1 = new Kint_Object_Representation('Rep 1'));
181
        $o->addRepresentation($r2 = new Kint_Object_Representation('Rep 2'));
182
        $o->addRepresentation($r3 = new Kint_Object_Representation('Rep 3'));
183
184
        $this->assertSame(
185
            array(
186
                $r1->name => $r1,
187
                $r2->name => $r2,
188
                $r3->name => $r3,
189
            ),
190
            $o->getRepresentations()
191
        );
192
    }
193
194
    public function testClearRepresentations()
195
    {
196
        $o = new Kint_Object();
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...
197
        $o->addRepresentation($r1 = new Kint_Object_Representation('Rep 1'));
198
        $o->addRepresentation(new Kint_Object_Representation('Rep 2'));
199
        $o->addRepresentation(new Kint_Object_Representation('Rep 3'));
200
201
        $o->clearRepresentations();
202
203
        $this->assertSame(array(), $o->representations);
204
        $this->assertSame($r1, $o->value);
205
    }
206
207
    public function testGetType()
208
    {
209
        $o = new Kint_Object();
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...
210
        $o->type = 'array';
211
        $this->assertEquals('array', $o->getType());
212
    }
213
214
    public function modifierProvider()
215
    {
216
        return array(
217
            'public' => array(
218
                false,
219
                false,
220
                Kint_Object::ACCESS_PUBLIC,
221
                'public',
222
            ),
223
            'public const' => array(
224
                true,
225
                false,
226
                Kint_Object::ACCESS_PUBLIC,
227
                'public const',
228
            ),
229
            'public static' => array(
230
                false,
231
                true,
232
                Kint_Object::ACCESS_PUBLIC,
233
                'public static',
234
            ),
235
            'protected' => array(
236
                false,
237
                false,
238
                Kint_Object::ACCESS_PROTECTED,
239
                'protected',
240
            ),
241
            'private' => array(
242
                false,
243
                false,
244
                Kint_Object::ACCESS_PRIVATE,
245
                'private',
246
            ),
247
            'none' => array(
248
                false,
249
                false,
250
                Kint_Object::ACCESS_NONE,
251
                null,
252
            ),
253
            'private static' => array(
254
                false,
255
                true,
256
                Kint_Object::ACCESS_PRIVATE,
257
                'private static',
258
            ),
259
            'public const static' => array(
260
                true,
261
                true,
262
                Kint_Object::ACCESS_PUBLIC,
263
                'public const static',
264
            ),
265
            'const' => array(
266
                true,
267
                false,
268
                Kint_Object::ACCESS_NONE,
269
                'const',
270
            ),
271
        );
272
        $accesses = array(
0 ignored issues
show
$accesses = array(\Kint_...bject::ACCESS_PRIVATE); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
$accesses 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...
273
            Kint_Object::ACCESS_NONE,
274
            Kint_Object::ACCESS_PUBLIC,
275
            Kint_Object::ACCESS_PROTECTED,
276
            Kint_Object::ACCESS_PRIVATE,
277
        );
278
    }
279
280
    /**
281
     * @dataProvider modifierProvider
282
     */
283
    public function testGetModifiers($const, $static, $access, $expect)
284
    {
285
        $o = new Kint_Object();
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...
286
        $o->const = $const;
287
        $o->static = $static;
288
        $o->access = $access;
289
        $this->assertSame($expect, $o->getModifiers());
290
    }
291
292
    public function testGetAccess()
293
    {
294
        $o = new Kint_Object();
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...
295
        $this->assertNull($o->getAccess());
296
        $o->access = Kint_Object::ACCESS_PUBLIC;
297
        $this->assertEquals('public', $o->getAccess());
298
        $o->access = Kint_Object::ACCESS_PROTECTED;
299
        $this->assertEquals('protected', $o->getAccess());
300
        $o->access = Kint_Object::ACCESS_PRIVATE;
301
        $this->assertEquals('private', $o->getAccess());
302
    }
303
304 View Code Duplication
    public function testGetName()
0 ignored issues
show
This method seems to be duplicated in 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.

Loading history...
305
    {
306
        $o = new Kint_Object();
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...
307
        $o->name = '$var';
308
        $this->assertEquals('$var', $o->getName());
309
        $o->name = '($a + $b)';
310
        $this->assertEquals('($a + $b)', $o->getName());
311
        $o->name = 'This is just a name, nothing more, nothing less.';
312
        $this->assertEquals('This is just a name, nothing more, nothing less.', $o->getName());
313
    }
314
315
    public function testGetOperator()
316
    {
317
        $o = new Kint_Object();
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...
318
        $this->assertNull($o->getOperator());
319
        $o->operator = Kint_Object::OPERATOR_NONE;
320
        $this->assertNull($o->getOperator());
321
        $o->operator = Kint_Object::OPERATOR_ARRAY;
322
        $this->assertEquals('=>', $o->getOperator());
323
        $o->operator = Kint_Object::OPERATOR_OBJECT;
324
        $this->assertEquals('->', $o->getOperator());
325
        $o->operator = Kint_Object::OPERATOR_STATIC;
326
        $this->assertEquals('::', $o->getOperator());
327
    }
328
329 View Code Duplication
    public function testGetSize()
0 ignored issues
show
This method seems to be duplicated in 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.

Loading history...
330
    {
331
        $o = new Kint_Object();
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...
332
        $this->assertNull($o->getSize());
333
        $o->size = 0;
334
        $this->assertEquals(0, $o->getSize());
335
        $o->size = 42;
336
        $this->assertEquals(42, $o->getSize());
337
    }
338
339
    public function testGetValueShort()
340
    {
341
        $o = new Kint_Object();
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...
342
        $r = new Kint_Object_Representation('contents');
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...
343
        $o->addRepresentation($r);
344
345
        $r->contents = true;
0 ignored issues
show
Documentation Bug introduced by
It seems like true of type boolean 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...
346
        $this->assertNull($o->getValueShort());
347
        $o->type = 'boolean';
348
        $this->assertEquals('true', $o->getValueShort());
349
        $r->contents = false;
0 ignored issues
show
Documentation Bug introduced by
It seems like false of type false 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...
350
        $this->assertEquals('false', $o->getValueShort());
351
        $o->type = 'integer';
352
        $r->contents = 1234;
0 ignored issues
show
Documentation Bug introduced by
It seems like 1234 of type integer 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...
353
        $this->assertEquals(1234, $o->getValueShort());
354
        $o->type = 'double';
355
        $r->contents = 1234.5678;
0 ignored issues
show
Documentation Bug introduced by
It seems like 1234.5678 of type double 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...
356
        $this->assertEquals(1234.5678, $o->getValueShort());
357
        $o->type = 'array';
358
        $r->contents = array();
359
        $this->assertNull($o->getValueShort());
360
        $o->type = 'string';
361
        $r->contents = 'string';
0 ignored issues
show
Documentation Bug introduced by
It seems like 'string' 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...
362
        $this->assertNull($o->getValueShort());
363
    }
364
365
    public function testGetAccessPath()
366
    {
367
        $o = new Kint_Object();
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...
368
        $this->assertNull($o->getAccessPath());
369
        $o->access_path = 'abcdefg, hijk elemeno p';
370
        $this->assertEquals('abcdefg, hijk elemeno p', $o->getAccessPath());
371
    }
372
373
    public function testBlank()
374
    {
375
        $o = new Kint_Object();
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...
376
        $this->assertNull($o->name);
377
        $this->assertNull($o->access_path);
378
379
        $o = Kint_Object::blank();
380
        $this->assertNull($o->name);
381
        $this->assertNull($o->access_path);
382
383
        $o = Kint_Object::blank('$var');
384
        $this->assertEquals('$var', $o->name);
385
        $this->assertEquals('$var', $o->access_path);
386
387
        $o = Kint_Object::blank('Name', 'access_path');
388
        $this->assertEquals('Name', $o->name);
389
        $this->assertEquals('access_path', $o->access_path);
390
    }
391
392
    public function testTransplant()
393
    {
394
        $o = new Kint_Object();
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...
395
396
        $o->name = 'name';
397
        $o->size = 42;
398
        $o->access_path = 'access_path';
399
        $o->access = Kint_Object::ACCESS_PUBLIC;
400
        $o->static = true;
401
        $o->const = true;
402
        $o->type = 'type';
403
        $o->depth = 43;
404
        $o->owner_class = 'owner_class';
405
        $o->operator = Kint_Object::OPERATOR_OBJECT;
406
        $o->reference = true;
407
        $o->hints = array('test', 'transplant', 'hints');
408
409
        $r = new Kint_Object_Representation('Test');
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...
410
        $o->addRepresentation($r);
411
412
        $o2 = $o->transplant(new Kint_Object());
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o2. 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...
413
414
        $this->assertEquals($o, $o2);
415
        $this->assertNotSame($o, $o2);
416
        $this->assertSame($o->value, $o2->value);
417
418
        $o2 = new Kint_Object();
419
        $r2 = new Kint_Object_Representation('Test 2');
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r2. 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...
420
        $o2->addRepresentation($r2);
421
        $o2->hints = array('test', 'thoroughly');
422
423
        $o2 = $o->transplant($o2);
424
425
        $this->assertSame(array('test_2' => $r2, 'test' => $r), $o2->representations);
426
        $this->assertSame(array('test', 'transplant', 'hints', 'test', 'thoroughly'), $o2->hints);
427
    }
428
429
    public function testIsSequential()
430
    {
431
        $this->assertTrue(Kint_Object::isSequential(array(1, 2, 3, 4)));
432
        $this->assertFalse(Kint_Object::isSequential(array(0 => 1, 1 => 2, 3 => 3, 2 => 4)));
433
        $this->assertFalse(Kint_Object::isSequential(array(0 => 1, 1 => 2, '02' => 3, 3 => 4)));
434
    }
435
436
    public function testSortByAccess()
437
    {
438
        $o1 = new Kint_Object();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o1. 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...
439
        $o2 = new Kint_Object();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o2. 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...
440
        $o3 = new Kint_Object();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o3. 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...
441
442
        $a = array($o1, $o2, $o3);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. 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...
443
444
        $o1->access = Kint_Object::ACCESS_PRIVATE;
445
        $o2->access = Kint_Object::ACCESS_PROTECTED;
446
        $o3->access = Kint_Object::ACCESS_PUBLIC;
447
448
        $this->assertSame(array($o1, $o2, $o3), $a);
449
450
        usort($a, 'Kint_Object::sortByAccess');
451
        $this->assertSame(array($o3, $o2, $o1), $a);
452
453
        $o1->access = Kint_Object::ACCESS_PROTECTED;
454
        $o2->access = Kint_Object::ACCESS_PRIVATE;
455
456
        usort($a, 'Kint_Object::sortByAccess');
457
        $this->assertSame(array($o3, $o1, $o2), $a);
458
    }
459
460
    public function testSortByName()
461
    {
462
        $o1 = new Kint_Object();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o1. 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...
463
        $o2 = new Kint_Object();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o2. 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...
464
        $o3 = new Kint_Object();
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $o3. 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...
465
466
        $a = array($o1, $o2, $o3);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $a. 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...
467
468
        $o1->name = 'Name Z';
469
        $o2->name = 'Name B';
470
        $o3->name = 'Name A';
471
472
        $this->assertSame(array($o1, $o2, $o3), $a);
473
474
        usort($a, 'Kint_Object::sortByName');
475
        $this->assertSame(array($o3, $o2, $o1), $a);
476
477
        $o1->name = 'Name M';
478
        $o2->name = 'Name Z2';
479
480
        usort($a, 'Kint_Object::sortByName');
481
        $this->assertSame(array($o3, $o1, $o2), $a);
482
    }
483
}
484