Completed
Push — master ( b0bce0...c1c6ff )
by ignace nyamagana
04:32
created

src/Modifiers/Filters/Uri.php (2 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
 * League.Uri (http://uri.thephpleague.com)
4
 *
5
 * @package   League.uri
6
 * @author    Ignace Nyamagana Butera <[email protected]>
7
 * @copyright 2013-2015 Ignace Nyamagana Butera
8
 * @license   https://github.com/thephpleague/uri/blob/master/LICENSE (MIT License)
9
 * @version   4.2.0
10
 * @link      https://github.com/thephpleague/uri/
11
 */
12
namespace League\Uri\Modifiers\Filters;
13
14
use League\Uri\Interfaces\Uri as LeagueUriInterface;
15
use League\Uri\Types\ValidatorTrait;
16
use Psr\Http\Message\UriInterface;
17
18
/**
19
 * Uri Parameter validation
20
 *
21
 * @package League.uri
22
 * @author  Ignace Nyamagana Butera <[email protected]>
23
 * @since   4.0.0
24
 * @internal
25
 */
26
trait Uri
27
{
28
    use ValidatorTrait;
29
30
    /**
31
     * The list of keys to remove
32
     *
33
     * @var LeagueUriInterface|UriInterface
34
     */
35
    protected $uri;
36
37
    /**
38
     * Return a new instance with a new set of keys
39
     *
40
     * DEPRECATION WARNING! This method will be removed in the next major point release
41
     *
42
     * @deprecated deprecated since version 4.1
43
     *
44
     * @param LeagueUriInterface|UriInterface $uri The Uri Object
45
     *
46
     * @return $this
47
     */
48
    public function withUri($uri)
49
    {
50
        $clone = clone $this;
51
        $clone->uri = $this->filterUri($uri);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->filterUri($uri) can also be of type object<League\Uri\Interfaces\Uri>. However, the property $uri is declared as type object<Psr\Http\Message\UriInterface>. 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...
Deprecated Code introduced by
The method League\Uri\Modifiers\Filters\Uri::filterUri() has been deprecated with message: deprecated since version 4.2

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
52
53
        return $clone;
54
    }
55
56
    /**
57
     * Validate the submitted keys
58
     *
59
     * DEPRECATION WARNING! This method will be removed in the next major point release
60
     *
61
     * @deprecated deprecated since version 4.2
62
     *
63
     * @param LeagueUriInterface|UriInterface $uri The Uri Object
64
     *
65
     * @return LeagueUriInterface|UriInterface
66
     */
67
    protected function filterUri($uri)
68
    {
69
        $this->assertUriObject($uri);
70
71
        return $uri;
72
    }
73
}
74