Completed
Push — master ( f172d4...76e139 )
by devosc
02:14
created

src/Plugin/Filter.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
 */
5
6
namespace Mvc5\Plugin;
7
8
class Filter
9
    implements Gem\Filter
10
{
11
    /**
12
     *
13
     */
14
    use Config\Args;
15
    use Config\Config;
16
17
    /**
18
     * @var array
19
     */
20
    protected $filter;
21
22
    /**
23
     * @var string
24
     */
25
    protected $param;
26
27
    /**
28
     * @param $config
29
     * @param array|\Traversable $filter
30
     * @param array $args
31
     * @param string $param
32
     */
33 14
    function __construct($config, $filter = [], array $args = [], $param = null)
34
    {
35 14
        $this->args   = $args;
36 14
        $this->config = $config;
37 14
        $this->filter = $filter;
0 ignored issues
show
Documentation Bug introduced by
It seems like $filter can also be of type object<Traversable>. However, the property $filter is declared as type array. 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 14
        $this->param  = $param;
39 14
    }
40
41
    /**
42
     * @return array|\Traversable
43
     */
44 10
    function filter()
45
    {
46 10
        return $this->filter;
47
    }
48
49
    /**
50
     * @return string
51
     */
52 10
    function param()
53
    {
54 10
        return $this->param;
55
    }
56
}
57