--TEST--
Phar::convertToZip|Tar|Phar() repeated (phar_based archives)
--EXTENSIONS--
phar
--INI--
phar.require_hash=0
phar.readonly=0
--FILE--
<?php

$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar';
$pname = 'phar://' . $fname;
$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip';
$fname3 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar';
$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>';
$file = $stub;

$files = array();
$files['a'] = 'a';
$files['b'] = 'b';
$files['c'] = 'c';

include 'files/phar_test.inc';

echo "=================== new Phar() =======================\n";
$phar = new Phar($fname);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());

echo "================= convertToTar() =====================\n";

$phar = $phar->convertToExecutable(Phar::TAR);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());

echo "================= convertToZip() =====================\n";

$phar = $phar->convertToExecutable(Phar::ZIP);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());

echo "================= convertToPhar() ====================\n";

$phar = $phar->convertToExecutable(Phar::PHAR, Phar::NONE, '.2.phar');
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump(strlen($phar->getStub()));
var_dump($phar->getAlias());

echo "================= convertToZip() =====================\n";

$phar = $phar->convertToExecutable(Phar::ZIP, Phar::NONE, '.2.phar.zip');
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());

echo "================= convertToTar() =====================\n";

$phar = $phar->convertToExecutable(Phar::TAR, Phar::NONE, '2.phar.tar');
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());

echo "================= convertToZip() =====================\n";

$phar = $phar->convertToExecutable(Phar::ZIP, Phar::NONE, '3.phar.zip');
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());

?>
--CLEAN--
<?php
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.phar.zip');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.2.phar.tar');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar');
unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.2.3.phar.zip');
?>
--EXPECTF--
=================== new Phar() =======================
bool(true)
bool(false)
bool(false)
string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
string(3) "hio"
================= convertToTar() =====================
bool(false)
bool(true)
bool(false)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
string(%d) "%sphar_convert_repeated.phar.tar"
================= convertToZip() =====================
bool(false)
bool(false)
bool(true)
string(60) "<?php // zip-based phar archive stub file
__HALT_COMPILER();"
NULL
================= convertToPhar() ====================
bool(true)
bool(false)
bool(false)
int(6641)
NULL
================= convertToZip() =====================
bool(false)
bool(false)
bool(true)
string(60) "<?php // zip-based phar archive stub file
__HALT_COMPILER();"
NULL
================= convertToTar() =====================
bool(false)
bool(true)
bool(false)
string(60) "<?php // tar-based phar archive stub file
__HALT_COMPILER();"
NULL
================= convertToZip() =====================
bool(false)
bool(false)
bool(true)
string(60) "<?php // zip-based phar archive stub file
__HALT_COMPILER();"
NULL
