1 | <?php |
||
15 | class AssetManager implements |
||
16 | AssetFilterManagerAwareInterface, |
||
17 | AssetCacheManagerAwareInterface |
||
18 | { |
||
19 | /** |
||
20 | * @var ResolverInterface |
||
21 | */ |
||
22 | protected $resolver; |
||
23 | |||
24 | /** |
||
25 | * @var AssetFilterManager The AssetFilterManager service. |
||
26 | */ |
||
27 | protected $filterManager; |
||
28 | |||
29 | /** |
||
30 | * @var AssetCacheManager The AssetCacheManager service. |
||
31 | */ |
||
32 | protected $cacheManager; |
||
33 | |||
34 | /** |
||
35 | * @var AssetInterface The asset |
||
36 | */ |
||
37 | protected $asset; |
||
38 | |||
39 | /** |
||
40 | * @var string The requested path |
||
41 | */ |
||
42 | protected $path; |
||
43 | |||
44 | /** |
||
45 | * @var array The asset_manager configuration |
||
46 | */ |
||
47 | protected $config; |
||
48 | |||
49 | /** |
||
50 | * @var bool Whether this instance has at least one asset successfully set on response |
||
51 | */ |
||
52 | protected $assetSetOnResponse = false; |
||
53 | |||
54 | /** |
||
55 | * Constructor |
||
56 | * |
||
57 | * @param ResolverInterface $resolver |
||
58 | * @param array $config |
||
59 | */ |
||
60 | public function __construct($resolver, $config = array()) |
||
65 | |||
66 | /** |
||
67 | * Set the config |
||
68 | * |
||
69 | * @param array $config |
||
70 | */ |
||
71 | protected function setConfig(array $config) |
||
75 | |||
76 | /** |
||
77 | * Check if the request resolves to an asset. |
||
78 | * |
||
79 | * @param ServerRequestInterface $request |
||
80 | * @return boolean |
||
81 | */ |
||
82 | public function resolvesToAsset(ServerRequestInterface $request) |
||
90 | |||
91 | /** |
||
92 | * Returns true if this instance of asset manager has at least one asset successfully set on response |
||
93 | * |
||
94 | * @return bool |
||
95 | */ |
||
96 | public function assetSetOnResponse() |
||
100 | |||
101 | /** |
||
102 | * Set the resolver to use in the asset manager |
||
103 | * |
||
104 | * @param ResolverInterface $resolver |
||
105 | */ |
||
106 | public function setResolver(ResolverInterface $resolver) |
||
110 | |||
111 | /** |
||
112 | * Get the resolver used by the asset manager |
||
113 | * |
||
114 | * @return ResolverInterface |
||
115 | */ |
||
116 | public function getResolver() |
||
120 | |||
121 | /** |
||
122 | * Set the asset on the response, including headers and content. |
||
123 | * |
||
124 | * @param ResponseInterface $response |
||
125 | * @return ResponseInterface |
||
126 | * @throws Exception\RuntimeException |
||
127 | */ |
||
128 | public function setAssetOnResponse(ResponseInterface $response) |
||
184 | |||
185 | /** |
||
186 | * Resolve the request to a file. |
||
187 | * |
||
188 | * @param ServerRequestInterface $request |
||
189 | * |
||
190 | * @return mixed false when not found, AssetInterface when resolved. |
||
191 | */ |
||
192 | protected function resolve(ServerRequestInterface $request) |
||
205 | |||
206 | /** |
||
207 | * Normalize the path |
||
208 | * |
||
209 | * @param $path |
||
210 | * |
||
211 | * @return string |
||
212 | */ |
||
213 | protected function normalizePath($path) |
||
217 | |||
218 | /** |
||
219 | * Set the AssetFilterManager. |
||
220 | * |
||
221 | * @param AssetFilterManager $filterManager |
||
222 | */ |
||
223 | public function setAssetFilterManager(AssetFilterManager $filterManager) |
||
227 | |||
228 | /** |
||
229 | * Get the AssetFilterManager |
||
230 | * |
||
231 | * @return AssetFilterManager |
||
232 | */ |
||
233 | public function getAssetFilterManager() |
||
237 | |||
238 | /** |
||
239 | * Set the AssetCacheManager. |
||
240 | * |
||
241 | * @param AssetCacheManager $cacheManager |
||
242 | */ |
||
243 | public function setAssetCacheManager(AssetCacheManager $cacheManager) |
||
247 | |||
248 | /** |
||
249 | * Get the AssetCacheManager |
||
250 | * |
||
251 | * @return AssetCacheManager |
||
252 | */ |
||
253 | public function getAssetCacheManager() |
||
257 | } |
||
258 |
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.