1--TEST--
2Phar::setStub()/stopBuffering() tar-based
3--EXTENSIONS--
4phar
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
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());
23var_dump($p->isFileFormat(Phar::TAR));
24?>
25--CLEAN--
26<?php
27unlink(__DIR__ . '/phar_commitwrite.phar.tar');
28?>
29--EXPECTF--
30string(60) "<?php // tar-based phar archive stub file
31__HALT_COMPILER();"
32string(%d) "<?php
33spl_autoload_register(function($class) {
34    include 'phar://' . str_replace('_', '/', $class);
35});
36Phar::mapPhar('phar_commitwrite.phar');
37include 'phar://phar_commitwrite.phar/startup.php';
38__HALT_COMPILER(); ?>
39"
40bool(true)
41