Issues (201)

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/Api/Php/Argument.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
/*
4
 * This file is part of the puli/manager package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Manager\Api\Php;
13
14
use Webmozart\Assert\Assert;
15
16
/**
17
 * An argument of a {@link Method}.
18
 *
19
 * @since  1.0
20
 *
21
 * @author Bernhard Schussek <[email protected]>
22
 */
23
class Argument
24
{
25
    /**
26
     * @var string
27
     */
28
    private $name;
29
30
    /**
31
     * @var string|null
32
     */
33
    private $typeHint;
34
35
    /**
36
     * @var string
37
     */
38
    private $type = 'mixed';
39
40
    /**
41
     * @var string
42
     */
43
    private $description;
44
45
    /**
46
     * @var string
47
     */
48
    private $defaultValue;
49
50
    /**
51
     * Creates a new argument.
52
     *
53
     * @param string $name The name of the argument.
54
     */
55 69
    public function __construct($name)
56
    {
57 69
        Assert::stringNotEmpty($name, 'The argument name must be a non-empty string. Got: %s');
58
59 69
        $this->name = $name;
60 69
    }
61
62
    /**
63
     * Returns the name of the argument.
64
     *
65
     * @return string The argument name.
66
     */
67 46
    public function getName()
68
    {
69 46
        return $this->name;
70
    }
71
72
    /**
73
     * Returns the type hint of the argument.
74
     *
75
     * @return string|null The type hint or `null` if the argument has no type
76
     *                     hint.
77
     */
78 2
    public function getTypeHint()
79
    {
80 2
        return $this->typeHint;
81
    }
82
83
    /**
84
     * Returns whether the argument has a type hint.
85
     *
86
     * @return bool Returns `true` if the argument has a type hint and `false`
87
     *              otherwise.
88
     */
89 1
    public function hasTypeHint()
90
    {
91 1
        return null !== $this->typeHint;
92
    }
93
94
    /**
95
     * Sets the type hint of the argument.
96
     *
97
     * @param string $typeHint The type hint.
98
     *
99
     * @return static The current instance.
100
     */
101 35
    public function setTypeHint($typeHint)
102
    {
103 35
        Assert::stringNotEmpty($typeHint, 'The argument type hint must be a non-empty string. Got: %s');
104
105 32
        $this->typeHint = $typeHint;
106
107 32
        return $this;
108
    }
109
110
    /**
111
     * Removes the type hint of the argument.
112
     *
113
     * @return static The current instance.
114
     */
115 2
    public function removeTypeHint()
116
    {
117 2
        $this->typeHint = null;
118
119 2
        return $this;
120
    }
121
122
    /**
123
     * Returns the type of the argument.
124
     *
125
     * @return string The argument type.
126
     */
127 30
    public function getType()
128
    {
129 30
        return $this->type;
130
    }
131
132
    /**
133
     * Sets the type of the argument.
134
     *
135
     * @param string $type The argument type.
136
     *
137
     * @return static The current instance.
138
     */
139 33
    public function setType($type)
140
    {
141 33
        Assert::stringNotEmpty($type, 'The argument type must be a non-empty string. Got: %s');
142
143 30
        $this->type = $type;
144
145 30
        return $this;
146
    }
147
148
    /**
149
     * Returns the description of the argument.
150
     *
151
     * @return string The argument description.
152
     */
153 30
    public function getDescription()
154
    {
155 30
        return $this->description;
156
    }
157
158
    /**
159
     * Sets the description of the argument.
160
     *
161
     * @param string $description The argument description.
162
     *
163
     * @return static The current instance.
164
     */
165 33
    public function setDescription($description)
166
    {
167 33
        Assert::stringNotEmpty($description, 'The argument description must be a non-empty string. Got: %s');
168
169 30
        $this->description = $description;
170
171 30
        return $this;
172
    }
173
174
    /**
175
     * Returns the default value of the argument.
176
     *
177
     * @return string|null The default value as source code or `null` if the
178
     *                     argument has no default value.
179
     */
180 2
    public function getDefaultValue()
181
    {
182 2
        return $this->defaultValue;
183
    }
184
185
    /**
186
     * Sets the default value of the argument.
187
     *
188
     * @param string $defaultValue The default value as source code.
189
     *
190
     * @return static The current instance.
191
     */
192 7
    public function setDefaultValue($defaultValue)
193
    {
194 7
        Assert::stringNotEmpty($defaultValue, 'The argument default value must be a non-empty string. Got: %s');
195
196 4
        $this->defaultValue = $defaultValue;
197
198 4
        return $this;
199
    }
200
201
    /**
202
     * Returns whether the argument has a default value.
203
     *
204
     * @return bool Returns `true` if the argument has a default value and
205
     *              `false` otherwise.
206
     */
207 1
    public function hasDefaultValue()
208
    {
209 1
        return null !== $this->defaultValue;
210
    }
211
212
    /**
213
     * Removes the default value of the argument.
214
     *
215
     * If the argument has no default value, this method does nothing.
216
     *
217
     * @return static The current instance.
218
     */
219 2
    public function removeDefaultValue()
220
    {
221 2
        $this->defaultValue = null;
222
223 2
        return $this;
224
    }
225
226
    /**
227
     * Returns the source code of the argument.
228
     *
229
     * @return string The source code.
230
     */
231 29
    public function __toString()
232
    {
233 29
        $string = '$'.$this->name;
234
235 29
        if ($this->typeHint) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->typeHint of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
236 22
            $string = $this->typeHint.' '.$string;
237
        }
238
239 29
        if ($this->defaultValue) {
240 1
            $string .= ' = '.$this->defaultValue;
241
        }
242
243 29
        return $string;
244
    }
245
}
246