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.tar';
+$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']->isReadable());
- $a['test']->chmod(0000);
- var_dump($a['test']->isReadable());
- $a['test']->chmod(0666);
- var_dump($a['test']->isReadable());
+ 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";
}
+
?>
===DONE===
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
?>
--EXPECTF--
bool(false)
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
-phar.readonly=1
+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.tar';
+$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']->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";
}
===DONE===
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
?>
--EXPECTF--
bool(false)
-Cannot modify permissions for file "a.php" in phar "%s033a.1.phar.php", write operations are prohibited
+Cannot modify permissions for file "a.php" in phar "%s033a.phar.tar", write operations are prohibited
===DONE===
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
-$pname = 'phar://' . $fname;
-$file = "<?php
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+$stub = "<?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($stub);
+$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.tar'); ?>
--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.tar/a): failed to open stream: phar error: "a" is not a file in phar "%sdelete.phar.tar" in %sdelete.php on line %d
\ No newline at end of file
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';
-unlink($pname . '/b/c.php');
+
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$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';
+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.tar'); ?>
--EXPECTF--
This is a
This is b
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.tar/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar.phar.tar" 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.tar/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar.php on line %d
===DONE===
-
\ No newline at end of file
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
-phar.readonly=1
+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.tar';
+$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 $alias . '/a.php';
+include $alias . '/b.php';
+include $alias . '/b/c.php';
+unlink($alias . '/b/c.php');
-include $pname . '/a.php';
-include $pname . '/b.php';
-include $pname . '/b/c.php';
-unlink($pname . '/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.tar'); ?>
--EXPECTF--
This is a
This is b
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.tar';
+$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.tar/a.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/b.php';
+include 'phar://' . dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar/b/c.php';
?>
===DONE===
--CLEAN--
-<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
--EXPECTF--
This is a
This is b
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.tar/b/c.php): failed to open stream: phar error: "b/c.php" is not a file in phar "%sdelete_in_phar_confirm.phar.tar" 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.tar/b/c.php' for inclusion (include_path='%s') in %sdelete_in_phar_confirm.php on line %d
===DONE===
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller.phar.tar');
-$a['a.php'] = 'hio';
-$a['a.jpg'] = 'hio';
-$a['a.phps'] = '<?php function hio(){}';
-$a['index.php'] = 'here is my index';
-$a->setStub('<?php
-Phar::webPhar();
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller1.phar.php/a.jpg
PATH_INFO=/a.jpg
--FILE_EXTERNAL--
-frontcontroller.phar.tar
+files/frontcontroller.phar.tar
--EXPECTHEADERS--
Content-type: image/jpeg
Content-length: 3
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller10.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller10.phar.tar');
-$a['index.php'] = '<?php
-var_dump($_SERVER["PHP_SELF"]);
-var_dump($_SERVER["SCRIPT_NAME"]);
-var_dump($_SERVER["SCRIPT_FILENAME"]);
-var_dump($_SERVER["REQUEST_URI"]);
-var_dump($_SERVER["PHAR_PHP_SELF"]);
-var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
-var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
-var_dump($_SERVER["PHAR_REQUEST_URI"]);
-';
-$a->setStub('<?php
-Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI", "OOPSIE"));
-Phar::webPhar();
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller10.phar.php/hi
PATH_INFO=/hi
--FILE_EXTERNAL--
-frontcontroller4.phar.tar
+files/frontcontroller4.phar.tar
--EXPECTHEADERS--
Content-type: text/html
Status: 403 Access Denied
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller11.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller11.phar.tar');
-$a['index.php'] = '<?php
-var_dump($_SERVER["PHP_SELF"]);
-var_dump($_SERVER["SCRIPT_NAME"]);
-var_dump($_SERVER["SCRIPT_FILENAME"]);
-var_dump($_SERVER["REQUEST_URI"]);
-var_dump($_SERVER["PHAR_PHP_SELF"]);
-var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
-var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
-var_dump($_SERVER["PHAR_REQUEST_URI"]);
-';
-$a->setStub('<?php
-Phar::mungServer(array(array(), "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
-Phar::webPhar();
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller11.phar.php/a.php
PATH_INFO=/a.php
--FILE_EXTERNAL--
-frontcontroller5.phar.tar
+files/frontcontroller5.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECTF--
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller12.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller12.phar.tar');
-$a['index.php'] = '<?php
-var_dump($_SERVER["PHP_SELF"]);
-var_dump($_SERVER["SCRIPT_NAME"]);
-var_dump($_SERVER["SCRIPT_FILENAME"]);
-var_dump($_SERVER["REQUEST_URI"]);
-var_dump($_SERVER["PHAR_PHP_SELF"]);
-var_dump($_SERVER["PHAR_SCRIPT_NAME"]);
-var_dump($_SERVER["PHAR_SCRIPT_FILENAME"]);
-var_dump($_SERVER["PHAR_REQUEST_URI"]);
-';
-$a->setStub('<?php
-Phar::mungServer(array("PHP_SELF", "SCRIPT_NAME", "SCRIPT_FILENAME", "REQUEST_URI"));
-Phar::webPhar();
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller12.phar.php/a.php
PATH_INFO=/a.php
--FILE_EXTERNAL--
-frontcontroller6.phar.tar
+files/frontcontroller6.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECTF--
REQUEST_URI=/frontcontroller13.phar.php/a.php
PATH_INFO=/a.php
--FILE_EXTERNAL--
-frontcontroller7.phar.tar
+files/frontcontroller7.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECTF--
REQUEST_URI=/frontcontroller14.phar.php/a.jpg
PATH_INFO=/a.jpg
--FILE_EXTERNAL--
-frontcontroller8.phar.tar
+files/frontcontroller8.phar.tar
--EXPECTHEADERS--
Content-type: foo/bar
Content-length: 4
REQUEST_URI=/frontcontroller15.phar.php/a.php
PATH_INFO=/a.php
--FILE_EXTERNAL--
-frontcontroller8.phar.tar
+files/frontcontroller8.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECT--
REQUEST_URI=/frontcontroller16.phar.php/a.phps
PATH_INFO=/a.phps
--FILE_EXTERNAL--
-frontcontroller8.phar.tar
+files/frontcontroller8.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECT--
REQUEST_URI=/frontcontroller17.phar.php/fronk.gronk
PATH_INFO=/fronk.gronk
--FILE_EXTERNAL--
-frontcontroller8.phar.tar
+files/frontcontroller8.phar.tar
--EXPECTHEADERS--
Content-type: application/octet-stream
Content-length: 4
REQUEST_URI=/frontcontroller18.phar.php/fronk.gronk
PATH_INFO=/fronk.gronk
--FILE_EXTERNAL--
-frontcontroller9.phar.tar
+files/frontcontroller9.phar.tar
--EXPECTF--
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller18.phar.php:2
Stack trace:
REQUEST_URI=/frontcontroller19.phar.php/
PATH_INFO=/
--FILE_EXTERNAL--
-frontcontroller10.phar.tar
+files/frontcontroller10.phar.tar
--EXPECTF--
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller19.phar.php:2
Stack trace:
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller2.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller2.phar.tar');
-$a['a.php'] = 'hio';
-$a['a.jpg'] = 'hio';
-$a['a.phps'] = '<?php function hio(){}';
-$a->setStub('<?php
-Phar::webPhar("whatever", "a.php");
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller2.phar.php/a.php
PATH_INFO=/a.php
--FILE_EXTERNAL--
-frontcontroller.phar.tar
+files/frontcontroller.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECT--
REQUEST_URI=/frontcontroller20.phar.php/
PATH_INFO=/
--FILE_EXTERNAL--
-frontcontroller11.phar.tar
+files/frontcontroller11.phar.tar
--EXPECTF--
Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME' in %sfrontcontroller20.phar.php:2
Stack trace:
PATH_INFO=/index.php
QUERY_STRING=test=hi
--FILE_EXTERNAL--
-frontcontroller12.phar.tar
+files/frontcontroller12.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECTF--
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller3.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller3.phar.tar');
-$a['a.php'] = 'hio';
-$a['a.jpg'] = 'hio';
-$a['a.phps'] = '<?php function hio(){}';
-$a->setStub('<?php
-function s($a)
-{
- static $b = array("/hi" => "a.phps");
- if (isset($b[$a])) return $b[$a];
- return $a;
-}
-Phar::webPhar("whatever", "/index.php", null, array(), "s");
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller3.phar.php/a.phps
PATH_INFO=/a.phps
--FILE_EXTERNAL--
-frontcontroller.phar.tar
+files/frontcontroller.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECT--
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller4.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller4.phar.tar');
-$a['a.php'] = 'hio';
-$a['a.jpg'] = 'hio';
-$a['a.phps'] = '<?php function hio(){}';
-$a->setStub('<?php
-function s($a)
-{
- static $b = array("/hi" => false);
- if (isset($b[$a])) return $b[$a];
- return $a;
-}
-Phar::webPhar("whatever", "index.php", null, array(), "s");
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
SCRIPT_NAME=/frontcontroller4.phar.php
REQUEST_URI=/frontcontroller4.phar.php
--FILE_EXTERNAL--
-frontcontroller.phar.tar
+files/frontcontroller.phar.tar
--EXPECTHEADERS--
Status: 301 Moved Permanently
Location: /frontcontroller4.phar.php/index.php
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller5.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller5.phar.tar');
-$a['a.php'] = 'hio';
-$a['a.jpg'] = 'hio';
-$a['a.phps'] = '<?php function hio(){}';
-$a->setStub('<?php
-Phar::webPhar("whatever", "index.php", null, array(0 => "oops"));
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller5.phar.php/
PATH_INFO=/
--FILE_EXTERNAL--
-frontcontroller.phar.tar
+files/frontcontroller.phar.tar
--EXPECTHEADERS--
Status: 301 Moved Permanently
Location: /frontcontroller5.phar.php/index.php
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller6.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller6.phar.tar');
-$a['a.php'] = 'hio';
-$a['a.jpg'] = 'hio';
-$a['a.phps'] = '<?php function hio(){}';
-$a->setStub('<?php
-Phar::webPhar("whatever", "index.php", null, array("blah" => 100));
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller6.phar.php/notfound.php
PATH_INFO=/notfound.php
--FILE_EXTERNAL--
-frontcontroller.phar.tar
+files/frontcontroller.phar.tar
--EXPECTHEADERS--
Status: 404 Not Found
--EXPECT--
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller7.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller7.phar.tar');
-$a['a.php'] = 'hio';
-$a['a.jpg'] = 'hio';
-$a['a.phps'] = '<?php function hio(){}';
-$a->setStub('<?php
-Phar::webPhar("whatever", "index.php", null, array("blah" => null));
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller7.phar.php/
PATH_INFO=/
--FILE_EXTERNAL--
-frontcontroller2.phar.tar
+files/frontcontroller2.phar.tar
--EXPECTHEADERS--
Status: 301 Moved Permanently
Location: /frontcontroller7.phar.php/a.php
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller8.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller8.phar.tar');
-$a['a.phps'] = 'hio1';
-$a['a.jpg'] = 'hio2';
-$a['a.php'] = '<?php function hio(){}';
-$a['fronk.gronk'] = 'hio3';
-$a->setStub('<?php
-Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller8.phar.php/
PATH_INFO=/
--FILE_EXTERNAL--
-frontcontroller3.phar.tar
+files/frontcontroller3.phar.tar
--EXPECTHEADERS--
Status: 404 Not Found
--EXPECT--
+++ /dev/null
-<?php
-@unlink(dirname(__FILE__) . '/frontcontroller9.phar.tar');
-$a = new Phar(dirname(__FILE__) . '/frontcontroller9.phar.tar');
-$a['a.phps'] = 'hio1';
-$a['a.jpg'] = 'hio2';
-$a['a.php'] = '<?php function hio(){}';
-$a['fronk.gronk'] = 'hio3';
-$a->setStub('<?php
-Phar::mungServer(array());
-Phar::webPhar("whatever", "index.php", null, array("jpg" => "foo/bar", "phps" => Phar::PHP, "php" => Phar::PHPS));
-echo "oops did not run\n";
-var_dump($_ENV, $_SERVER);
-__HALT_COMPILER();');
-?>
REQUEST_URI=/frontcontroller9.phar.php/hi
PATH_INFO=/hi
--FILE_EXTERNAL--
-frontcontroller3.phar.tar
+files/frontcontroller3.phar.tar
--EXPECTHEADERS--
Content-type: text/html
--EXPECT--
+++ /dev/null
-<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-class corrupter extends tarmaker {
-function close()
-{
- fwrite($this->tmp, 'oopsie');
- fclose($this->tmp);
-}
-}
\ No newline at end of file
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar';
+$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();
-$fp = fopen($pname . '/b/c.php', 'wb');
+$phar->stopBuffering();
+
+$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.tar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
--EXPECT--
extra
===DONE===
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
-phar.readonly=1
+phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar';
+$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) {
- echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
}
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.tar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_existing_b.phar.tar.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.tar/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
+Warning: fwrite(): supplied argument is not a valid stream resource in %sopen_for_write_existing_b.php on line %d
Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b.php on line %d
This is b/c
-===DONE===
\ No newline at end of file
+
+===DONE===
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
-phar.readonly=1
+phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar';
+$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();
-$fp = fopen($pname . '/b/c.php', 'wb');
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+$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.tar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_existing_c.phar.tar.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.tar/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
Warning: fclose(): supplied argument is not a valid stream resource in %sopen_for_write_existing_c.php on line %d
This is b/c
-===DONE===
\ No newline at end of file
+
+===DONE===
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar';
+$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();
-$fp = fopen($pname . '/b/new.php', 'wb');
+$phar->stopBuffering();
+
+$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.tar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
--EXPECT--
This is b/c
extra
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
-phar.readonly=1
+phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar';
+$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) {
- echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
+ echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
}
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.tar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_newfile_b.phar.tar.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.tar/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.tar.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.tar.php" in %sopen_for_write_newfile_b.php on line %d
+Warning: include(phar://%sopen_for_write_newfile_b.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_b.phar.tar" in %sopen_for_write_newfile_b.php on line %d
-Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_b.phar.tar.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.tar/b/new.php' for inclusion (include_path='%s') in %sopen_for_write_newfile_b.php on line %d
===DONE===
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--INI--
-phar.readonly=1
+phar.readonly=0
phar.require_hash=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar.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.tar';
+$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();
-$fp = fopen($pname . '/b/new.php', 'wb');
+$phar->stopBuffering();
+ini_set('phar.readonly', 1);
+
+$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.tar.php'); ?>
+<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
--EXPECTF--
-Warning: fopen(phar://%sopen_for_write_newfile_c.phar.tar.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.tar/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.tar.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.tar.php" in %sopen_for_write_newfile_c.php on line %d
+Warning: include(phar://%sopen_for_write_newfile_c.phar.tar/b/new.php): failed to open stream: phar error: "b/new.php" is not a file in phar "%sopen_for_write_newfile_c.phar.tar" in %sopen_for_write_newfile_c.php on line %d
-Warning: include(): Failed opening 'phar://%sopen_for_write_newfile_c.phar.tar.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.tar/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
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.tar';
+
+$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 = new Phar($fname);
+$phar->stopBuffering();
+
echo $phar->getAlias() . "\n";
$phar->setAlias('test');
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.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.tar');
__HALT_COMPILER();
?>
--EXPECT--
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.tar';
+
+$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 = new Phar($fname);
+$phar->stopBuffering();
+
echo $phar->getAlias() . "\n";
$phar->setAlias('test');
echo $phar->getAlias() . "\n";
+
$phar = new Phar(dirname(__FILE__) . '/notphar.phar');
+
try {
$phar->setAlias('test');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
+
?>
===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.tar');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phartmp.tar');
__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.tar" and cannot be used for other archives
===DONE===
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.tar';
$phar = new Phar($fname);
+$phar->setStub($stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>' ."\r\n");
+$phar->setAlias('hio');
+$phar['a'] = 'a';
+$phar->stopBuffering();
+
var_dump($stub);
var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);
$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
-try
-{
+
+try {
$phar->setStub($newstub);
-}
-catch(exception $e)
-{
+} catch(exception $e) {
echo 'Exception: ' . $e->getMessage() . "\n";
}
+
var_dump($phar->getStub());
var_dump($phar->getStub() == $stub);
$phar->stopBuffering();
===DONE===
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php');
+unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
__HALT_COMPILER();
?>
--EXPECTF--
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
bool(true)
-Exception: illegal stub for tar-based phar "%sphar_stub_error.phar.php"
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+Exception: illegal stub for tar-based phar "%sphar_stub_error.phar.tar"
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
bool(true)
-string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
+string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
+"
bool(true)
===DONE===
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(); ?>");
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('.phar/stub.php', "<?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"; ?>';
$files['.phar/alias.txt'] = 'hio';
+
foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+ $tar->addFile($n, $file);
}
-$a->close();
-$fp = fopen($pname . '/b/c.php', 'wb');
+$tar->close();
+
+$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'];
+$phar = new Phar($fname);
+$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.tar'); ?>
--EXPECTF--
===CLOSE===
object(PharFileInfo)#%d (2) {
["pathName":"SplFileInfo":private]=>
- string(%d) "phar://%srefcount1.phar.php/b"
+ string(%d) "phar://%srefcount1.phar.tar/b"
["fileName":"SplFileInfo":private]=>
- string(%d) "phar://%srefcount1.phar.php/b/c.php"
+ string(%d) "phar://%srefcount1.phar.tar/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.tar", 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.tar/b"
["fileName":"SplFileInfo":private]=>
- string(%s) "phar://%srefcount1.phar.php/b/c.php"
+ string(%s) "phar://%srefcount1.phar.tar/b/c.php"
}
string(5) "extra"
extra
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
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('.phar/stub.php', "<?php
Phar::mapPhar('hio');
__HALT_COMPILER(); ?>");
$files = array();
$files['a'] = 'a';
+
foreach ($files as $n => $file) {
-$a->addFile($n, $file);
+ $tar->addFile($n, $file);
}
-$a->close();
+
+$tar->close();
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.tar'); ?>
--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.tar/a): failed to open stream: phar error: "a" is not a file in phar "%srename.phar.tar" in %srename.php on line %d
<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
--FILE--
<?php
-include dirname(__FILE__) . '/make_invalid_tar.php.inc';
-$a = new corrupter(dirname(__FILE__) . '/tar_001.phar', 'none');
-$a->init();
-$a->addFile('tar_001.phpt', __FILE__);
-$a->close();
+include dirname(__FILE__) . '/files/make_invalid_tar.php.inc';
-$a = fopen('phar://' . dirname(__FILE__) . '/tar_001.phar/tar_001.phpt', 'rb');
+$tar = new corrupter(dirname(__FILE__) . '/tar_001.phar.tar', 'none');
+$tar->init();
+$tar->addFile('tar_001.phpt', __FILE__);
+$tar->close();
+
+$tar = fopen('phar://' . dirname(__FILE__) . '/tar_001.phar.tar/tar_001.phpt', 'rb');
try {
-$a = new Phar(dirname(__FILE__) . '/tar_001.phar');
-echo "should not execute\n";
+ $phar = new Phar(dirname(__FILE__) . '/tar_001.phar.tar');
+ echo "should not execute\n";
} catch (Exception $e) {
-echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
?>
===DONE===
@unlink(dirname(__FILE__) . '/tar_001.phar');
?>
--EXPECTF--
-Warning: fopen(phar://%star_001.phar/tar_001.phpt): failed to open stream: phar error: "%star_001.phar" is a corrupted tar file in %star_001.php on line %d
-Cannot open phar file '%star_001.phar' with alias '(null)': phar error: "%star_001.phar" is a corrupted tar file
+Warning: fopen(phar://%star_001.phar.tar/tar_001.phpt): failed to open stream: phar error: "%star_001.phar.tar" is a corrupted tar file in %star_001.php on line %d
+Cannot open phar file '%star_001.phar.tar' with alias '(null)': phar error: "%star_001.phar.tar" is a corrupted tar file
===DONE===
\ No newline at end of file
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/make_invalid_tar.php.inc';
-$a = new corrupter(dirname(__FILE__) . '/tar_002.phar', 'none');
-$a->init();
-$a->addFile('tar_002.phpt', __FILE__);
-$a->close();
+include dirname(__FILE__) . '/files/make_invalid_tar.php.inc';
+
+$tar = new corrupter(dirname(__FILE__) . '/tar_002.phar.tar', 'none');
+$tar->init();
+$tar->addFile('tar_002.phpt', __FILE__);
+$tar->close();
+
+$tar = fopen('phar://' . dirname(__FILE__) . '/tar_002.phar.tar/tar_002.phpt', 'rb');
-$a = fopen('phar://' . dirname(__FILE__) . '/tar_002.phar/tar_002.phpt', 'rb');
try {
-$a = new Phar(dirname(__FILE__) . '/tar_002.phar');
-echo "should not execute\n";
+ $phar = new Phar(dirname(__FILE__) . '/tar_002.phar.tar');
+ echo "should not execute\n";
} catch (Exception $e) {
-echo $e->getMessage() . "\n";
+ echo $e->getMessage() . "\n";
}
?>
===DONE===
--CLEAN--
<?php
-@unlink(dirname(__FILE__) . '/tar_002.phar');
+@unlink(dirname(__FILE__) . '/tar_002.phar.tar');
?>
--EXPECTF--
-Warning: fopen(phar://%star_002.phar/tar_002.phpt): failed to open stream: phar error: "%star_002.phar" is a corrupted tar file in %star_002.php on line %d
-Cannot open phar file '%star_002.phar' with alias '(null)': phar error: "%star_002.phar" is a corrupted tar file
+Warning: fopen(phar://%star_002.phar.tar/tar_002.phpt): failed to open stream: phar error: "%star_002.phar.tar" is a corrupted tar file in %star_002.php on line %d
+Cannot open phar file '%star_002.phar.tar' with alias '(null)': phar error: "%star_002.phar.tar" is a corrupted tar file
===DONE===
\ No newline at end of file
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/tar_003.phar';
-$pname = 'phar://' . $fname;
-
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('tar_003.phpt', $g = fopen(__FILE__, 'r'));
-$a->addFile('internal/file/here', "hi there!\n");
-$a->mkDir('internal/dir');
-$a->mkDir('dir');
-$a->close();
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+
+$fname = dirname(__FILE__) . '/tar_003.phar.tar';
+$alias = 'phar://' . $fname;
+
+$tar = new tarmaker($fname, 'none');
+$tar->init();
+$tar->addFile('tar_003.phpt', $g = fopen(__FILE__, 'r'));
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->mkDir('internal/dir');
+$tar->mkDir('dir');
+$tar->close();
+
fclose($g);
-echo file_get_contents($pname . '/internal/file/here');
-$a = opendir($pname . '/');
-while (false !== ($v = readdir($a))) {
- echo (is_file($pname . '/' . $v) ? "file\n" : "dir\n");
+echo file_get_contents($alias . '/internal/file/here');
+
+$tar = opendir($alias . '/');
+
+while (false !== ($v = readdir($tar))) {
+ echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n");
echo $v . "\n";
}
-closedir($a);
+closedir($tar);
/* ensure none of the dir tar files were freed */
echo "second round\n";
-$a = opendir($pname . '/');
-while (false !== ($v = readdir($a))) {
- echo (is_file($pname . '/' . $v) ? "file\n" : "dir\n");
+$tar = opendir($alias . '/');
+while (false !== ($v = readdir($tar))) {
+ echo (is_file($alias . '/' . $v) ? "file\n" : "dir\n");
echo $v . "\n";
}
-closedir($a);
+closedir($tar);
?>
===DONE===
--CLEAN--
<?php
-@unlink(dirname(__FILE__) . '/tar_003.phar');
+@unlink(dirname(__FILE__) . '/tar_003.phar.tar');
?>
--EXPECT--
hi there!
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/tar_004.phar';
-$pname = 'phar://' . $fname;
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('tar_004.php', '<?php var_dump(__FILE__);');
-$a->addFile('internal/file/here', "hi there!\n");
-$a->mkDir('internal/dir');
-$a->mkDir('dir');
-$a->addFile('.phar/stub.php', '<?php
+$fname = dirname(__FILE__) . '/tar_004.phar.tar';
+$alias = 'phar://' . $fname;
+
+$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->mkDir('internal/dir');
+$tar->mkDir('dir');
+$tar->addFile('.phar/stub.php', '<?php
Phar::mapPhar();
var_dump("it worked");
include "phar://" . __FILE__ . "/tar_004.php";
');
-$a->close();
+$tar->close();
include $fname;
?>
===DONE===
--CLEAN--
<?php
-@unlink(dirname(__FILE__) . '/tar_004.phar');
+@unlink(dirname(__FILE__) . '/tar_004.phar.tar');
?>
--EXPECTF--
string(9) "it worked"
-string(%d) "phar://%star_004.phar/tar_004.php"
+string(%d) "phar://%star_004.phar.tar/tar_004.php"
===DONE===
\ No newline at end of file
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+
$fname = dirname(__FILE__) . '/tar_bz2.phar';
-$pname = 'phar://' . $fname;
+$alias = 'phar://' . $fname;
$fname2 = dirname(__FILE__) . '/tar_bz2.phar.tar';
-$pname2 = 'phar://' . $fname2;
+$alias2 = 'phar://' . $fname2;
-$a = new tarmaker($fname, 'bz2');
-$a->init();
-$a->addFile('tar_004.php', '<?php var_dump(__FILE__);');
-$a->addFile('internal/file/here', "hi there!\n");
-$a->mkDir('internal/dir');
-$a->mkDir('dir');
-$a->addFile('.phar/stub.php', '<?php
+$tar = new tarmaker($fname, 'bz2');
+$tar->init();
+$tar->addFile('tar_004.php', '<?php var_dump(__FILE__);');
+$tar->addFile('internal/file/here', "hi there!\n");
+$tar->mkDir('internal/dir');
+$tar->mkDir('dir');
+$tar->addFile('.phar/stub.php', '<?php
Phar::mapPhar();
var_dump("it worked");
include "phar://" . __FILE__ . "/tar_004.php";
');
-$a->close();
+$tar->close();
include $fname;
-$a = new Phar($fname);
-$a['test'] = 'hi';
+$phar = new Phar($fname);
+$phar['test'] = 'hi';
+
copy($fname, $fname2);
-$b = new Phar($fname2);
-var_dump($b->isTar());
-var_dump($b->isCompressed() == Phar::BZ2);
+
+$phar2 = new Phar($fname2);
+var_dump($phar2->isTar());
+var_dump($phar2->isCompressed() == Phar::BZ2);
+
?>
===DONE===
--CLEAN--
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
$fname = dirname(__FILE__) . '/tar_gzip.phar';
$pname = 'phar://' . $fname;
$fname2 = dirname(__FILE__) . '/tar_gzip.phar.tar';
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
+
$fname = dirname(__FILE__) . '/tar_makebz2.phar.tar';
-$pname = 'phar://' . $fname;
-$fname2 = dirname(__FILE__) . '/tar_makebz22.phar.tar';
-$pname2 = 'phar://' . $fname2;
+$alias = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/tar_makebz2_b.phar.tar';
+$alias2 = 'phar://' . $fname2;
+
+$phar = new Phar($fname);
+$phar['test'] = 'hi';
+var_dump($phar->isTar());
+$phar->compressAllFilesBZIP2();
-$a = new Phar($fname);
-$a['test'] = 'hi';
-var_dump($a->isTar());
-$a->compressAllFilesBZIP2();
copy($fname, $fname2);
-$b = new Phar($fname2);
-var_dump($b->isTar());
-var_dump($b->isCompressed() == Phar::BZ2);
+
+$phar2 = new Phar($fname2);
+var_dump($phar2->isTar());
+var_dump($phar2->isCompressed() == Phar::BZ2);
+
?>
===DONE===
--CLEAN--
<?php
@unlink(dirname(__FILE__) . '/tar_makebz2.phar.tar');
-@unlink(dirname(__FILE__) . '/tar_makebz22.phar.tar');
+@unlink(dirname(__FILE__) . '/tar_makebz2_b.phar.tar');
?>
--EXPECTF--
bool(true)
phar.readonly=0
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
+
$fname = dirname(__FILE__) . '/tar_makegz.phar.tar';
-$pname = 'phar://' . $fname;
-$fname2 = dirname(__FILE__) . '/tar_makegz2.phar.tar';
-$pname2 = 'phar://' . $fname2;
+$alias = 'phar://' . $fname;
+$fname2 = dirname(__FILE__) . '/tar_makegz_b.phar.tar';
+$alias2 = 'phar://' . $fname2;
+
+$phar = new Phar($fname);
+$phar['test'] = 'hi';
+var_dump($phar->isTar());
+$phar->compressAllFilesGZ();
-$a = new Phar($fname);
-$a['test'] = 'hi';
-var_dump($a->isTar());
-$a->compressAllFilesGZ();
copy($fname, $fname2);
-$b = new Phar($fname2);
-var_dump($b->isTar());
-var_dump($b->isCompressed() == Phar::GZ);
+
+$phar2 = new Phar($fname2);
+var_dump($phar2->isTar());
+var_dump($phar2->isCompressed() == Phar::GZ);
+
?>
===DONE===
--CLEAN--
<?php
@unlink(dirname(__FILE__) . '/tar_makegz.phar.tar');
-@unlink(dirname(__FILE__) . '/tar_makegz2.phar.tar');
+@unlink(dirname(__FILE__) . '/tar_makegz_b.phar.tar');
?>
--EXPECTF--
bool(true)
--TEST--
-Phar: tar-based phar, externally created tar with no stub, Phar->getStub()
+Phar: tar-based phar, third-party tar with no stub, Phar->getStub()
--SKIPIF--
<?php if (!extension_loaded('phar')) die('skip'); ?>
<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
phar.readonly=1
--FILE--
<?php
-include dirname(__FILE__) . '/tarmaker.php.inc';
-$fname = dirname(__FILE__) . '/tar_004.phar';
-$pname = 'phar://' . $fname;
+include dirname(__FILE__) . '/files/tarmaker.php.inc';
+$fname = dirname(__FILE__) . '/tar_004.phar.tar';
+$alias = 'phar://' . $fname;
-$a = new tarmaker($fname, 'none');
-$a->init();
-$a->addFile('tar_004.php', '<?php var_dump(__FILE__);');
-$a->addFile('internal/file/here', "hi there!\n");
-$a->close();
+$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->close();
+
+$phar = new Phar($fname);
+var_dump($phar->getStub());
-$b = new Phar($fname);
-var_dump($b->getStub());
?>
===DONE===
--CLEAN--
?>
--EXPECTF--
string(0) ""
-===DONE===
\ No newline at end of file
+===DONE===
+++ /dev/null
-<?php
-// stolen from PEAR2_Pyrus_Developer_Creator_Tar by Greg Beaver, the original author, for use in unit tests
-class tarmaker
-{
- /**
- * Path to archive file
- *
- * @var string
- */
- protected $archive;
- /**
- * Temporary stream used for creating the archive
- *
- * @var stream
- */
- protected $tmp;
- protected $path;
- protected $compress;
- function __construct($path, $compress = 'zlib')
- {
- $this->compress = $compress;
- if ($compress === 'bz2' && !function_exists('bzopen')) {
- throw new PEAR2_Pyrus_Developer_Creator_Exception(
- 'bzip2 extension not available');
- }
- if ($compress === 'zlib' && !function_exists('gzopen')) {
- throw new PEAR2_Pyrus_Developer_Creator_Exception(
- 'zlib extension not available');
- }
- $this->path = $path;
- }
-
- /**
- * save a file inside this package
- *
- * This code is modified from Vincent Lascaux's File_Archive
- * package, which is licensed under the LGPL license.
- * @param string relative path within the package
- * @param string|resource file contents or open file handle
- */
- function addFile($path, $fileOrStream, $stat = null)
- {
- clearstatcache();
- if ($stat === null) {
- if (is_resource($fileOrStream)) {
- $stat = fstat($fileOrStream);
- } else {
- $stat = array(
- 'mode' => 0x8000 + 0644,
- 'uid' => 0,
- 'gid' => 0,
- 'size' => strlen($fileOrStream),
- 'mtime' => time(),
- );
- }
- }
-
- $link = null;
- if ($stat['mode'] & 0x4000) {
- $type = 5; // Directory
- } else if ($stat['mode'] & 0x8000) {
- $type = 0; // Regular
- } else if ($stat['mode'] & 0xA000) {
- $type = 1; // Link
- $link = @readlink($current);
- } else {
- $type = 9; // Unknown
- }
-
- $filePrefix = '';
- if (strlen($path) > 255) {
- throw new Exception(
- "$path is too long, must be 255 characters or less"
- );
- } else if (strlen($path) > 100) {
- $filePrefix = substr($path, 0, strlen($path)-100);
- $path = substr($path, -100);
- }
-
- $block = pack('a100a8a8a8a12A12',
- $path,
- decoct($stat['mode']),
- sprintf('%6s ',decoct($stat['uid'])),
- sprintf('%6s ',decoct($stat['gid'])),
- sprintf('%11s ',decoct($stat['size'])),
- sprintf('%11s ',decoct($stat['mtime']))
- );
-
- $blockend = pack('a1a100a6a2a32a32a8a8a155a12',
- $type,
- $link,
- 'ustar',
- '00',
- 'Pyrus',
- 'Pyrus',
- '',
- '',
- $filePrefix,
- '');
-
- $checkheader = array_merge(str_split($block), str_split($blockend));
- if (!function_exists('_pear2tarchecksum')) {
- function _pear2tarchecksum($a, $b) {return $a + ord($b);}
- }
- $checksum = 256; // 8 * ord(' ');
- $checksum += array_reduce($checkheader, '_pear2tarchecksum');
-
- $checksum = pack('a8', sprintf('%6s ', decoct($checksum)));
-
- fwrite($this->tmp, $block . $checksum . $blockend, 512);
- if (is_resource($fileOrStream)) {
- stream_copy_to_stream($fileOrStream, $this->tmp);
- if ($stat['size'] % 512) {
- fwrite($this->tmp, str_repeat("\0", 512 - $stat['size'] % 512));
- }
- } else {
- fwrite($this->tmp, $fileOrStream);
- if (strlen($fileOrStream) % 512) {
- fwrite($this->tmp, str_repeat("\0", 512 - strlen($fileOrStream) % 512));
- }
- }
- }
-
- /**
- * Initialize the package creator
- */
- function init()
- {
- switch ($this->compress) {
- case 'zlib' :
- $this->tmp = gzopen($this->path, 'wb');
- break;
- case 'bz2' :
- $this->tmp = bzopen($this->path, 'w');
- break;
- case 'none' :
- $this->tmp = fopen($this->path, 'wb');
- break;
- default :
- throw new Exception(
- 'unknown compression type ' . $this->compress);
- }
- }
-
- /**
- * Create an internal directory, creating parent directories as needed
- *
- * @param string $dir
- */
- function mkdir($dir)
- {
- $this->addFile($dir, "", array(
- 'mode' => 0x4000 + 0644,
- 'uid' => 0,
- 'gid' => 0,
- 'size' => 0,
- 'mtime' => time(),
- ));
- }
-
- /**
- * Finish saving the package
- */
- function close()
- {
- fwrite($this->tmp, pack('a1024', ''));
- fclose($this->tmp);
- }
-}
\ No newline at end of file