Issues (127)

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/ReflectionParameter.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 Exception;
8
use ReflectionParameter as CoreReflectionParameter;
9
use Roave\BetterReflection\Reflection\ReflectionMethod as BetterReflectionMethod;
10
use Roave\BetterReflection\Reflection\ReflectionParameter as BetterReflectionParameter;
11
12
class ReflectionParameter extends CoreReflectionParameter
13
{
14
    /** @var BetterReflectionParameter */
15
    private $betterReflectionParameter;
16
17 22
    public function __construct(BetterReflectionParameter $betterReflectionParameter)
18
    {
19 22
        $this->betterReflectionParameter = $betterReflectionParameter;
20 22
    }
21
22
    /**
23
     * {@inheritDoc}
24
     *
25 1
     * @throws Exception
26
     */
27 1
    public static function export($function, $parameter, $return = null)
28
    {
29
        throw new Exception('Unable to export statically');
30
    }
31
32
    /**
33 1
     * {@inheritDoc}
34
     */
35 1
    public function __toString()
36
    {
37
        return $this->betterReflectionParameter->__toString();
38
    }
39
40
    /**
41 1
     * {@inheritDoc}
42
     */
43 1
    public function getName()
44
    {
45
        return $this->betterReflectionParameter->getName();
46
    }
47
48
    /**
49 1
     * {@inheritDoc}
50
     */
51 1
    public function isPassedByReference()
52
    {
53
        return $this->betterReflectionParameter->isPassedByReference();
54
    }
55
56
    /**
57 1
     * {@inheritDoc}
58
     */
59 1
    public function canBePassedByValue()
60
    {
61
        return $this->betterReflectionParameter->canBePassedByValue();
62
    }
63
64
    /**
65 2
     * {@inheritDoc}
66
     */
67
    public function getDeclaringFunction()
68 2
    {
69
        /** @var BetterReflectionMethod|\Roave\BetterReflection\Reflection\ReflectionFunction $function */
70 2
        $function = $this->betterReflectionParameter->getDeclaringFunction();
71 1
72
        if ($function instanceof BetterReflectionMethod) {
73
            return new ReflectionMethod($function);
0 ignored issues
show
Bug Best Practice introduced by James Titcumb
The return type of return new \Roave\Better...ctionMethod($function); (Roave\BetterReflection\R...dapter\ReflectionMethod) is incompatible with the return type of the parent method ReflectionParameter::getDeclaringFunction of type ReflectionFunction.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
74 1
        }
75
76
        return new ReflectionFunction($function);
77
    }
78
79
    /**
80 2
     * {@inheritDoc}
81
     */
82 2
    public function getDeclaringClass()
83
    {
84 2
        $declaringClass = $this->betterReflectionParameter->getDeclaringClass();
85 1
86
        if ($declaringClass === null) {
87
            return null;
88 1
        }
89
90
        return new ReflectionClass($declaringClass);
91
    }
92
93
    /**
94 2
     * {@inheritDoc}
95
     */
96 2
    public function getClass()
97
    {
98 2
        $class = $this->betterReflectionParameter->getClass();
99 1
100
        if ($class === null) {
101
            return null;
102 1
        }
103
104
        return new ReflectionClass($class);
105
    }
106
107
    /**
108 1
     * {@inheritDoc}
109
     */
110 1
    public function isArray()
111
    {
112
        return $this->betterReflectionParameter->isArray();
113
    }
114
115
    /**
116 1
     * {@inheritDoc}
117
     */
118 1
    public function isCallable()
119
    {
120
        return $this->betterReflectionParameter->isCallable();
121
    }
122
123
    /**
124 1
     * {@inheritDoc}
125
     */
126 1
    public function allowsNull()
127
    {
128
        return $this->betterReflectionParameter->allowsNull();
129
    }
130
131
    /**
132 1
     * {@inheritDoc}
133
     */
134 1
    public function getPosition()
135
    {
136
        return $this->betterReflectionParameter->getPosition();
137
    }
138
139
    /**
140 1
     * {@inheritDoc}
141
     */
142 1
    public function isOptional()
143
    {
144
        return $this->betterReflectionParameter->isOptional();
145
    }
146
147
    /**
148 1
     * {@inheritDoc}
149
     */
150 1
    public function isVariadic()
151
    {
152
        return $this->betterReflectionParameter->isVariadic();
153
    }
154
155
    /**
156 1
     * {@inheritDoc}
157
     */
158 1
    public function isDefaultValueAvailable()
159
    {
160
        return $this->betterReflectionParameter->isDefaultValueAvailable();
161
    }
162
163
    /**
164 1
     * {@inheritDoc}
165
     */
166 1
    public function getDefaultValue()
167
    {
168
        return $this->betterReflectionParameter->getDefaultValue();
169
    }
170
171
    /**
172 1
     * {@inheritDoc}
173
     */
174 1
    public function isDefaultValueConstant()
175
    {
176
        return $this->betterReflectionParameter->isDefaultValueConstant();
177
    }
178
179
    /**
180 1
     * {@inheritDoc}
181
     */
182 1
    public function getDefaultValueConstantName()
183
    {
184
        return $this->betterReflectionParameter->getDefaultValueConstantName();
185
    }
186
187
    /**
188 1
     * {@inheritDoc}
189
     */
190 1
    public function hasType()
191
    {
192
        return $this->betterReflectionParameter->hasType();
193
    }
194
195
    /**
196 1
     * {@inheritDoc}
197
     */
198 1
    public function getType()
199
    {
200
        return ReflectionType::fromReturnTypeOrNull($this->betterReflectionParameter->getType());
201
    }
202
}
203