1--TEST--
2Phar: fopen a .phar for writing (existing file) tar-based
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.readonly=0
9phar.require_hash=0
10--FILE--
11<?php
12
13$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar';
14$alias = 'phar://' . $fname;
15
16$phar = new Phar($fname);
17$phar->setStub("<?php __HALT_COMPILER(); ?>");
18
19$files = array();
20
21$files['a.php'] = '<?php echo "This is a\n"; ?>';
22$files['b.php'] = '<?php echo "This is b\n"; ?>';
23$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
24
25foreach ($files as $n => $file) {
26	$phar[$n] = $file;
27}
28
29$phar->stopBuffering();
30ini_set('phar.readonly', 1);
31
32$fp = fopen($alias . '/b/c.php', 'wb');
33fwrite($fp, 'extra');
34fclose($fp);
35
36include $alias . '/b/c.php';
37
38?>
39
40===DONE===
41--CLEAN--
42<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); ?>
43--EXPECTF--
44Warning: fopen(phar://%sopen_for_write_existing_c.phar.tar/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_c.php on line %d
45
46Warning: fwrite() expects parameter 1 to be resource, bool given in %spen_for_write_existing_c.php on line %d
47
48Warning: fclose() expects parameter 1 to be resource, bool given in %spen_for_write_existing_c.php on line %d
49This is b/c
50
51===DONE===
52