1--TEST--
2Phar::setStub()/getStub() tar-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.tar';
12
13$phar = new Phar($fname);
14$stub = '<?php echo "first stub\n"; __HALT_COMPILER(); ?>' ."\r\n";
15$phar->setStub($stub);
16$phar->setAlias('hio');
17$phar['a'] = 'a';
18$phar->stopBuffering();
19
20var_dump($phar->getStub());
21var_dump($phar->getStub() == $stub);
22
23$newstub = '<?php echo "second stub\n"; _x_HALT_COMPILER(); ?>';
24
25try {
26	$phar->setStub($newstub);
27} catch(exception $e) {
28	echo 'Exception: ' . $e->getMessage() . "\n";
29}
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.tar');
42__HALT_COMPILER();
43?>
44--EXPECTF--
45string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
46"
47bool(true)
48Exception: illegal stub for tar-based phar "%sphar_stub_error.phar.tar"
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