1--TEST--
2Phar::setStub()/stopBuffering() 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$p = new Phar(__DIR__ . '/phar_commitwrite.phar.tar', 0, 'phar_commitwrite.phar');
11$p['file1.txt'] = 'hi';
12$p->stopBuffering();
13var_dump($p->getStub());
14$p->setStub("<?php
15function __autoload(\$class)
16{
17    include 'phar://' . str_replace('_', '/', \$class);
18}
19Phar::mapPhar('phar_commitwrite.phar');
20include 'phar://phar_commitwrite.phar/startup.php';
21__HALT_COMPILER();
22?>");
23var_dump($p->getStub());
24var_dump($p->isFileFormat(Phar::TAR));
25?>
26===DONE===
27--CLEAN--
28<?php
29unlink(__DIR__ . '/phar_commitwrite.phar.tar');
30?>
31--EXPECTF--
32string(60) "<?php // tar-based phar archive stub file
33__HALT_COMPILER();"
34string(%d) "<?php
35function __autoload($class)
36{
37    include 'phar://' . str_replace('_', '/', $class);
38}
39Phar::mapPhar('phar_commitwrite.phar');
40include 'phar://phar_commitwrite.phar/startup.php';
41__HALT_COMPILER(); ?>
42"
43bool(true)
44===DONE===
45