Ejemplo n.º 1
0
 public function build()
 {
     $this->prepareTemp();
     /* Dateien ins Temp-Verzeichnis kopieren */
     $class2path = array();
     $relDir = $this->classPath->up();
     // wir wollen ja den Namespace als erstes Verzeichnis haben
     foreach ($this->getClassFiles() as $file) {
         $class = $this->inferClassName($file);
         // $class2path[ $class ] = $fileURL;
         $class2path[ltrim($class, '\\')] = $url = $file->getURL($relDir);
         // statt hier Code::mapClassToFile() zu machen nehmen wir die url
         $targetFile = File::createFromURL($url, $this->tempSrc);
         $targetFile->getDirectory()->create();
         $this->log(str_pad('Add: ' . $url, 80, ' ', STR_PAD_RIGHT) . " [" . $class . "]", 2);
         $file->copy($targetFile);
     }
     foreach ($this->additionalFiles as $list) {
         list($file, $fileInPhar) = $list;
         $targetFile = new File($this->tempSrc . $fileInPhar);
         $targetFile->getDirectory()->create();
         $this->log('Add: ' . $fileInPhar);
         $file->copy($targetFile);
     }
     /* Bootstrapping */
     $bootstrapCode = $this->getBootstrapCode($class2path);
     $bootstrapFile = new File($this->tempSrc, 'index.php');
     $bootstrapFile->writeContents($bootstrapCode);
     /* Build */
     try {
         $tmp = File::createTemporary();
         $tmp->setExtension('phar.gz');
         $this->phar = new PHPPhar((string) $tmp);
         $this->phar->compress(PHPPHAR::GZ);
         $this->phar->startBuffering();
         $this->phar->buildFromDirectory($this->tempSrc);
         $this->phar->stopBuffering();
         $this->tempSrc->delete();
         $this->out->delete();
         $tmp->copy($this->out);
     } catch (\Exception $e) {
         $this->tempSrc->delete();
         throw $e;
     }
 }
Ejemplo n.º 2
0
 public function testConstruct_setsUnderscoreStyle()
 {
     $phar = new Phar($this->newFile('out.php'), $this->getTestDirectory(), 'PHPWord_');
     $this->assertTrue($phar->getUnderscoreStyle());
 }