1--TEST--
2Phar: Phar::setDefaultStub() with and without arg, zip-based phar
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5--INI--
6phar.readonly=0
7--FILE--
8<?php
9
10$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.zip';
11
12$phar = new Phar($fname);
13$phar['a.php'] = '<php echo "this is a\n"; ?>';
14$phar['b.php'] = '<php echo "this is b\n"; ?>';
15$phar->setStub('<?php echo "Hello World\n"; __HALT_COMPILER(); ?>');
16
17var_dump($phar->getStub());
18
19echo "============================================================================\n";
20echo "============================================================================\n";
21
22try {
23	$phar->setDefaultStub();
24	$phar->stopBuffering();
25} catch(Exception $e) {
26	echo $e->getMessage(). "\n";
27}
28
29var_dump($phar->getStub());
30
31echo "============================================================================\n";
32echo "============================================================================\n";
33
34try {
35	$phar->setDefaultStub('my/custom/thingy.php');
36	$phar->stopBuffering();
37} catch(Exception $e) {
38	echo $e->getMessage(). "\n";
39}
40
41var_dump($phar->getStub());
42
43echo "============================================================================\n";
44echo "============================================================================\n";
45
46try {
47	$phar->setDefaultStub('my/custom/thingy.php', 'the/web.php');
48	$phar->stopBuffering();
49} catch(Exception $e) {
50	echo $e->getMessage(). "\n";
51}
52
53var_dump($phar->getStub());
54
55?>
56===DONE===
57--CLEAN--
58<?php
59unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.zip');
60?>
61--EXPECTF--
62string(51) "<?php echo "Hello World\n"; __HALT_COMPILER(); ?>
63"
64============================================================================
65============================================================================
66string(60) "<?php // zip-based phar archive stub file
67__HALT_COMPILER();"
68============================================================================
69============================================================================
70
71Warning: Phar::setDefaultStub(): method accepts no arguments for a tar- or zip-based phar stub, 1 given in %sphar_setdefaultstub.php on line %d
72string(60) "<?php // zip-based phar archive stub file
73__HALT_COMPILER();"
74============================================================================
75============================================================================
76
77Warning: Phar::setDefaultStub(): method accepts no arguments for a tar- or zip-based phar stub, 2 given in %sphar_setdefaultstub.php on line %d
78string(60) "<?php // zip-based phar archive stub file
79__HALT_COMPILER();"
80===DONE===
81