1 | <?php |
||
27 | class Relativize extends AbstractUriModifier |
||
28 | { |
||
29 | use UriFilter; |
||
30 | |||
31 | /** |
||
32 | * New instance |
||
33 | * |
||
34 | * @param Uri|UriInterface $uri |
||
35 | */ |
||
36 | 93 | public function __construct($uri) |
|
40 | |||
41 | /** |
||
42 | * Return a Uri object modified according to the modifier |
||
43 | * |
||
44 | * @param Uri|UriInterface $payload |
||
45 | * |
||
46 | * @return Uri|UriInterface |
||
47 | */ |
||
48 | 93 | public function __invoke($payload) |
|
54 | |||
55 | /** |
||
56 | * Resolve the payload URI |
||
57 | * |
||
58 | * @param Uri|UriInterface $payload |
||
59 | * |
||
60 | * @return Uri|UriInterface |
||
61 | */ |
||
62 | 93 | protected function relativizeUri($payload) |
|
81 | |||
82 | /** |
||
83 | * Relative the URI for a authority-less payload URI |
||
84 | * |
||
85 | * @param string $targetPath |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | 60 | protected function relativizePath($targetPath) |
|
112 | |||
113 | /** |
||
114 | * returns the path segments |
||
115 | * |
||
116 | * @param string $path |
||
117 | * |
||
118 | * @return array |
||
119 | */ |
||
120 | 60 | protected function getSegments($path) |
|
128 | |||
129 | /** |
||
130 | * Post formatting the path to keep a valid URI |
||
131 | * |
||
132 | * @param string $path |
||
133 | * |
||
134 | * @return string |
||
135 | */ |
||
136 | 60 | protected function formatPath($path) |
|
153 | } |
||
154 |
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.