1--TEST--
2Phar::convertToZip()
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') . '.2.phar.zip';
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
25$phar = new Phar($fname);
26var_dump($phar->isFileFormat(Phar::ZIP));
27var_dump($phar->getStub());
28
29$phar = $phar->convertToExecutable(Phar::ZIP);
30var_dump($phar->isFileFormat(Phar::ZIP));
31var_dump($phar->getStub());
32
33copy($fname2, $fname3);
34
35$phar = new Phar($fname3);
36var_dump($phar->isFileFormat(Phar::ZIP));
37var_dump($phar->getStub());
38?>
39--CLEAN--
40<?php
41unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
42unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar');
43unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.2.phar.zip');
44__HALT_COMPILER();
45?>
46--EXPECT--
47bool(false)
48string(48) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>"
49bool(true)
50string(60) "<?php // zip-based phar archive stub file
51__HALT_COMPILER();"
52bool(true)
53string(60) "<?php // zip-based phar archive stub file
54__HALT_COMPILER();"
55