public function findConst($fullyQualifiedName) { $this->run(); if (array_key_exists($fullyQualifiedName, $this->constCache)) { return $this->constCache[$fullyQualifiedName]; } $consts = []; foreach ($this->locators as $locator) { foreach ($locator->getPathsForConst($fullyQualifiedName) as $path) { try { /** @var Container $cont */ $cont = $this->fileStore->getFile($path); if ($cont === null) { $cont = $this->fileStore->addFile($path, $this->io->read($path)); } $file = $cont->get('reflection.file'); if ($file !== null) { $consts = array_merge($consts, $file->findConst($fullyQualifiedName)); } } catch (IOException $e) { } } } return $this->constsCache[$fullyQualifiedName] = $consts; }
/** * @internal */ public function update() { if ($this->updateQueue->isEmpty()) { return; } list($path, $deleted) = $this->updateQueue->dequeue(); try { $contents = $deleted ? '' : $this->io->read($path); /** @var Container */ $cont = $this->factory->createIndexerContainer($this->project, $path, $contents); $components = $cont->getByTag('index_data'); /** @var IndexDataInterface $indexData */ foreach ($components as $indexData) { $key = $indexData->getKey(); if (!isset($this->data['data'][$key])) { $this->data['data'][$key] = []; } $indexData->update($this->data['data'][$key]); } if ($deleted) { unset($this->data['files'][$path]); } else { $this->data['files'][$path] = $this->io->getMTime($path); } $this->logger->info("Indexed " . $path); } catch (IOException $e) { $this->logger->notice("Can't index " . $path . ": " . $e->getMessage(), ['exception' => $e]); } catch (\Exception $e) { $this->logger->notice("Can't index " . $path . ": " . $e->getMessage(), ['exception' => $e]); } catch (\Error $e) { // PHP7 $this->logger->notice("Can't index " . $path . ": " . $e->getMessage(), ['exception' => $e]); } if (!$this->updateQueue->isEmpty()) { $this->loop->futureTick([$this, 'update']); } else { $this->updating = false; $this->saveCache(); } }