cmd = $cmd; $this->path = $path; } /** * @inheritdoc * @see \pharext\SourceDir::getBaseDir() */ public function getBaseDir() { return $this->path; } /** * Generate a list of files by `git ls-files` * @return Generator */ private function generateFiles() { $pwd = getcwd(); chdir($this->path); if (($pipe = popen("git ls-files", "r"))) { while (!feof($pipe)) { if (strlen($file = trim(fgets($pipe)))) { if ($this->cmd->getArgs()->verbose) { $this->cmd->info("Packaging %s\n", $file); } if (!($realpath = realpath($file))) { $this->cmd->error("File %s does not exist\n", $file); } yield $realpath; } } pclose($pipe); } chdir($pwd); } /** * Implements IteratorAggregate * @see IteratorAggregate::getIterator() */ public function getIterator() { return $this->generateFiles(); } }