示例#1
0
 function __c3_build_html_report(PHP_CodeCoverage $codeCoverage, $path)
 {
     $writer = new PHP_CodeCoverage_Report_HTML();
     $writer->process($codeCoverage, $path . 'html');
     if (file_exists($path . '.tar')) {
         unlink($path . '.tar');
     }
     $phar = new PharData($path . '.tar');
     $phar->setSignatureAlgorithm(Phar::SHA1);
     $files = $phar->buildFromDirectory($path . 'html');
     array_map('unlink', $files);
     if (in_array('GZ', Phar::getSupportedCompression())) {
         if (file_exists($path . '.tar.gz')) {
             unlink($path . '.tar.gz');
         }
         $phar->compress(\Phar::GZ);
         // close the file so that we can rename it
         unset($phar);
         unlink($path . '.tar');
         rename($path . '.tar.gz', $path . '.tar');
     }
     return $path . '.tar';
 }
示例#2
0
include dirname(__FILE__) . '/files/tarmaker.php.inc';
$fname = dirname(__FILE__) . '/tar_004.phar.tar';
$alias = 'phar://' . $fname;
$fname2 = dirname(__FILE__) . '/tar_004.tar';
$tar = new tarmaker($fname, 'none');
$tar->init();
$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
$tar->addFile('internal/file/here', "hi there!\n");
$tar->addFile('.phar/stub.php', "__HALT_COMPILER();");
$tar->close();
try {
    $phar = new Phar($fname);
    var_dump($phar->getStub());
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
ini_set('phar.require_hash', 0);
try {
    $phar = new PharData($fname2);
    $phar['file'] = 'hi';
    var_dump($phar->getSignature());
    $phar->setSignatureAlgorithm(Phar::MD5);
    var_dump($phar->getSignature());
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
?>
===DONE===
<?php 
@unlink(dirname(__FILE__) . '/tar_004.phar.tar');
@unlink(dirname(__FILE__) . '/tar_004.tar');