Issues (135)

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.

src/Reflection/Adapter/ReflectionObject.php (1 issue)

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
declare(strict_types=1);
4
5
namespace Roave\BetterReflection\Reflection\Adapter;
6
7
use ReflectionException as CoreReflectionException;
8
use ReflectionObject as CoreReflectionObject;
9
use Roave\BetterReflection\Reflection\ReflectionMethod as BetterReflectionMethod;
10
use Roave\BetterReflection\Reflection\ReflectionObject as BetterReflectionObject;
11
use function array_combine;
12
use function array_map;
13
use function func_num_args;
14
use function sprintf;
15
use function strtolower;
16
17
class ReflectionObject extends CoreReflectionObject
18
{
19
    /** @var BetterReflectionObject */
20
    private $betterReflectionObject;
21
22 61
    public function __construct(BetterReflectionObject $betterReflectionObject)
23
    {
24 61
        $this->betterReflectionObject = $betterReflectionObject;
25 61
    }
26
27
    /**
28
     * {@inheritDoc}
29
     *
30
     * @throws CoreReflectionException
31
     */
32 1
    public static function export($argument, $return = null)
33
    {
34 1
        $output = BetterReflectionObject::createFromInstance($argument)->__toString();
35
36 1
        if ($return) {
37 1
            return $output;
38
        }
39
40
        echo $output;
41
42
        return null;
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48 1
    public function __toString()
49
    {
50 1
        return $this->betterReflectionObject->__toString();
51
    }
52
53
    /**
54
     * {@inheritDoc}
55
     */
56 1
    public function getName()
57
    {
58 1
        return $this->betterReflectionObject->getName();
59
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64 1
    public function isInternal()
65
    {
66 1
        return $this->betterReflectionObject->isInternal();
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72 1
    public function isUserDefined()
73
    {
74 1
        return $this->betterReflectionObject->isUserDefined();
75
    }
76
77
    /**
78
     * {@inheritDoc}
79
     */
80 1
    public function isInstantiable()
81
    {
82 1
        return $this->betterReflectionObject->isInstantiable();
83
    }
84
85
    /**
86
     * {@inheritDoc}
87
     */
88 1
    public function isCloneable()
89
    {
90 1
        return $this->betterReflectionObject->isCloneable();
91
    }
92
93
    /**
94
     * {@inheritDoc}
95
     */
96 2
    public function getFileName()
97
    {
98 2
        return $this->betterReflectionObject->getFileName() ?? false;
99
    }
100
101
    /**
102
     * {@inheritDoc}
103
     */
104 1
    public function getStartLine()
105
    {
106 1
        return $this->betterReflectionObject->getStartLine();
107
    }
108
109
    /**
110
     * {@inheritDoc}
111
     */
112 1
    public function getEndLine()
113
    {
114 1
        return $this->betterReflectionObject->getEndLine();
115
    }
116
117
    /**
118
     * {@inheritDoc}
119
     */
120 2
    public function getDocComment()
121
    {
122 2
        return $this->betterReflectionObject->getDocComment() ?: false;
123
    }
124
125
    /**
126
     * {@inheritDoc}
127
     */
128 1
    public function getConstructor()
129
    {
130 1
        return new ReflectionMethod($this->betterReflectionObject->getConstructor());
131
    }
132
133
    /**
134
     * {@inheritDoc}
135
     */
136 2
    public function hasMethod($name)
137
    {
138 2
        return $this->betterReflectionObject->hasMethod($this->getMethodRealName($name));
139
    }
140
141
    /**
142
     * {@inheritDoc}
143
     */
144 2
    public function getMethod($name)
145
    {
146 2
        return new ReflectionMethod($this->betterReflectionObject->getMethod($this->getMethodRealName($name)));
147
    }
148
149 4
    private function getMethodRealName(string $name) : string
150
    {
151
        $realMethodNames = array_map(static function (BetterReflectionMethod $method) : string {
152 2
            return $method->getName();
153 4
        }, $this->betterReflectionObject->getMethods());
154
155
        $methodNames = array_combine(array_map(static function (string $methodName) : string {
156 2
            return strtolower($methodName);
157 4
        }, $realMethodNames), $realMethodNames);
158
159 4
        return $methodNames[strtolower($name)] ?? $name;
160
    }
161
162
    /**
163
     * {@inheritDoc}
164
     */
165 1
    public function getMethods($filter = null)
166
    {
167 1
        $methods = $this->betterReflectionObject->getMethods();
168
169 1
        $wrappedMethods = [];
170 1
        foreach ($methods as $key => $method) {
171 1
            $wrappedMethods[$key] = new ReflectionMethod($method);
172
        }
173
174 1
        return $wrappedMethods;
175
    }
176
177
    /**
178
     * {@inheritDoc}
179
     */
180 1
    public function hasProperty($name)
181
    {
182 1
        return $this->betterReflectionObject->hasProperty($name);
183
    }
184
185
    /**
186
     * {@inheritDoc}
187
     */
188 2
    public function getProperty($name)
189
    {
190 2
        $property = $this->betterReflectionObject->getProperty($name);
191
192 2
        if ($property === null) {
193 1
            throw new CoreReflectionException(sprintf('Property "%s" does not exist', $name));
194
        }
195
196 1
        return new ReflectionProperty($property);
197
    }
198
199
    /**
200
     * {@inheritDoc}
201
     */
202 1
    public function getProperties($filter = null)
203
    {
204 1
        $properties = $this->betterReflectionObject->getProperties();
205
206 1
        $wrappedProperties = [];
207 1
        foreach ($properties as $key => $property) {
208 1
            $wrappedProperties[$key] = new ReflectionProperty($property);
209
        }
210
211 1
        return $wrappedProperties;
212
    }
213
214
    /**
215
     * {@inheritDoc}
216
     */
217 1
    public function hasConstant($name)
218
    {
219 1
        return $this->betterReflectionObject->hasConstant($name);
220
    }
221
222
    /**
223
     * {@inheritDoc}
224
     */
225 1
    public function getConstants()
226
    {
227 1
        return $this->betterReflectionObject->getConstants();
228
    }
229
230
    /**
231
     * {@inheritDoc}
232
     */
233 1
    public function getConstant($name)
234
    {
235 1
        return $this->betterReflectionObject->getConstant($name);
236
    }
237
238
    /**
239
     * {@inheritDoc}
240
     */
241 1
    public function getInterfaces()
242
    {
243 1
        $interfaces = $this->betterReflectionObject->getInterfaces();
244
245 1
        $wrappedInterfaces = [];
246 1
        foreach ($interfaces as $key => $interface) {
247 1
            $wrappedInterfaces[$key] = new ReflectionClass($interface);
248
        }
249
250 1
        return $wrappedInterfaces;
251
    }
252
253
    /**
254
     * {@inheritDoc}
255
     */
256 1
    public function getInterfaceNames()
257
    {
258 1
        return $this->betterReflectionObject->getInterfaceNames();
259
    }
260
261
    /**
262
     * {@inheritDoc}
263
     */
264 1
    public function isInterface()
265
    {
266 1
        return $this->betterReflectionObject->isInterface();
267
    }
268
269
    /**
270
     * {@inheritDoc}
271
     *
272 1
     * @psalm-suppress InvalidReturnType see #530
273
     */
274 1
    public function getTraits()
275
    {
276 1
        $traits = $this->betterReflectionObject->getTraits();
277 1
278 1
        $wrappedTraits = [];
279
        foreach ($traits as $key => $trait) {
280
            $wrappedTraits[$key] = new ReflectionClass($trait);
281 1
        }
282
283
        return $wrappedTraits;
284
    }
285
286
    /**
287 1
     * {@inheritDoc}
288
     */
289 1
    public function getTraitNames()
290
    {
291
        return $this->betterReflectionObject->getTraitNames();
292
    }
293
294
    /**
295 1
     * {@inheritDoc}
296
     */
297 1
    public function getTraitAliases()
298
    {
299
        return $this->betterReflectionObject->getTraitAliases();
300
    }
301
302
    /**
303 1
     * {@inheritDoc}
304
     */
305 1
    public function isTrait()
306
    {
307
        return $this->betterReflectionObject->isTrait();
308
    }
309
310
    /**
311 1
     * {@inheritDoc}
312
     */
313 1
    public function isAbstract()
314
    {
315
        return $this->betterReflectionObject->isAbstract();
316
    }
317
318
    /**
319 1
     * {@inheritDoc}
320
     */
321 1
    public function isFinal()
322
    {
323
        return $this->betterReflectionObject->isFinal();
324
    }
325
326
    /**
327 1
     * {@inheritDoc}
328
     */
329 1
    public function getModifiers()
330
    {
331
        return $this->betterReflectionObject->getModifiers();
332
    }
333
334
    /**
335 1
     * {@inheritDoc}
336
     */
337 1
    public function isInstance($object)
338
    {
339
        return $this->betterReflectionObject->isInstance($object);
340
    }
341
342
    /**
343 1
     * {@inheritDoc}
344
     */
345 1
    public function newInstance($arg = null, ...$args)
0 ignored issues
show
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
346
    {
347
        throw new Exception\NotImplemented('Not implemented');
348
    }
349
350
    /**
351 1
     * {@inheritDoc}
352
     */
353 1
    public function newInstanceWithoutConstructor()
354
    {
355
        throw new Exception\NotImplemented('Not implemented');
356
    }
357
358
    /**
359 1
     * {@inheritDoc}
360
     */
361 1
    public function newInstanceArgs(?array $args = null)
362
    {
363
        throw new Exception\NotImplemented('Not implemented');
364
    }
365
366
    /**
367 2
     * {@inheritDoc}
368
     */
369 2
    public function getParentClass()
370
    {
371 2
        $parentClass = $this->betterReflectionObject->getParentClass();
372 1
373
        if ($parentClass === null) {
374
            return false;
375 1
        }
376
377
        return new ReflectionClass($parentClass);
378
    }
379
380
    /**
381 2
     * {@inheritDoc}
382
     */
383 2
    public function isSubclassOf($class)
384
    {
385
        $realParentClassNames = $this->betterReflectionObject->getParentClassNames();
386 1
387 2
        $parentClassNames = array_combine(array_map(static function (string $parentClassName) : string {
388
            return strtolower($parentClassName);
389 2
        }, $realParentClassNames), $realParentClassNames);
390
391 2
        $realParentClassName = $parentClassNames[strtolower($class)] ?? $class;
392
393
        return $this->betterReflectionObject->isSubclassOf($realParentClassName);
394
    }
395
396
    /**
397 1
     * {@inheritDoc}
398
     */
399 1
    public function getStaticProperties()
400
    {
401
        return $this->betterReflectionObject->getStaticProperties();
402
    }
403
404
    /**
405 4
     * {@inheritDoc}
406
     */
407 4
    public function getStaticPropertyValue($name, $default = null)
408
    {
409 4
        $betterReflectionProperty = $this->betterReflectionObject->getProperty($name);
410 2
411 1
        if ($betterReflectionProperty === null) {
412
            if (func_num_args() === 2) {
413
                return $default;
414 1
            }
415
416
            throw new CoreReflectionException(sprintf('Property "%s" does not exist', $name));
417 2
        }
418
419 2
        $property = new ReflectionProperty($betterReflectionProperty);
420 1
421
        if (! $property->isAccessible()) {
422
            throw new CoreReflectionException(sprintf('Property "%s" is not accessible', $name));
423 1
        }
424
425
        if (! $property->isStatic()) {
426
            throw new CoreReflectionException(sprintf('Property "%s" is not static', $name));
427 1
        }
428
429
        return $property->getValue();
430
    }
431
432
    /**
433 3
     * {@inheritDoc}
434
     */
435 3
    public function setStaticPropertyValue($name, $value)
436
    {
437 3
        $betterReflectionProperty = $this->betterReflectionObject->getProperty($name);
438 1
439
        if ($betterReflectionProperty === null) {
440
            throw new CoreReflectionException(sprintf('Property "%s" does not exist', $name));
441 2
        }
442
443 2
        $property = new ReflectionProperty($betterReflectionProperty);
444 1
445
        if (! $property->isAccessible()) {
446
            throw new CoreReflectionException(sprintf('Property "%s" is not accessible', $name));
447 1
        }
448
449
        if (! $property->isStatic()) {
450
            throw new CoreReflectionException(sprintf('Property "%s" is not static', $name));
451 1
        }
452 1
453
        $property->setValue($value);
454
    }
455
456
    /**
457 1
     * {@inheritDoc}
458
     */
459 1
    public function getDefaultProperties()
460
    {
461
        return $this->betterReflectionObject->getDefaultProperties();
462
    }
463
464
    /**
465 1
     * {@inheritDoc}
466
     */
467 1
    public function isIterateable()
468
    {
469
        return $this->betterReflectionObject->isIterateable();
470
    }
471
472
    /**
473 2
     * {@inheritDoc}
474
     */
475 2
    public function implementsInterface($interface)
476
    {
477
        $realInterfaceNames = $this->betterReflectionObject->getInterfaceNames();
478 1
479 2
        $interfaceNames = array_combine(array_map(static function (string $interfaceName) : string {
480
            return strtolower($interfaceName);
481 2
        }, $realInterfaceNames), $realInterfaceNames);
482
483 2
        $realInterfaceName = $interfaceNames[strtolower($interface)] ?? $interface;
484
485
        return $this->betterReflectionObject->implementsInterface($realInterfaceName);
486
    }
487
488
    /**
489 1
     * {@inheritDoc}
490
     */
491 1
    public function getExtension()
492
    {
493
        throw new Exception\NotImplemented('Not implemented');
494
    }
495
496
    /**
497 2
     * {@inheritDoc}
498
     */
499 2
    public function getExtensionName()
500
    {
501
        return $this->betterReflectionObject->getExtensionName() ?? false;
502
    }
503
504
    /**
505 1
     * {@inheritDoc}
506
     */
507 1
    public function inNamespace()
508
    {
509
        return $this->betterReflectionObject->inNamespace();
510
    }
511
512
    /**
513 1
     * {@inheritDoc}
514
     */
515 1
    public function getNamespaceName()
516
    {
517
        return $this->betterReflectionObject->getNamespaceName();
518
    }
519
520
    /**
521 1
     * {@inheritDoc}
522
     */
523 1
    public function getShortName()
524
    {
525
        return $this->betterReflectionObject->getShortName();
526
    }
527
}
528