1--TEST--
2Phar::convertToPhar() from zip
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 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar';
12$fname2 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '2.phar';
13$fname3 = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.3.phar';
14
15$phar = new Phar($fname);
16$phar['a.txt'] = 'some text';
17$phar->stopBuffering();
18var_dump($phar->isFileFormat(Phar::ZIP));
19var_dump(strlen($phar->getStub()));
20
21$phar = $phar->convertToExecutable(Phar::ZIP);
22var_dump($phar->isFileFormat(Phar::ZIP));
23var_dump($phar->getStub());
24
25$phar['a'] = 'hi there';
26
27$phar = $phar->convertToExecutable(Phar::PHAR, Phar::NONE, '.3.phar');
28var_dump($phar->isFileFormat(Phar::PHAR));
29var_dump(strlen($phar->getStub()));
30
31copy($fname3, $fname2);
32
33$phar = new Phar($fname2);
34var_dump($phar->isFileFormat(Phar::PHAR));
35var_dump(strlen($phar->getStub()));
36
37?>
38===DONE===
39--CLEAN--
40<?php
41unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
42unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
43unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '2.phar');
44unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.3.phar');
45__HALT_COMPILER();
46?>
47--EXPECT--
48bool(false)
49int(6673)
50bool(true)
51string(60) "<?php // zip-based phar archive stub file
52__HALT_COMPILER();"
53bool(true)
54int(6673)
55bool(true)
56int(6673)
57===DONE===
58