function getPhase2Files(Config $config, OutputInterface $output, \RecursiveIteratorIterator $it2, &$toProcess) { $configArr = $config->getConfigArray(); foreach ($it2 as $file) { if ($file->getExtension() == "php" && $file->isFile()) { if (isset($configArr['test-ignore']) && is_array($configArr['test-ignore']) && Util::matchesGlobs($config->getBasePath(), $file->getPathname(), $configArr['test-ignore'])) { continue; } $toProcess[] = $file->getPathname(); } } }
function index(Config $config, OutputInterface $output, \RecursiveIteratorIterator $it2, $stubs = false) { $baseDir = $config->getBasePath(); $symbolTable = $config->getSymbolTable(); $indexer = new SymbolTableIndexer($symbolTable, $output); $traverser1 = new NodeTraverser(); $traverser1->addVisitor(new NameResolver()); $traverser2 = new NodeTraverser(); $traverser2->addVisitor($indexer); $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); $configArr = $config->getConfigArray(); $count = 0; foreach ($it2 as $file) { if (($file->getExtension() == "php" || $file->getExtension() == "inc") && $file->isFile()) { $name = Util::removeInitialPath($baseDir, $file->getPathname()); if (strpos($name, "phar://") === 0) { $name = str_replace(\Phar::running(), "", $name); while ($name[0] == '/') { $name = substr($name, 1); } $name = "phar://" . $name; } try { if (!$stubs && isset($configArr['ignore']) && is_array($configArr['ignore']) && Util::matchesGlobs($baseDir, $file->getPathname(), $configArr['ignore'])) { continue; } ++$count; $output->output(".", " - {$count}:" . $name); // If the $fileName is in our phar then make it a relative path so that files that we index don't // depend on the phar file existing in a particular directory. $fileData = file_get_contents($file->getPathname()); if ($config->shouldReindex()) { $symbolTable->removeFileFromIndex($file->getPathname()); } $indexer->setFilename($name); $stmts = $parser->parse($fileData); if ($stmts) { $traverser1->traverse($stmts); $traverser2->traverse($stmts); } } catch (Error $e) { $output->emitError(__CLASS__, $file, 0, ' Parse Error: ' . $e->getMessage() . "\n"); } } } return $count; }