1--TEST-- 2Phar::convertToZip|Tar|Phar() repeated (phar_based archives) 3--SKIPIF-- 4<?php if (!extension_loaded("phar")) die("skip"); ?> 5--INI-- 6phar.require_hash=0 7phar.readonly=0 8--FILE-- 9<?php 10 11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar'; 12$pname = 'phar://' . $fname; 13$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip'; 14$fname3 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar'; 15$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>'; 16$file = $stub; 17 18$files = array(); 19$files['a'] = 'a'; 20$files['b'] = 'b'; 21$files['c'] = 'c'; 22 23include 'files/phar_test.inc'; 24 25echo "=================== new Phar() =======================\n"; 26$phar = new Phar($fname); 27var_dump($phar->isFileFormat(Phar::PHAR)); 28var_dump($phar->isFileFormat(Phar::TAR)); 29var_dump($phar->isFileFormat(Phar::ZIP)); 30var_dump($phar->getStub()); 31var_dump($phar->getAlias()); 32 33echo "================= convertToTar() =====================\n"; 34 35$phar = $phar->convertToExecutable(Phar::TAR); 36var_dump($phar->isFileFormat(Phar::PHAR)); 37var_dump($phar->isFileFormat(Phar::TAR)); 38var_dump($phar->isFileFormat(Phar::ZIP)); 39var_dump($phar->getStub()); 40var_dump($phar->getAlias()); 41 42echo "================= convertToZip() =====================\n"; 43 44$phar = $phar->convertToExecutable(Phar::ZIP); 45var_dump($phar->isFileFormat(Phar::PHAR)); 46var_dump($phar->isFileFormat(Phar::TAR)); 47var_dump($phar->isFileFormat(Phar::ZIP)); 48var_dump($phar->getStub()); 49var_dump($phar->getAlias()); 50 51echo "================= convertToPhar() ====================\n"; 52 53$phar = $phar->convertToExecutable(Phar::PHAR, Phar::NONE, '.2.phar'); 54var_dump($phar->isFileFormat(Phar::PHAR)); 55var_dump($phar->isFileFormat(Phar::TAR)); 56var_dump($phar->isFileFormat(Phar::ZIP)); 57var_dump(strlen($phar->getStub())); 58var_dump($phar->getAlias()); 59 60echo "================= convertToZip() =====================\n"; 61 62$phar = $phar->convertToExecutable(Phar::ZIP, Phar::NONE, '.2.phar.zip'); 63var_dump($phar->isFileFormat(Phar::PHAR)); 64var_dump($phar->isFileFormat(Phar::TAR)); 65var_dump($phar->isFileFormat(Phar::ZIP)); 66var_dump($phar->getStub()); 67var_dump($phar->getAlias()); 68 69echo "================= convertToTar() =====================\n"; 70 71$phar = $phar->convertToExecutable(Phar::TAR, Phar::NONE, '2.phar.tar'); 72var_dump($phar->isFileFormat(Phar::PHAR)); 73var_dump($phar->isFileFormat(Phar::TAR)); 74var_dump($phar->isFileFormat(Phar::ZIP)); 75var_dump($phar->getStub()); 76var_dump($phar->getAlias()); 77 78echo "================= convertToZip() =====================\n"; 79 80$phar = $phar->convertToExecutable(Phar::ZIP, Phar::NONE, '3.phar.zip'); 81var_dump($phar->isFileFormat(Phar::PHAR)); 82var_dump($phar->isFileFormat(Phar::TAR)); 83var_dump($phar->isFileFormat(Phar::ZIP)); 84var_dump($phar->getStub()); 85var_dump($phar->getAlias()); 86 87?> 88--CLEAN-- 89<?php 90unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); 91unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); 92unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar'); 93unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.phar.zip'); 94unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.2.phar.tar'); 95unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar'); 96unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.2.2.3.phar.zip'); 97unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.3.phar.tar'); 98unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.3.phar'); 99?> 100--EXPECTF-- 101=================== new Phar() ======================= 102bool(true) 103bool(false) 104bool(false) 105string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>" 106string(3) "hio" 107================= convertToTar() ===================== 108bool(false) 109bool(true) 110bool(false) 111string(60) "<?php // tar-based phar archive stub file 112__HALT_COMPILER();" 113string(%d) "%sphar_convert_repeated.phar.tar" 114================= convertToZip() ===================== 115bool(false) 116bool(false) 117bool(true) 118string(60) "<?php // zip-based phar archive stub file 119__HALT_COMPILER();" 120NULL 121================= convertToPhar() ==================== 122bool(true) 123bool(false) 124bool(false) 125int(6641) 126NULL 127================= convertToZip() ===================== 128bool(false) 129bool(false) 130bool(true) 131string(60) "<?php // zip-based phar archive stub file 132__HALT_COMPILER();" 133NULL 134================= convertToTar() ===================== 135bool(false) 136bool(true) 137bool(false) 138string(60) "<?php // tar-based phar archive stub file 139__HALT_COMPILER();" 140NULL 141================= convertToZip() ===================== 142bool(false) 143bool(false) 144bool(true) 145string(60) "<?php // zip-based phar archive stub file 146__HALT_COMPILER();" 147NULL 148