1--TEST--
2Phar::setStub()/getStub() zip-based
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.zip';
12
13$phar = new Phar($fname);
14$phar->setStub($stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>' . "\r\n");
15$phar->setAlias('hio');
16$phar['a'] = 'a';
17$phar->stopBuffering();
18
19var_dump($phar->getStub());
20var_dump($phar->getStub() == $stub);
21
22$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
23try
24{
25	$phar->setStub($newstub);
26}
27catch(exception $e)
28{
29	echo 'Exception: ' . $e->getMessage() . "\n";
30}
31var_dump($phar->getStub());
32var_dump($phar->getStub() == $stub);
33$phar->stopBuffering();
34var_dump($phar->getStub());
35var_dump($phar->getStub() == $stub);
36
37?>
38===DONE===
39--CLEAN--
40<?php
41unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
42__HALT_COMPILER();
43?>
44--EXPECTF--
45string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
46"
47bool(true)
48Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.zip"
49string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
50"
51bool(true)
52string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
53"
54bool(true)
55===DONE===
56