1--TEST--
2Phar::setStub()/stopBuffering()
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', 0, 'phar_commitwrite.phar');
11$p['file1.txt'] = 'hi';
12$p->stopBuffering();
13var_dump(strlen($p->getStub()));
14$p->setStub("<?php
15spl_autoload_register(function(\$class) {
16    include 'phar://' . str_replace('_', '/', \$class);
17});
18Phar::mapPhar('phar_commitwrite.phar');
19include 'phar://phar_commitwrite.phar/startup.php';
20__HALT_COMPILER();
21?>");
22var_dump($p->getStub());
23?>
24--CLEAN--
25<?php
26unlink(__DIR__ . '/phar_commitwrite.phar');
27__HALT_COMPILER();
28?>
29--EXPECTF--
30int(6641)
31string(%d) "<?php
32spl_autoload_register(function($class) {
33    include 'phar://' . str_replace('_', '/', $class);
34});
35Phar::mapPhar('phar_commitwrite.phar');
36include 'phar://phar_commitwrite.phar/startup.php';
37__HALT_COMPILER(); ?>
38"
39