icy2003 /
php
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Class Mobile |
||
| 4 | * |
||
| 5 | * @link https://www.icy2003.com/ |
||
| 6 | * @author icy2003 <[email protected]> |
||
| 7 | * @copyright Copyright (c) 2017, icy2003 |
||
| 8 | */ |
||
| 9 | namespace icy2003\php\iapis; |
||
| 10 | |||
| 11 | use icy2003\php\I; |
||
| 12 | use icy2003\php\ihelpers\Http; |
||
| 13 | use icy2003\php\ihelpers\Json; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * 手机号相关接口 |
||
| 17 | */ |
||
| 18 | class Mobile extends Api |
||
| 19 | { |
||
| 20 | /** |
||
| 21 | * 查询手机归属地 |
||
| 22 | * |
||
| 23 | * @param string $number 手机号码 |
||
| 24 | * |
||
| 25 | * @return static |
||
| 26 | */ |
||
| 27 | public function fetchAttribution($number) |
||
| 28 | { |
||
| 29 | $this->_result = Json::get(Http::get('https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php', [ |
||
|
0 ignored issues
–
show
|
|||
| 30 | 'resource_name' => 'guishudi', |
||
| 31 | 'query' => $number, |
||
| 32 | 'oe' => 'utf8', |
||
| 33 | ]), 'data.0', []); |
||
| 34 | $this->_toArrayCall = function ($array) { |
||
| 35 | return [ |
||
| 36 | 'province' => I::get($array, 'prov'), |
||
| 37 | 'city' => I::get($array, 'city'), |
||
| 38 | 'type' => I::get($array, 'type'), |
||
| 39 | ]; |
||
| 40 | }; |
||
| 41 | |||
| 42 | return $this; |
||
| 43 | } |
||
| 44 | } |
||
| 45 |
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.