1--TEST--
2Phar::startBuffering()/setStub()/stopBuffering() tar-based
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.readonly=0
9--FILE--
10<?php
11$p = new Phar(__DIR__ . '/phar_begin_setstub_commit.phar.tar', 0, 'phar_begin_setstub_commit.phar');
12var_dump($p->isFileFormat(Phar::TAR));
13//var_dump($p->getStub());
14var_dump($p->isBuffering());
15$p->startBuffering();
16var_dump($p->isBuffering());
17$p['a.php'] = '<?php var_dump("Hello");';
18$p->setStub('<?php var_dump("First"); Phar::mapPhar("phar_begin_setstub_commit.phar"); __HALT_COMPILER(); ?>');
19include 'phar://phar_begin_setstub_commit.phar/a.php';
20var_dump($p->getStub());
21$p['b.php'] = '<?php var_dump("World");';
22$p->setStub('<?php var_dump("Second"); Phar::mapPhar("phar_begin_setstub_commit.phar"); __HALT_COMPILER();');
23include 'phar://phar_begin_setstub_commit.phar/b.php';
24var_dump($p->getStub());
25$p->stopBuffering();
26echo "===COMMIT===\n";
27var_dump($p->isBuffering());
28include 'phar://phar_begin_setstub_commit.phar/a.php';
29include 'phar://phar_begin_setstub_commit.phar/b.php';
30var_dump($p->getStub());
31?>
32===DONE===
33--CLEAN--
34<?php
35unlink(__DIR__ . '/phar_begin_setstub_commit.phar.tar');
36?>
37--EXPECTF--
38bool(true)
39bool(false)
40bool(true)
41string(5) "Hello"
42string(%d) "<?php var_dump("First"); Phar::mapPhar("phar_begin_setstub_commit.phar"); __HALT_COMPILER(); ?>
43"
44string(5) "World"
45string(%d) "<?php var_dump("Second"); Phar::mapPhar("phar_begin_setstub_commit.phar"); __HALT_COMPILER(); ?>
46"
47===COMMIT===
48bool(false)
49string(5) "Hello"
50string(5) "World"
51string(%d) "<?php var_dump("Second"); Phar::mapPhar("phar_begin_setstub_commit.phar"); __HALT_COMPILER(); ?>
52"
53===DONE===
54