1--TEST--
2Phar::setStub()/getStub() zip-based
3--EXTENSIONS--
4phar
5--INI--
6phar.require_hash=0
7phar.readonly=0
8--FILE--
9<?php
10
11$fname = __DIR__ . '/' . 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--CLEAN--
39<?php
40unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
41__HALT_COMPILER();
42?>
43--EXPECTF--
44string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
45"
46bool(true)
47Exception: illegal stub for zip-based phar "%sphar_stub_error.phar.zip"
48string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
49"
50bool(true)
51string(50) "<?php echo "first stub\n"; __HALT_COMPILER(); ?>
52"
53bool(true)
54