1 | <?php |
||
24 | class Route implements RouteInterface |
||
25 | { |
||
26 | /** |
||
27 | * Route Http Method |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $method; |
||
32 | |||
33 | /** |
||
34 | * Route Path Pattern |
||
35 | * |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $pattern; |
||
39 | |||
40 | /** |
||
41 | * Route Handler |
||
42 | * |
||
43 | * @var string|\Closure |
||
44 | */ |
||
45 | protected $handler; |
||
46 | |||
47 | /** |
||
48 | * Route Names |
||
49 | * |
||
50 | * @var array $routeNames |
||
51 | */ |
||
52 | protected $names; |
||
53 | |||
54 | /** |
||
55 | * Create a new route. |
||
56 | * |
||
57 | * @param string|array $method Route Http Method |
||
58 | * @param string $pattern Route Path / Pattern |
||
59 | * @param string|\Closure $handler Route Handler. |
||
60 | * @param array $names Route Names |
||
61 | */ |
||
62 | 30 | public function __construct($method, $pattern, $handler, array $names = []) |
|
69 | |||
70 | /** |
||
71 | * @inheritdoc |
||
72 | */ |
||
73 | 1 | public function withMethod($method = '') |
|
79 | |||
80 | /** |
||
81 | * @inheritdoc |
||
82 | */ |
||
83 | 3 | public function withHandler($handler) |
|
89 | |||
90 | /** |
||
91 | * @inheritdoc |
||
92 | */ |
||
93 | 1 | public function withPattern($pattern = '') |
|
99 | |||
100 | /** |
||
101 | * @inheritdoc |
||
102 | */ |
||
103 | 1 | public function withNames(array $name = []) |
|
109 | |||
110 | /** |
||
111 | * @inheritdoc |
||
112 | */ |
||
113 | 12 | public function getMethod() |
|
117 | |||
118 | /** |
||
119 | * @inheritdoc |
||
120 | */ |
||
121 | 3 | public function getHandler() |
|
125 | |||
126 | /** |
||
127 | * @inheritdoc |
||
128 | */ |
||
129 | 2 | public function getHandlerType() |
|
133 | |||
134 | /** |
||
135 | * @inheritdoc |
||
136 | */ |
||
137 | 6 | public function getPattern() |
|
141 | |||
142 | /** |
||
143 | * @inheritdoc |
||
144 | */ |
||
145 | 2 | public function getNames() |
|
149 | } |
||
150 |
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 theid
property of an instance of theAccount
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.