1 | <?php |
||
9 | class Preview |
||
10 | { |
||
11 | /** |
||
12 | * body from guzzle request |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $result; |
||
16 | |||
17 | /** |
||
18 | * Guzzle client |
||
19 | * @var \GuzzleHttp\Client |
||
20 | */ |
||
21 | protected $client; |
||
22 | |||
23 | /** |
||
24 | * PHPQuery document object that will be used to select elements |
||
25 | * @var \Jclyons52\PHPQuery\Document |
||
26 | */ |
||
27 | public $document; |
||
28 | |||
29 | /** |
||
30 | * reference to the url parameter the user passes into the fetch method |
||
31 | * @var string |
||
32 | */ |
||
33 | public $url; |
||
34 | |||
35 | /** |
||
36 | * destructured array of url components from parse_url |
||
37 | * @var array |
||
38 | */ |
||
39 | protected $urlComponents; |
||
40 | |||
41 | 33 | public function __construct(Client $client) |
|
45 | |||
46 | /** |
||
47 | * @param string $url |
||
48 | * @return Document |
||
49 | */ |
||
50 | 33 | public function fetch($url) |
|
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | 6 | public function title() |
|
72 | |||
73 | /** |
||
74 | * @return mixed |
||
75 | */ |
||
76 | 3 | public function metaKeywords() |
|
87 | |||
88 | /** |
||
89 | * @param string $element |
||
90 | * @return array |
||
91 | */ |
||
92 | 18 | public function meta($element = null) |
|
114 | |||
115 | /** |
||
116 | * get source attributes of all image tags on the page |
||
117 | * @return array<String> |
||
118 | */ |
||
119 | 13 | public function images() |
|
129 | |||
130 | /** |
||
131 | * returns a string of the link preview html |
||
132 | * @param string $type template name to be selected |
||
133 | * @param string $viewPath path to templates folder |
||
134 | * @return string html for link preview |
||
135 | */ |
||
136 | 9 | public function render($type = 'media', $viewPath = null) |
|
163 | |||
164 | /** |
||
165 | * @param string $url |
||
166 | * @return string |
||
167 | */ |
||
168 | 12 | private function formatUrl($url) |
|
180 | } |
||
181 |
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.