]> granicus.if.org Git - php/commitdiff
Funnily enough those frontcontroller tests still pass here! Investigating...
authorSteph Fox <sfox@php.net>
Mon, 11 Feb 2008 20:55:44 +0000 (20:55 +0000)
committerSteph Fox <sfox@php.net>
Mon, 11 Feb 2008 20:55:44 +0000 (20:55 +0000)
43 files changed:
ext/phar/tests/zip/033.phpt
ext/phar/tests/zip/033a.phpt
ext/phar/tests/zip/delete.phpt
ext/phar/tests/zip/delete_in_phar.phpt
ext/phar/tests/zip/delete_in_phar_b.phpt
ext/phar/tests/zip/delete_in_phar_confirm.phpt
ext/phar/tests/zip/files/frontcontroller.phar.inc [moved from ext/phar/tests/zip/frontcontroller.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller.phar.zip [moved from ext/phar/tests/zip/frontcontroller.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller10.phar.inc [moved from ext/phar/tests/zip/frontcontroller10.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller10.phar.zip [moved from ext/phar/tests/zip/frontcontroller10.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller11.phar.inc [moved from ext/phar/tests/zip/frontcontroller11.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller11.phar.zip [moved from ext/phar/tests/zip/frontcontroller11.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller12.phar.inc [moved from ext/phar/tests/zip/frontcontroller12.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller12.phar.zip [moved from ext/phar/tests/zip/frontcontroller12.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller2.phar.inc [moved from ext/phar/tests/zip/frontcontroller2.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller2.phar.zip [moved from ext/phar/tests/zip/frontcontroller2.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller3.phar.inc [moved from ext/phar/tests/zip/frontcontroller3.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller3.phar.zip [moved from ext/phar/tests/zip/frontcontroller3.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller4.phar.inc [moved from ext/phar/tests/zip/frontcontroller4.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller4.phar.zip [moved from ext/phar/tests/zip/frontcontroller4.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller5.phar.inc [moved from ext/phar/tests/zip/frontcontroller5.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller5.phar.zip [moved from ext/phar/tests/zip/frontcontroller5.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller6.phar.inc [moved from ext/phar/tests/zip/frontcontroller6.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller6.phar.zip [moved from ext/phar/tests/zip/frontcontroller6.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller7.phar.inc [moved from ext/phar/tests/zip/frontcontroller7.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller7.phar.zip [moved from ext/phar/tests/zip/frontcontroller7.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller8.phar.inc [moved from ext/phar/tests/zip/frontcontroller8.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller8.phar.zip [moved from ext/phar/tests/zip/frontcontroller8.phar.zip with 100% similarity]
ext/phar/tests/zip/files/frontcontroller9.phar.inc [moved from ext/phar/tests/zip/frontcontroller9.phar.inc with 100% similarity]
ext/phar/tests/zip/files/frontcontroller9.phar.zip [moved from ext/phar/tests/zip/frontcontroller9.phar.zip with 100% similarity]
ext/phar/tests/zip/files/make_invalid_tar.php.inc [moved from ext/phar/tests/zip/make_invalid_tar.php.inc with 100% similarity]
ext/phar/tests/zip/files/zipmaker.php.inc [moved from ext/phar/tests/zip/tarmaker.php.inc with 51% similarity]
ext/phar/tests/zip/open_for_write_existing.phpt
ext/phar/tests/zip/open_for_write_existing_b.phpt
ext/phar/tests/zip/open_for_write_existing_c.phpt
ext/phar/tests/zip/open_for_write_newfile.phpt
ext/phar/tests/zip/open_for_write_newfile_b.phpt
ext/phar/tests/zip/open_for_write_newfile_c.phpt
ext/phar/tests/zip/phar_setalias.phpt
ext/phar/tests/zip/phar_setalias2.phpt
ext/phar/tests/zip/phar_stub_error.phpt
ext/phar/tests/zip/refcount1.phpt
ext/phar/tests/zip/rename.phpt

index 410fd56f60e3ce1bd207dfdf28b09686404d9b1c..084afaa9448fecb573a1d82dd509c0794d91c626 100644 (file)
@@ -7,31 +7,29 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
-$pname = 'phar://hio';
 
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>');
-$a->addFile('.phar/alias.txt', 'hio');
-$a->mkDir('test');
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar['test/'] = '';
+$phar->stopBuffering();
 
 try {
-       $a = new Phar($fname);
-       var_dump($a['a.php']->isExecutable());
-       $a['a.php']->chmod(0777);
-       var_dump($a['a.php']->isExecutable());
-       $a['a.php']->chmod(0666);
-       var_dump($a['a.php']->isExecutable());
+       var_dump($phar['a.php']->isExecutable());
+       $phar['a.php']->chmod(0777);
+       var_dump($phar['a.php']->isExecutable());
+       $phar['a.php']->chmod(0666);
+       var_dump($phar['a.php']->isExecutable());
        echo "test dir\n";
-       var_dump($a['test']->isDir());
-       var_dump($a['test']->isReadable());
-       $a['test']->chmod(0000);
-       var_dump($a['test']->isReadable());
-       $a['test']->chmod(0666);
-       var_dump($a['test']->isReadable());
+       var_dump($phar['test']->isDir());
+       var_dump($phar['test']->isReadable());
+       $phar['test']->chmod(0000);
+       var_dump($phar['test']->isReadable());
+       $phar['test']->chmod(0666);
+       var_dump($phar['test']->isReadable());
 } catch (Exception $e) {
        echo $e->getMessage() . "\n";
 }
@@ -39,7 +37,7 @@ try {
 ===DONE===
 --CLEAN--
 <?php 
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
 ?>
 --EXPECT--
 bool(false)
index 71e154f480fe85cee5f9c1b934b37d9a1c8d6c42..af4b56a48753a60432f2be85b2ad4f299865c093 100644 (file)
@@ -7,31 +7,29 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.1.phar.php';
-$pname = 'phar://hio';
 
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>');
-$a->addFile('.phar/alias.txt', 'hio');
-$a->mkDir('test');
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://hio';
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; include "'.$alias.'/b.php"; ?>';
+$phar->setAlias('hio');
+$phar['test/'] = '';
+$phar->stopBuffering();
 ini_set('phar.readonly', 1);
 
 try {
-       $a = new Phar($fname);
-       var_dump($a['a.php']->isExecutable());
-       $a['a.php']->chmod(0777);
-       var_dump($a['a.php']->isExecutable());
-       $a['a.php']->chmod(0666);
-       var_dump($a['a.php']->isExecutable());
+       var_dump($phar['a.php']->isExecutable());
+       $phar['a.php']->chmod(0777);
+       var_dump($phar['a.php']->isExecutable());
+       $phar['a.php']->chmod(0666);
+       var_dump($phar['a.php']->isExecutable());
        echo "test dir\n";
-       var_dump($a['test']->isExecutable());
-       $a['test']->chmod(0777);
-       var_dump($a['test']->isExecutable());
-       $a['test']->chmod(0666);
-       var_dump($a['test']->isExecutable());
+       var_dump($phar['test']->isExecutable());
+       $phar['test']->chmod(0777);
+       var_dump($phar['test']->isExecutable());
+       $phar['test']->chmod(0666);
+       var_dump($phar['test']->isExecutable());
 } catch (Exception $e) {
        echo $e->getMessage() . "\n";
 }
@@ -39,9 +37,9 @@ try {
 ===DONE===
 --CLEAN--
 <?php 
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
 ?>
 --EXPECTF--
 bool(false)
-Cannot modify permissions for file "a.php" in phar "%sa.1.phar.php", write operations are prohibited
+Cannot modify permissions for file "a.php" in phar "%sa.phar.zip", write operations are prohibited
 ===DONE===
index 85b4a44d4e7b71035578bdce4b187e3dd8a88649..06078b3a39c0211d815b3ecb5b6760c340ea9f60 100644 (file)
@@ -7,28 +7,25 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
 $file = "<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>";
 
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a', 'a');
-$a->addFile('.phar/stub.php', $file);
-$a->close();
-
 $phar = new Phar($fname);
+$phar['a'] = 'a';
+$phar->setStub($file);
+$phar->stopBuffering();
 
-echo file_get_contents($pname . '/a') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
 $phar->delete('a');
-echo file_get_contents($pname . '/a') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
 ?>
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 a
 
-Warning: file_get_contents(phar://%sdelete.phar.php/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.php" in %sdelete.php on line %d
\ No newline at end of file
+Warning: file_get_contents(phar://%sdelete.phar.zip/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.zip" in %sdelete.php on line %d
\ No newline at end of file
index 43f6874c0c3938ba5c656ca1668c04fbaae865d2..b7bda7ca4b6a4c0a333357a1ec881a5c12f1d17b 100644 (file)
@@ -7,33 +7,32 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
 
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; ?>');
-$a->addFile('b.php', '<?php echo "This is b\n"; ?>');
-$a->addFile('b/c.php', '<?php echo "This is b/c\n"; ?>');
-$a->addFile('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
 
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-unlink($pname . '/b/c.php');
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
 ?>
 ===AFTER===
 <?php
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
 ?>
 
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 This is a
 This is b
@@ -42,9 +41,9 @@ This is b/c
 This is a
 This is b
 
-Warning: include(%sdelete_in_phar.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.php" in %sdelete_in_phar.php on line %d
+Warning: include(%sdelete_in_phar.phar.zip/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.zip" in %sdelete_in_phar.php on line %d
 
-Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
+Warning: include(): Failed opening 'phar://%sdelete_in_phar.phar.zip/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
 
 ===DONE===
                
\ No newline at end of file
index cb01890444bba7111efee3bc6905321075b89fc2..7bc3a2bf1a6970abe728b2d35bbf32232c7b6713 100644 (file)
@@ -7,34 +7,33 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
 
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; ?>');
-$a->addFile('b.php', '<?php echo "This is b\n"; ?>');
-$a->addFile('b/c.php', '<?php echo "This is b/c\n"; ?>');
-$a->addFile('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
 ini_set('phar.readonly', 1);
 
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-unlink($pname . '/b/c.php');
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
 ?>
 ===AFTER===
 <?php
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
 ?>
 
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 This is a
 This is b
index 29743e01324b8584913e8e99f6db8a529abc24be..fdd0b42b5cb8d0be47a11a86a3dd8d2dc037b48e 100644 (file)
@@ -7,36 +7,37 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('a.php', '<?php echo "This is a\n"; ?>');
-$a->addFile('b.php', '<?php echo "This is b\n"; ?>');
-$a->addFile('b/c.php', '<?php echo "This is b/c\n"; ?>');
-$a->addFile('.phar/stub.php', '<?php __HALT_COMPILER(); ?>');
-$a->close();
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar['a.php'] = '<?php echo "This is a\n"; ?>';
+$phar['b.php'] = '<?php echo "This is b\n"; ?>';
+$phar['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
+$phar->stopBuffering();
+
+include $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+
 $md5 = md5_file($fname);
-unlink($pname . '/b/c.php');
+unlink($alias . '/b/c.php');
 clearstatcache();
 $md52 = md5_file($fname);
 if ($md5 == $md52) echo 'file was not modified';
 ?>
 ===AFTER===
 <?php
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/a.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b.php';
-include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php/b/c.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/a.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/b.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip/b/c.php';
 ?>
 
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 This is a
 This is b
@@ -45,8 +46,8 @@ This is b/c
 This is a
 This is b
 
-Warning: include(%sdelete_in_phar_confirm.phar.php/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.php" in %sdelete_in_phar_confirm.php on line %d
+Warning: include(%sdelete_in_phar_confirm.phar.zip/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.zip" in %sdelete_in_phar_confirm.php on line %d
 
-Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.php/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
+Warning: include(): Failed opening 'phar://%sdelete_in_phar_confirm.phar.zip/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
 
 ===DONE===
similarity index 51%
rename from ext/phar/tests/zip/tarmaker.php.inc
rename to ext/phar/tests/zip/files/zipmaker.php.inc
index da2add772b1f2a6edd6c09759997ec2dc5fcc18a..aceab0d26b94d71d412d02843711ca739e2d58a0 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // stolen from PEAR2_Pyrus_Developer_Creator_Zip by Greg Beaver, the original author, for use in unit tests
-class tarmaker
+class zipmaker
 {
     /**
      * Path to archive file
@@ -9,19 +9,17 @@ class tarmaker
      */
     protected $archive;
     /**
-     * @var Phar
+     * @var ZIPArchive
      */
     protected $zip;
     protected $path;
-    /**
-     * this is the location we'll create the phar, then we'll copy() it to $path
-     * @var string
-     */
-    protected $tmppath;
     function __construct($path)
     {
+        if (!class_exists('ZIPArchive')) {
+            throw new Exception(
+                'Zip extension is not available');
+        }
         $this->path = $path;
-        $this->tmppath = dirname($path) . "/.tmp.thingy.phar";
     }
 
     /**
@@ -31,12 +29,11 @@ class tarmaker
      */
     function addFile($path, $fileOrStream)
     {
-        if ($path == '.phar/stub.php') {
-            $this->zip->setStub($fileOrStream);
-        } elseif ($path == '.phar/alias.txt') {
-            $this->zip->setAlias($fileOrStream);
+        if (is_resource($fileOrStream)) {
+            $this->zip->addFromString($path, stream_get_contents($fileOrStream));
+        } else {
+            $this->zip->addFromString($path, $fileOrStream);
         }
-        $this->zip[$path] = $fileOrStream;
     }
 
     /**
@@ -44,8 +41,12 @@ class tarmaker
      */
     function init()
     {
-        $this->zip = new Phar($this->tmppath);
-        $this->zip->convertToZip();
+        $this->zip = new ZipArchive;
+        if (true !== $this->zip->open($this->path, ZIPARCHIVE::CREATE)) {
+            throw new Exception(
+                'Cannot open ZIP archive ' . $this->path
+            );
+        }
     }
 
     /**
@@ -56,8 +57,7 @@ class tarmaker
      */
     function mkdir($dir)
     {
-        if ($dir[strlen($dir)-1] != '/') $dir .= '/';
-        $this->zip[$dir] = '';
+        $this->zip->addEmptyDir($dir);
     }
 
     /**
@@ -65,14 +65,6 @@ class tarmaker
      */
     function close()
     {
-        $this->zip->stopBuffering();
-        copy($this->tmppath, $this->path);
-        $this->zip->setAlias('not.to.be.used'); // for preventing alias conflict
-        $this->zip->stopBuffering();
-    }
-
-    function __destruct()
-    {
-        unlink($this->tmppath);
+        $this->zip->close();
     }
 }
\ No newline at end of file
index a68f9897edc42bd20ca20395a5984595201a9770..94f85b4e3f753e9ee3b93ee8668cd9bd7246463c 100644 (file)
@@ -7,31 +7,33 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
 
 $files = array();
+
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
 
-$fp = fopen($pname . '/b/c.php', 'wb');
+$fp = fopen($alias . '/b/c.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include $pname . '/b/c.php';
+include $alias . '/b/c.php';
 ?>
 
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECT--
 extra
 ===DONE===
index 7468ef330d7ea5b24e2f2c5aef95d70fe1a24b72..347a1ce719554af633a940bf3738ead6591bd94f 100755 (executable)
@@ -7,21 +7,24 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
 
 $files = array();
+
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
+
 ini_set('phar.readonly', 1);
 
 function err_handler($errno, $errstr, $errfile, $errline) {
@@ -30,17 +33,17 @@ function err_handler($errno, $errstr, $errfile, $errline) {
 
 set_error_handler("err_handler", E_RECOVERABLE_ERROR);
 
-$fp = fopen($pname . '/b/c.php', 'wb');
+$fp = fopen($alias . '/b/c.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include $pname . '/b/c.php';
+include $alias . '/b/c.php';
 ?>
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 
-Warning: fopen(phar://%sopen_for_write_existing_b.phar.zip.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
+Warning: fopen(phar://%sopen_for_write_existing_b.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_b.php on line %d
 
 Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
 
index 8586b8694f70dbcca74173680e1c6e0956d526c3..b66a77b2128922bc1421b1efa7eb75ebb58556cc 100755 (executable)
@@ -1,5 +1,5 @@
 --TEST--
-Phar: fopen a .phar for writing (existing file) tar-based
+Phar: fopen a .phar for writing (existing file) zip-based
 --SKIPIF--
 <?php if (!extension_loaded("phar")) die("skip"); ?>
 --INI--
@@ -7,34 +7,37 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
 
 $files = array();
+
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
+
 ini_set('phar.readonly', 1);
 
-$fp = fopen($pname . '/b/c.php', 'wb');
+$fp = fopen($alias . '/b/c.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include $pname . '/b/c.php';
+include $alias . '/b/c.php';
 ?>
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 
-Warning: fopen(phar://%sopen_for_write_existing_c.phar.zip.php/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
+Warning: fopen(phar://%sopen_for_write_existing_c.phar.zip/b/c.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_existing_c.php on line %d
 
 Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
 
index 9d6a3be63d11404a2624f7637832578b08093878..c3782d4fd3d11d591ddbf1d96aa72e2d183618b7 100644 (file)
@@ -7,32 +7,35 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
 
 $files = array();
+
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
 
-$fp = fopen($pname . '/b/new.php', 'wb');
+$fp = fopen($alias . '/b/new.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
 ?>
 
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECT--
 This is b/c
 extra
index 05ea2d6bfbd4a065b064e3a60c3964bb8ddab054..44ad7487fa0fbb6998f11b39e77ae81e90a83a4b 100755 (executable)
@@ -7,21 +7,24 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
 
 $files = array();
+
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
+
 ini_set('phar.readonly', 1);
 
 function err_handler($errno, $errstr, $errfile, $errline) {
@@ -30,27 +33,28 @@ function err_handler($errno, $errstr, $errfile, $errline) {
 
 set_error_handler("err_handler", E_RECOVERABLE_ERROR);
 
-$fp = fopen($pname . '/b/new.php', 'wb');
+$fp = fopen($alias . '/b/new.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
 ?>
 
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 
-Warning: fopen(phar://%sopen_for_write_newfile_b.phar.zip.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
+Warning: fopen(phar://%sopen_for_write_newfile_b.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_b.php on line %d
 
 Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
 
 Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_b.php on line %d
 This is b/c
 
-Warning: include(phar://%sopen_for_write_newfile_b.phar.zip.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.zip.php" in %sopen_for_write_newfile_b.php on line %d
+Warning: include(phar://%sopen_for_write_newfile_b.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.zip" in %sopen_for_write_newfile_b.php on line %d
 
-Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.zip.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
 
 ===DONE===
index 499dfc57749ef1c61b9ef900a80d1f871eff8741..b664397a99aef66d50ac918b2a392d8dda7f8414 100755 (executable)
@@ -7,44 +7,48 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub('<?php __HALT_COMPILER(); ?>');
 
 $files = array();
+
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
+
 ini_set('phar.readonly', 1);
 
-$fp = fopen($pname . '/b/new.php', 'wb');
+$fp = fopen($alias . '/b/new.php', 'wb');
 fwrite($fp, 'extra');
 fclose($fp);
-include $pname . '/b/c.php';
-include $pname . '/b/new.php';
+
+include $alias . '/b/c.php';
+include $alias . '/b/new.php';
 ?>
 
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 
-Warning: fopen(phar://%sopen_for_write_newfile_c.phar.zip.php/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
+Warning: fopen(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: write operations disabled by INI setting in %sopen_for_write_newfile_c.php on line %d
 
 Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
 
 Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_newfile_c.php on line %d
 This is b/c
 
-Warning: include(phar://%sopen_for_write_newfile_c.phar.zip.php/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.zip.php" in %sopen_for_write_newfile_c.php on line %d
+Warning: include(phar://%sopen_for_write_newfile_c.phar.zip/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.zip" in %sopen_for_write_newfile_c.php on line %d
 
-Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.zip.php/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
+Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.zip/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_c.php on line %d
 
 ===DONE===
\ No newline at end of file
index ecd969a1ddd68ed1be85624226b11bc1a67e1fd5..1a5d8504b56aed7a53c4c4445bf84d7454380ee7 100644 (file)
@@ -7,24 +7,24 @@ phar.require_hash=0
 phar.readonly=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+$phar = new Phar($fname);
+$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
 
 $files = array();
+
 $files['a'] = 'a';
 $files['b'] = 'b';
 $files['c'] = 'c';
-$files['.phar/alias.txt'] = 'hio';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
 
-$phar = new Phar($fname);
 echo $phar->getAlias() . "\n";
 $phar->setAlias('test');
 echo $phar->getAlias() . "\n";
@@ -32,8 +32,8 @@ echo $phar->getAlias() . "\n";
 ===DONE===
 --CLEAN--
 <?php 
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.zip');
 __HALT_COMPILER();
 ?>
 --EXPECT--
index 89057931a5e5b18acc34754eb51d03b03ee9ee98..a17dd8fd2b7180483d2b7f69684238e7c800032f 100644 (file)
@@ -7,27 +7,28 @@ phar.require_hash=0
 phar.readonly=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+
+$phar = new Phar($fname);
+$phar->setStub('<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
 
 $files = array();
+
 $files['a'] = 'a';
 $files['b'] = 'b';
 $files['c'] = 'c';
-$files['.phar/alias.txt'] = 'hio';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
 
-$phar = new Phar($fname);
 echo $phar->getAlias() . "\n";
 $phar->setAlias('test');
 echo $phar->getAlias() . "\n";
+
 $phar = new Phar(dirname(__FILE__) . '/notphar.phar');
 try {
        $phar->setAlias('test');
@@ -38,13 +39,12 @@ try {
 ===DONE===
 --CLEAN--
 <?php 
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
-unlink(dirname(__FILE__) . '/notphar.phar');
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.zip');
 __HALT_COMPILER();
 ?>
 --EXPECTF--
 hio
 test
-alias "test" is already used for archive "%sphar_setalias2.phar.php" and cannot be used for other archives
+alias "test" is already used for archive "%sphar_setalias2.phar.zip" and cannot be used for other archives
 ===DONE===
index fce7a8342723ad7fa25e1a0f27f68a998b202499..50d0cb1b010bbc7b03e9711b1225c48a75f3efba 100755 (executable)
@@ -7,22 +7,15 @@ phar.require_hash=0
 phar.readonly=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', $stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
 
-$files = array();
-$files['a'] = 'a';
-$files['.phar/alias.txt'] = 'hio';
-foreach ($files as $n => $file) {
-$a->addFile($n, $file);
-}
-$a->close();
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
 
 $phar = new Phar($fname);
+$phar->setStub($stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>');
+$phar->setAlias('hio');
+$phar['a'] = 'a';
+$phar->stopBuffering();
+
 var_dump($stub);
 var_dump($phar->getStub());
 var_dump($phar->getStub() == $stub);
@@ -46,14 +39,14 @@ var_dump($phar->getStub() == $stub);
 ===DONE===
 --CLEAN--
 <?php 
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
 __HALT_COMPILER();
 ?>
 --EXPECTF--
 string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
 string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
 bool(true)
-Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.php"
+Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.zip"
 string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
 bool(true)
 string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
index b16bcb6ead542f3763a2e7e9f7ad2df581a06cad..6d7b7420c6eeb9f4ed75ee1074371e25f4f7b2b8 100644 (file)
@@ -9,61 +9,61 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php __HALT_COMPILER(); ?>");
 
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php __HALT_COMPILER(); ?>");
+$phar->setAlias('hio');
 
 $files = array();
+
 $files['a.php'] = '<?php echo "This is a\n"; ?>';
 $files['b.php'] = '<?php echo "This is b\n"; ?>';
 $files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
-$files['.phar/alias.txt'] = 'hio';
+
 foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+       $phar[$n] = $file;
 }
-$a->close();
+$phar->stopBuffering();
 
-$fp = fopen($pname . '/b/c.php', 'wb');
+$fp = fopen($alias . '/b/c.php', 'wb');
 fwrite($fp, "extra");
 fclose($fp);
 echo "===CLOSE===\n";
-$p = new Phar($fname);
-$b = fopen($pname . '/b/c.php', 'rb');
-$a = $p['b/c.php'];
+$b = fopen($alias . '/b/c.php', 'rb');
+$a = $phar['b/c.php'];
 var_dump($a);
 var_dump(fread($b, 20));
 rewind($b);
 echo "===UNLINK===\n";
-unlink($pname . '/b/c.php');
+unlink($alias . '/b/c.php');
 var_dump($a);
 var_dump(fread($b, 20));
-include $pname . '/b/c.php';
+include $alias . '/b/c.php';
 ?>
 
 ===DONE===
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 ===CLOSE===
 object(PharFileInfo)#%d (2) {
   ["pathName":"SplFileInfo":private]=>
-  string(%d) "phar://%srefcount1.phar.php/b"
+  string(%d) "phar://%srefcount1.phar.zip/b"
   ["fileName":"SplFileInfo":private]=>
-  string(%d) "phar://%srefcount1.phar.php/b/c.php"
+  string(%d) "phar://%srefcount1.phar.zip/b/c.php"
 }
 string(5) "extra"
 ===UNLINK===
 
-Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.php", has open file pointers, cannot unlink in %srefcount1.php on line %d
+Warning: unlink(): phar error: "b/c.php" in phar "%srefcount1.phar.zip", has open file pointers, cannot unlink in %srefcount1.php on line %d
 object(PharFileInfo)#%d (2) {
   ["pathName":"SplFileInfo":private]=>
-  string(%d) "phar://%srefcount1.phar.php/b"
+  string(%d) "phar://%srefcount1.phar.zip/b"
   ["fileName":"SplFileInfo":private]=>
-  string(%s) "phar://%srefcount1.phar.php/b/c.php"
+  string(%s) "phar://%srefcount1.phar.zip/b/c.php"
 }
 string(5) "extra"
 extra
index 7e6d3118da868677f047cb3a06295029dc861fca..9b1f5c98cdadc25d6c1ec391068a27875c54e399 100644 (file)
@@ -7,33 +7,28 @@ phar.readonly=0
 phar.require_hash=0
 --FILE--
 <?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('.phar/stub.php', "<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
+$alias = 'phar://' . $fname;
+
+$phar = new Phar($fname);
+$phar->setStub("<?php
 Phar::mapPhar('hio');
 __HALT_COMPILER(); ?>");
-
-$files = array();
-$files['a'] = 'a';
-foreach ($files as $n => $file) {
-$a->addFile($n, $file);
-}
-$a->close();
+$phar['a'] = 'a';
+$phar->stopBuffering();
 
 include $fname;
 
-echo file_get_contents($pname . '/a') . "\n";
-rename($pname . '/a', $pname . '/b');
-echo file_get_contents($pname . '/b') . "\n";
-echo file_get_contents($pname . '/a') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
+rename($alias . '/a', $alias . '/b');
+echo file_get_contents($alias . '/b') . "\n";
+echo file_get_contents($alias . '/a') . "\n";
 ?>
 --CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); ?>
 --EXPECTF--
 a
 a
 
-Warning: file_get_contents(phar://%srename.phar.php/a): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.php" in %srename.php on line %d
\ No newline at end of file
+Warning: file_get_contents(phar://%srename.phar.zip/a): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.zip" in %srename.php on line %d
\ No newline at end of file