/**
  * @Then /^download manual from "([^"]*)" package from "([^"]*)"$/
  */
 public function downloadManualFromPackageFrom($lang, $mirror)
 {
     $this->package = new Package($lang, $mirror);
     $dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php-doc-parser-test';
     @mkdir($dir);
     $file = $dir . DIRECTORY_SEPARATOR . $this->package->getOrigFilename();
     $this->package->download($file);
     $testUnpackDir = $this->package->unpack(array_map(function ($item) {
         return $item['source-filename'];
     }, $this->testFiles));
     $this->unpackedFilesDir = $this->package->getUnpackedDir();
     assertEquals($testUnpackDir, $this->unpackedFilesDir);
     assertCount(count($this->testFiles), glob($this->unpackedFilesDir . DIRECTORY_SEPARATOR . '*.html'));
 }
 private function parse(Package $package, $outDir, $includeExamples)
 {
     $parser = new Parser();
     $bar = $this->createProgressBar(count($parser->getFilesToProcess($package->getUnpackedDir())));
     $bar->setRedrawFrequency(100);
     $bar->start();
     $results = $parser->processDir($package->getUnpackedDir(), $includeExamples, function ($filename, $total, $processed) use($bar) {
         $bar->setMessage('Processing: ' . $filename);
         $bar->advance();
     });
     $bar->finish();
     $functions = [];
     $examples = [];
     foreach ($results->getFuncNames() as $funcName) {
         $arrayRes = $results->getResult($funcName);
         $examplesRes = $results->getExamples($funcName);
         if ($examplesRes && is_array($arrayRes)) {
             if ($includeExamples == Parser::INCLUDE_EXAMPLES) {
                 $arrayRes = array_merge($arrayRes, ['examples' => $examplesRes]);
             } elseif ($includeExamples == Parser::EXPORT_EXAMPLES) {
                 $examples[$funcName] = $examplesRes;
             }
         }
         $functions[$funcName] = $arrayRes;
     }
     $this->output->writeln('');
     $this->output->writeln("Warnings: <comment>" . $results->countAllWarnings() . "</comment> (malformed UTF8 in examples)");
     $this->output->writeln("Skipped files: <comment>" . count($results->getSkipped()) . "</comment> (no function definition found)");
     $basePath = $outDir . DIRECTORY_SEPARATOR . $package->getLang() . '_' . str_replace('.', '_', $package->getMirror());
     $this->saveOutput($basePath, $functions);
     $this->output->writeln("Total functions: <info>" . count($functions) . "</info>");
     $this->saveFunctionsList($basePath, $functions);
     if ($includeExamples == Parser::EXPORT_EXAMPLES) {
         $this->saveExamples($basePath, $examples);
         $this->output->writeln("Total examples: <info>" . $results->countAllExamples() . "</info>");
     }
     if ($this->output->isVerbose()) {
         foreach ($results->getWarnings() as $funcName => $warnings) {
             $this->output->writeln("<comment>Warning in {$funcName}</comment>");
             foreach ($warnings as $warning) {
                 $this->output->writeln($warning);
             }
         }
     }
     if ($this->output->isVeryVerbose()) {
         foreach (array_keys($results->getSkipped()) as $filename) {
             $this->output->writeln("<comment>Skipped {$filename}</comment>");
         }
     }
     //        $this->output->writeln("Total: <comment>${count}</comment> examples");
 }