1--TEST--
2Phar: fopen a .phar for writing (existing file)
3--SKIPIF--
4<?php if (!extension_loaded("phar")) die("skip"); ?>
5<?php if (version_compare(PHP_VERSION, "5.3", ">")) die("skip requires 5.2 or earlier"); ?>
6--INI--
7phar.readonly=1
8phar.require_hash=0
9--FILE--
10<?php
11$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php';
12$pname = 'phar://' . $fname;
13$file = "<?php __HALT_COMPILER(); ?>";
14
15$files = array();
16$files['a.php'] = '<?php echo "This is a\n"; ?>';
17$files['b.php'] = '<?php echo "This is b\n"; ?>';
18$files['b/c.php'] = '<?php echo "This is b/c\n"; ?>';
19include 'files/phar_test.inc';
20
21function err_handler($errno, $errstr, $errfile, $errline) {
22  echo "Catchable fatal error: $errstr in $errfile on line $errline\n";
23}
24
25set_error_handler("err_handler", E_RECOVERABLE_ERROR);
26
27$fp = fopen($pname . '/b/c.php', 'wb');
28fwrite($fp, 'extra');
29fclose($fp);
30include $pname . '/b/c.php';
31?>
32===DONE===
33--CLEAN--
34<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?>
35--EXPECTF--
36
37Warning: fopen(phar://%sopen_for_write_existing_b_5_2.phar.php/b/c.php): failed to open stream: phar error: write operations disabled by the php.ini setting phar.readonly in %sopen_for_write_existing_b_5_2.php on line %d
38
39Warning: fwrite(): supplied argument is not a valid stream resource in %spen_for_write_existing_b_5_2.php on line %d
40
41Warning: fclose(): supplied argument is not a valid stream resource in %spen_for_write_existing_b_5_2.php on line %d
42This is b/c
43===DONE===
44