1--TEST-- 2PharData::convertToZip|Tar|Phar() repeated (phardata_based archives) 3--EXTENSIONS-- 4phar 5zlib 6--INI-- 7phar.readonly=1 8--FILE-- 9<?php 10 11$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.zip'; 12 13echo "=================== new PharData() ==================\n"; 14$phar = new PharData($fname); 15$phar['a'] = 'a'; 16$phar['b'] = 'b'; 17$phar['c'] = 'c'; 18 19var_dump($phar->isFileFormat(Phar::PHAR)); 20var_dump($phar->isFileFormat(Phar::TAR)); 21var_dump($phar->isFileFormat(Phar::ZIP)); 22var_dump($phar->getStub()); 23var_dump($phar->getAlias()); 24 25echo "================= convertToTar() =====================\n"; 26 27$phar = $phar->convertToData(Phar::TAR); 28var_dump($phar->isFileFormat(Phar::PHAR)); 29var_dump($phar->isFileFormat(Phar::TAR)); 30var_dump($phar->isFileFormat(Phar::ZIP)); 31var_dump($phar->getStub()); 32var_dump($phar->getAlias()); 33 34echo "================= convertToZip() =====================\n"; 35 36$phar = $phar->convertToData(Phar::ZIP, Phar::NONE, '.1.zip'); 37var_dump($phar->isFileFormat(Phar::PHAR)); 38var_dump($phar->isFileFormat(Phar::TAR)); 39var_dump($phar->isFileFormat(Phar::ZIP)); 40var_dump($phar->getStub()); 41var_dump($phar->getAlias()); 42 43echo "================= convertToPhar() ====================\n"; 44 45try { 46 $phar = $phar->convertToExecutable(Phar::PHAR); 47 var_dump($phar->isFileFormat(Phar::PHAR)); 48 var_dump($phar->isFileFormat(Phar::TAR)); 49 var_dump($phar->isFileFormat(Phar::ZIP)); 50 var_dump(strlen($phar->getStub())); 51 var_dump($phar->getAlias()); 52} catch(Exception $e) { 53 echo $e->getMessage()."\n"; 54} 55 56echo "================ convertToTar(GZ) ====================\n"; 57 58$phar = $phar->convertToData(Phar::TAR, Phar::GZ, '.2.tar'); 59var_dump($phar->isFileFormat(Phar::PHAR)); 60var_dump($phar->isFileFormat(Phar::TAR)); 61var_dump($phar->isFileFormat(Phar::ZIP)); 62var_dump($phar->getStub()); 63var_dump($phar->getAlias()); 64 65echo "================= convertToPhar() ====================\n"; 66 67try { 68 $phar = $phar->convertToExecutable(Phar::PHAR); 69 var_dump($phar->isFileFormat(Phar::PHAR)); 70 var_dump($phar->isFileFormat(Phar::TAR)); 71 var_dump($phar->isFileFormat(Phar::ZIP)); 72 var_dump(strlen($phar->getStub())); 73 var_dump($phar->getAlias()); 74} catch(Exception $e) { 75 echo $e->getMessage()."\n"; 76} 77?> 78--CLEAN-- 79<?php 80echo __DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.gz' . "\n"; 81 82unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.gz'); 83unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar.gz'); 84unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar'); 85unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.1.2.tar'); 86unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.zip'); 87unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.1.zip'); 88 89?> 90--EXPECT-- 91=================== new PharData() ================== 92bool(false) 93bool(false) 94bool(true) 95string(0) "" 96NULL 97================= convertToTar() ===================== 98bool(false) 99bool(true) 100bool(false) 101string(0) "" 102NULL 103================= convertToZip() ===================== 104bool(false) 105bool(false) 106bool(true) 107string(0) "" 108NULL 109================= convertToPhar() ==================== 110Cannot write out executable phar archive, phar is read-only 111================ convertToTar(GZ) ==================== 112bool(false) 113bool(true) 114bool(false) 115string(0) "" 116NULL 117================= convertToPhar() ==================== 118Cannot write out executable phar archive, phar is read-only 119