1 | <?php |
||
20 | class MetadataCollector |
||
21 | { |
||
22 | /** |
||
23 | * @var DocumentFinder |
||
24 | */ |
||
25 | private $finder; |
||
26 | |||
27 | /** |
||
28 | * @var DocumentParser |
||
29 | */ |
||
30 | private $parser; |
||
31 | |||
32 | /** |
||
33 | * @var CacheProvider |
||
34 | */ |
||
35 | private $cache = null; |
||
36 | |||
37 | /** |
||
38 | * @var bool |
||
39 | */ |
||
40 | private $enableCache = false; |
||
41 | |||
42 | /** |
||
43 | * Bundles mappings local cache container. Could be stored as the whole bundle or as single document. |
||
44 | * e.g. AcmeDemoBundle, AcmeDemoBundle:Product. |
||
45 | * |
||
46 | * @var mixed |
||
47 | */ |
||
48 | private $mappings = []; |
||
49 | |||
50 | /** |
||
51 | * @param DocumentFinder $finder For finding documents. |
||
52 | * @param DocumentParser $parser For reading document annotations. |
||
53 | * @param CacheProvider $cache Cache provider to store the meta data for later use. |
||
54 | */ |
||
55 | public function __construct($finder, $parser, $cache = null) |
||
65 | |||
66 | /** |
||
67 | * Enables metadata caching. |
||
68 | * |
||
69 | * @param bool $enableCache |
||
70 | */ |
||
71 | public function setEnableCache($enableCache) |
||
75 | |||
76 | /** |
||
77 | * Fetches bundles mapping from documents. |
||
78 | * |
||
79 | * @param string[] $bundles Elasticsearch manager config. You can get bundles list from 'mappings' node. |
||
80 | * @return array |
||
81 | */ |
||
82 | public function getMappings(array $bundles) |
||
102 | |||
103 | /** |
||
104 | * Searches for documents in the bundle and tries to read them. |
||
105 | * |
||
106 | * @param string $name |
||
107 | * |
||
108 | * @return array Empty array on containing zero documents. |
||
109 | */ |
||
110 | public function getBundleMapping($name) |
||
179 | |||
180 | /** |
||
181 | * @param array $manager |
||
182 | * |
||
183 | * @return array |
||
184 | */ |
||
185 | public function getManagerTypes($manager) |
||
191 | |||
192 | /** |
||
193 | * Resolves document elasticsearch type, use format: SomeBarBundle:AcmeDocument. |
||
194 | * |
||
195 | * @param string $document |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | public function getDocumentType($document) |
||
205 | |||
206 | /** |
||
207 | * Retrieves document mapping by namespace. |
||
208 | * |
||
209 | * @param string $namespace Document namespace. |
||
210 | * |
||
211 | * @return array|null |
||
212 | */ |
||
213 | public function getMappingByNamespace($namespace) |
||
224 | |||
225 | /** |
||
226 | * Retrieves prepared mapping to sent to the elasticsearch client. |
||
227 | * |
||
228 | * @param array $bundles Manager config. |
||
229 | * |
||
230 | * @return array |
||
231 | */ |
||
232 | public function getClientMapping(array $bundles) |
||
256 | |||
257 | /** |
||
258 | * Gathers annotation data from class. |
||
259 | * |
||
260 | * @param \ReflectionClass $reflectionClass Document reflection class to read mapping from. |
||
261 | * |
||
262 | * @return array |
||
263 | */ |
||
264 | private function getDocumentReflectionMapping(\ReflectionClass $reflectionClass) |
||
268 | |||
269 | /** |
||
270 | * Retrieves mapping from document. |
||
271 | * |
||
272 | * @param DocumentInterface $document |
||
273 | * |
||
274 | * @return array |
||
275 | */ |
||
276 | public function getDocumentMapping(DocumentInterface $document) |
||
280 | |||
281 | /** |
||
282 | * Returns mapping with metadata. |
||
283 | * |
||
284 | * @param string $namespace Bundle or document namespace. |
||
285 | * |
||
286 | * @return array |
||
287 | */ |
||
288 | public function getMapping($namespace) |
||
297 | |||
298 | /** |
||
299 | * Adds metadata information to the cache storage. |
||
300 | * |
||
301 | * @param string $bundle |
||
302 | * @param array $mapping |
||
303 | */ |
||
304 | private function cacheBundle($bundle, array $mapping) |
||
311 | |||
312 | /** |
||
313 | * returns the namespace declared at the start of a file |
||
314 | * @param $filepath |
||
315 | * @return bool |
||
316 | */ |
||
317 | private function getFileNamespace($filepath) { |
||
325 | } |
||
326 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.