| 1 | <?php |
||
| 5 | class Url |
||
| 6 | { |
||
| 7 | /** @var string */ |
||
| 8 | protected $url; |
||
| 9 | |||
| 10 | /** @var array */ |
||
| 11 | protected $parts; |
||
| 12 | |||
| 13 | 4 | public function __construct($url) |
|
| 14 | { |
||
| 15 | 4 | $this->url = $url; |
|
| 16 | 4 | $this->parts = parse_url($url); |
|
|
|
|||
| 17 | 4 | } |
|
| 18 | |||
| 19 | 2 | public function __toString() |
|
| 23 | |||
| 24 | /** |
||
| 25 | * Obtener una parte de la URL. |
||
| 26 | * |
||
| 27 | * @param $part string Parte de la URL (Ej: host). |
||
| 28 | * |
||
| 29 | * @return string|null |
||
| 30 | */ |
||
| 31 | 3 | public function part($part) |
|
| 35 | |||
| 36 | /** |
||
| 37 | * Url tiene una parte. |
||
| 38 | * |
||
| 39 | * @return boolean true|false |
||
| 40 | */ |
||
| 41 | 2 | public function has($part) |
|
| 45 | |||
| 46 | /** |
||
| 47 | * Decodificación URL. |
||
| 48 | * |
||
| 49 | * @return object |
||
| 50 | */ |
||
| 51 | 1 | public function decode() |
|
| 57 | |||
| 58 | /** |
||
| 59 | * Dada una URL, normaliza esa URL. |
||
| 60 | * |
||
| 61 | * @param $schemeAndHost string Esquema y dominio base (Ej. http://example.com) |
||
| 62 | * |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | 1 | public function normalize($schemeAndHost) |
|
| 73 | } |
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
$accountIdthat can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theidproperty of an instance of theAccountclass. 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.