GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( c2e867...855438 )
by Patrique
05:00
created

Uri::getUserInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Patoui\Router;
6
7
use Psr\Http\Message\UriInterface;
8
9
class Uri implements UriInterface
10
{
11
    /** @var string */
12
    private $scheme;
13
14
    /** @var string */
15
    private $host;
16
17
    /** @var string */
18
    private $port;
19
20
    /** @var string */
21
    private $user;
22
23
    /** @var string */
24
    private $path;
25
26
    /** @var string */
27
    private $query;
28
29
    /** @var string */
30
    private $fragment;
31
32
    public function __construct(string $uri)
33
    {
34
        $this->scheme = parse_url($uri, PHP_URL_SCHEME);
0 ignored issues
show
Documentation Bug introduced by
It seems like parse_url($uri, PHP_URL_SCHEME) can also be of type false. However, the property $scheme is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

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

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
35
        $this->host = parse_url($uri, PHP_URL_HOST);
0 ignored issues
show
Documentation Bug introduced by
It seems like parse_url($uri, PHP_URL_HOST) can also be of type false. However, the property $host is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

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

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
36
        $this->port = (int) parse_url($uri, PHP_URL_PORT);
0 ignored issues
show
Documentation Bug introduced by
The property $port was declared of type string, but (int) parse_url($uri, PHP_URL_PORT) is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
37
        $this->user = parse_url($uri, PHP_URL_USER);
0 ignored issues
show
Documentation Bug introduced by
It seems like parse_url($uri, PHP_URL_USER) can also be of type false. However, the property $user is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

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

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
38
        $this->path = parse_url($uri, PHP_URL_PASS);
0 ignored issues
show
Documentation Bug introduced by
It seems like parse_url($uri, PHP_URL_PASS) can also be of type false. However, the property $path is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

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

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
39
        $this->query = parse_url($uri, PHP_URL_QUERY);
0 ignored issues
show
Documentation Bug introduced by
It seems like parse_url($uri, PHP_URL_QUERY) can also be of type false. However, the property $query is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

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

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
40
        $this->fragment = parse_url($uri, PHP_URL_FRAGMENT);
0 ignored issues
show
Documentation Bug introduced by
It seems like parse_url($uri, PHP_URL_FRAGMENT) can also be of type false. However, the property $fragment is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

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

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
41
    }
42
43
    /**
44
     * Retrieve the scheme component of the URI.
45
     *
46
     * If no scheme is present, this method MUST return an empty string.
47
     *
48
     * The value returned MUST be normalized to lowercase, per RFC 3986
49
     * Section 3.1.
50
     *
51
     * The trailing ":" character is not part of the scheme and MUST NOT be
52
     * added.
53
     *
54
     * @see https://tools.ietf.org/html/rfc3986#section-3.1
55
     * @return string The URI scheme.
56
     */
57
    public function getScheme()
58
    {
59
        // TODO: Implement getScheme() method.
60
    }
61
62
    /**
63
     * Retrieve the authority component of the URI.
64
     *
65
     * If no authority information is present, this method MUST return an empty
66
     * string.
67
     *
68
     * The authority syntax of the URI is:
69
     *
70
     * <pre>
71
     * [user-info@]host[:port]
72
     * </pre>
73
     *
74
     * If the port component is not set or is the standard port for the current
75
     * scheme, it SHOULD NOT be included.
76
     *
77
     * @see https://tools.ietf.org/html/rfc3986#section-3.2
78
     * @return string The URI authority, in "[user-info@]host[:port]" format.
79
     */
80
    public function getAuthority()
81
    {
82
        // TODO: Implement getAuthority() method.
83
    }
84
85
    /**
86
     * Retrieve the user information component of the URI.
87
     *
88
     * If no user information is present, this method MUST return an empty
89
     * string.
90
     *
91
     * If a user is present in the URI, this will return that value;
92
     * additionally, if the password is also present, it will be appended to the
93
     * user value, with a colon (":") separating the values.
94
     *
95
     * The trailing "@" character is not part of the user information and MUST
96
     * NOT be added.
97
     *
98
     * @return string The URI user information, in "username[:password]" format.
99
     */
100
    public function getUserInfo()
101
    {
102
        // TODO: Implement getUserInfo() method.
103
    }
104
105
    /**
106
     * Retrieve the host component of the URI.
107
     *
108
     * If no host is present, this method MUST return an empty string.
109
     *
110
     * The value returned MUST be normalized to lowercase, per RFC 3986
111
     * Section 3.2.2.
112
     *
113
     * @see http://tools.ietf.org/html/rfc3986#section-3.2.2
114
     * @return string The URI host.
115
     */
116
    public function getHost()
117
    {
118
        return $this->host;
119
    }
120
121
    /**
122
     * Retrieve the port component of the URI.
123
     *
124
     * If a port is present, and it is non-standard for the current scheme,
125
     * this method MUST return it as an integer. If the port is the standard port
126
     * used with the current scheme, this method SHOULD return null.
127
     *
128
     * If no port is present, and no scheme is present, this method MUST return
129
     * a null value.
130
     *
131
     * If no port is present, but a scheme is present, this method MAY return
132
     * the standard port for that scheme, but SHOULD return null.
133
     *
134
     * @return null|int The URI port.
135
     */
136
    public function getPort()
137
    {
138
        // TODO: Implement getPort() method.
139
    }
140
141
    /**
142
     * Retrieve the path component of the URI.
143
     *
144
     * The path can either be empty or absolute (starting with a slash) or
145
     * rootless (not starting with a slash). Implementations MUST support all
146
     * three syntaxes.
147
     *
148
     * Normally, the empty path "" and absolute path "/" are considered equal as
149
     * defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically
150
     * do this normalization because in contexts with a trimmed base path, e.g.
151
     * the front controller, this difference becomes significant. It's the task
152
     * of the user to handle both "" and "/".
153
     *
154
     * The value returned MUST be percent-encoded, but MUST NOT double-encode
155
     * any characters. To determine what characters to encode, please refer to
156
     * RFC 3986, Sections 2 and 3.3.
157
     *
158
     * As an example, if the value should include a slash ("/") not intended as
159
     * delimiter between path segments, that value MUST be passed in encoded
160
     * form (e.g., "%2F") to the instance.
161
     *
162
     * @see https://tools.ietf.org/html/rfc3986#section-2
163
     * @see https://tools.ietf.org/html/rfc3986#section-3.3
164
     * @return string The URI path.
165
     */
166
    public function getPath()
167
    {
168
        // TODO: Implement getPath() method.
169
    }
170
171
    /**
172
     * Retrieve the query string of the URI.
173
     *
174
     * If no query string is present, this method MUST return an empty string.
175
     *
176
     * The leading "?" character is not part of the query and MUST NOT be
177
     * added.
178
     *
179
     * The value returned MUST be percent-encoded, but MUST NOT double-encode
180
     * any characters. To determine what characters to encode, please refer to
181
     * RFC 3986, Sections 2 and 3.4.
182
     *
183
     * As an example, if a value in a key/value pair of the query string should
184
     * include an ampersand ("&") not intended as a delimiter between values,
185
     * that value MUST be passed in encoded form (e.g., "%26") to the instance.
186
     *
187
     * @see https://tools.ietf.org/html/rfc3986#section-2
188
     * @see https://tools.ietf.org/html/rfc3986#section-3.4
189
     * @return string The URI query string.
190
     */
191
    public function getQuery()
192
    {
193
        // TODO: Implement getQuery() method.
194
    }
195
196
    /**
197
     * Retrieve the fragment component of the URI.
198
     *
199
     * If no fragment is present, this method MUST return an empty string.
200
     *
201
     * The leading "#" character is not part of the fragment and MUST NOT be
202
     * added.
203
     *
204
     * The value returned MUST be percent-encoded, but MUST NOT double-encode
205
     * any characters. To determine what characters to encode, please refer to
206
     * RFC 3986, Sections 2 and 3.5.
207
     *
208
     * @see https://tools.ietf.org/html/rfc3986#section-2
209
     * @see https://tools.ietf.org/html/rfc3986#section-3.5
210
     * @return string The URI fragment.
211
     */
212
    public function getFragment()
213
    {
214
        // TODO: Implement getFragment() method.
215
    }
216
217
    /**
218
     * Return an instance with the specified scheme.
219
     *
220
     * This method MUST retain the state of the current instance, and return
221
     * an instance that contains the specified scheme.
222
     *
223
     * Implementations MUST support the schemes "http" and "https" case
224
     * insensitively, and MAY accommodate other schemes if required.
225
     *
226
     * An empty scheme is equivalent to removing the scheme.
227
     *
228
     * @param  string  $scheme  The scheme to use with the new instance.
229
     * @return static A new instance with the specified scheme.
230
     * @throws \InvalidArgumentException for invalid or unsupported schemes.
231
     */
232
    public function withScheme($scheme)
233
    {
234
        // TODO: Implement withScheme() method.
235
    }
236
237
    /**
238
     * Return an instance with the specified user information.
239
     *
240
     * This method MUST retain the state of the current instance, and return
241
     * an instance that contains the specified user information.
242
     *
243
     * Password is optional, but the user information MUST include the
244
     * user; an empty string for the user is equivalent to removing user
245
     * information.
246
     *
247
     * @param  string  $user  The user name to use for authority.
248
     * @param  null|string  $password  The password associated with $user.
249
     * @return static A new instance with the specified user information.
250
     */
251
    public function withUserInfo($user, $password = null)
252
    {
253
        // TODO: Implement withUserInfo() method.
254
    }
255
256
    /**
257
     * Return an instance with the specified host.
258
     *
259
     * This method MUST retain the state of the current instance, and return
260
     * an instance that contains the specified host.
261
     *
262
     * An empty host value is equivalent to removing the host.
263
     *
264
     * @param  string  $host  The hostname to use with the new instance.
265
     * @return static A new instance with the specified host.
266
     * @throws \InvalidArgumentException for invalid hostnames.
267
     */
268
    public function withHost($host)
269
    {
270
        // TODO: Implement withHost() method.
271
    }
272
273
    /**
274
     * Return an instance with the specified port.
275
     *
276
     * This method MUST retain the state of the current instance, and return
277
     * an instance that contains the specified port.
278
     *
279
     * Implementations MUST raise an exception for ports outside the
280
     * established TCP and UDP port ranges.
281
     *
282
     * A null value provided for the port is equivalent to removing the port
283
     * information.
284
     *
285
     * @param  null|int  $port  The port to use with the new instance; a null value
286
     *     removes the port information.
287
     * @return static A new instance with the specified port.
288
     * @throws \InvalidArgumentException for invalid ports.
289
     */
290
    public function withPort($port)
291
    {
292
        // TODO: Implement withPort() method.
293
    }
294
295
    /**
296
     * Return an instance with the specified path.
297
     *
298
     * This method MUST retain the state of the current instance, and return
299
     * an instance that contains the specified path.
300
     *
301
     * The path can either be empty or absolute (starting with a slash) or
302
     * rootless (not starting with a slash). Implementations MUST support all
303
     * three syntaxes.
304
     *
305
     * If the path is intended to be domain-relative rather than path relative then
306
     * it must begin with a slash ("/"). Paths not starting with a slash ("/")
307
     * are assumed to be relative to some base path known to the application or
308
     * consumer.
309
     *
310
     * Users can provide both encoded and decoded path characters.
311
     * Implementations ensure the correct encoding as outlined in getPath().
312
     *
313
     * @param  string  $path  The path to use with the new instance.
314
     * @return static A new instance with the specified path.
315
     * @throws \InvalidArgumentException for invalid paths.
316
     */
317
    public function withPath($path)
318
    {
319
        // TODO: Implement withPath() method.
320
    }
321
322
    /**
323
     * Return an instance with the specified query string.
324
     *
325
     * This method MUST retain the state of the current instance, and return
326
     * an instance that contains the specified query string.
327
     *
328
     * Users can provide both encoded and decoded query characters.
329
     * Implementations ensure the correct encoding as outlined in getQuery().
330
     *
331
     * An empty query string value is equivalent to removing the query string.
332
     *
333
     * @param  string  $query  The query string to use with the new instance.
334
     * @return static A new instance with the specified query string.
335
     * @throws \InvalidArgumentException for invalid query strings.
336
     */
337
    public function withQuery($query)
338
    {
339
        // TODO: Implement withQuery() method.
340
    }
341
342
    /**
343
     * Return an instance with the specified URI fragment.
344
     *
345
     * This method MUST retain the state of the current instance, and return
346
     * an instance that contains the specified URI fragment.
347
     *
348
     * Users can provide both encoded and decoded fragment characters.
349
     * Implementations ensure the correct encoding as outlined in getFragment().
350
     *
351
     * An empty fragment value is equivalent to removing the fragment.
352
     *
353
     * @param  string  $fragment  The fragment to use with the new instance.
354
     * @return static A new instance with the specified fragment.
355
     */
356
    public function withFragment($fragment)
357
    {
358
        // TODO: Implement withFragment() method.
359
    }
360
361
    /**
362
     * Return the string representation as a URI reference.
363
     *
364
     * Depending on which components of the URI are present, the resulting
365
     * string is either a full URI or relative reference according to RFC 3986,
366
     * Section 4.1. The method concatenates the various components of the URI,
367
     * using the appropriate delimiters:
368
     *
369
     * - If a scheme is present, it MUST be suffixed by ":".
370
     * - If an authority is present, it MUST be prefixed by "//".
371
     * - The path can be concatenated without delimiters. But there are two
372
     *   cases where the path has to be adjusted to make the URI reference
373
     *   valid as PHP does not allow to throw an exception in __toString():
374
     *     - If the path is rootless and an authority is present, the path MUST
375
     *       be prefixed by "/".
376
     *     - If the path is starting with more than one "/" and no authority is
377
     *       present, the starting slashes MUST be reduced to one.
378
     * - If a query is present, it MUST be prefixed by "?".
379
     * - If a fragment is present, it MUST be prefixed by "#".
380
     *
381
     * @see http://tools.ietf.org/html/rfc3986#section-4.1
382
     * @return string
383
     */
384
    public function __toString()
385
    {
386
        // TODO: Implement __toString() method.
387
    }
388
}
389