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; }
public function getProjectRootDir($path) { $rootDir = null; foreach (static::PROJECT_FILES as $projectFile) { $oldPath = $path; $curPath = dirname($path); while ($oldPath !== $curPath) { $projectFilePath = $curPath . '/' . $projectFile; if ($this->io->exists($projectFilePath)) { $rootDir = $curPath; } $oldPath = $curPath; $curPath = dirname($curPath); } if ($rootDir !== null) { return $rootDir; } } return null; }
protected function doRun() { $this->data = ['files' => [], 'data' => []]; $this->logger = $this->container->get('logger'); $this->io = $this->container->get('io'); $this->loop = $this->container->get('eventloop'); $this->factory = $this->container->get('factory'); $this->project = $this->container->get('project'); $this->cachePath = $this->io->getCacheDir('indexer') . '/' . sha1($this->project->getRootPath()) . '.json'; $this->updateQueue = new \SplQueue(); $this->loadCache(); $fsEvents = ['modify', 'delete', 'move_to', 'move_from']; $this->monitor = new INotifyProcessMonitor($this->project->getRootPath(), $fsEvents); $this->setupFsEvents(); $this->watch(); }
/** * Find a composer (root) package given file belongs to. * * @param string $phpFilePath * @param FileIOInterface $io * * @return ComposerPackage|null */ public static function get($phpFilePath, FileIOInterface $io) { $baseDir = null; $oldPath = $phpFilePath; $path = dirname($oldPath); while ($oldPath !== $path) { $config = $path . '/' . self::COMPOSER_CONFIG; if ($io->exists($config)) { $baseDir = $path; } $oldPath = $path; $path = dirname($path); } if ($baseDir === null) { return null; } if (array_key_exists($baseDir, self::$packages)) { return self::$packages[$baseDir]; } return self::$packages[$baseDir] = new static($baseDir); }