1--TEST-- 2Phar::convertToPhar() with global metadata 3--SKIPIF-- 4<?php if (!extension_loaded("phar")) die("skip"); ?> 5<?php if (!extension_loaded("zlib")) die("skip"); ?> 6--INI-- 7phar.require_hash=0 8phar.readonly=0 9--FILE-- 10<?php 11 12$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar'; 13$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '2.phar'; 14 15$phar = new Phar($fname); 16$phar['a.txt'] = 'some text'; 17$phar->setMetadata('hi'); 18$phar->stopBuffering(); 19var_dump($phar->isFileFormat(Phar::TAR)); 20var_dump(strlen($phar->getStub())); 21var_dump($phar->getMetadata()); 22 23$phar = $phar->convertToExecutable(Phar::TAR); 24var_dump($phar->isFileFormat(Phar::TAR)); 25var_dump($phar->getStub()); 26var_dump($phar->getMetadata()); 27 28$phar['a'] = 'hi there'; 29 30$phar = $phar->convertToExecutable(Phar::PHAR, Phar::GZ); 31var_dump($phar->isFileFormat(Phar::PHAR)); 32var_dump($phar->isCompressed()); 33var_dump(strlen($phar->getStub())); 34var_dump($phar->getMetadata()); 35 36copy($fname . '.gz', $fname2); 37 38$phar = new Phar($fname2); 39var_dump($phar->isFileFormat(Phar::PHAR)); 40var_dump($phar->isCompressed() == Phar::GZ); 41var_dump(strlen($phar->getStub())); 42var_dump($phar->getMetadata()); 43 44?> 45--CLEAN-- 46<?php 47unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.gz'); 48unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '2.phar'); 49unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar'); 50unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); 51unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar.gz'); 52__HALT_COMPILER(); 53?> 54--EXPECT-- 55bool(false) 56int(6641) 57string(2) "hi" 58bool(true) 59string(60) "<?php // tar-based phar archive stub file 60__HALT_COMPILER();" 61string(2) "hi" 62bool(true) 63int(4096) 64int(6641) 65string(2) "hi" 66bool(true) 67bool(true) 68int(6641) 69string(2) "hi" 70