1--TEST--
2Phar::isWriteable
3--EXTENSIONS--
4phar
5--INI--
6phar.readonly=0
7phar.require_hash=0
8--FILE--
9<?php
10$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.1.phar.php';
11$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.tar';
12$pname = 'phar://hio';
13$file = '<?php include "' . $pname . '/a.php"; __HALT_COMPILER(); ?>';
14
15$files = array();
16$files['a.php']   = '<?php echo "This is a\n"; include "'.$pname.'/b.php"; ?>';
17$files['dir/'] = '';
18$hasdir = 1;
19include 'files/phar_test.inc';
20$a = new Phar($fname);
21$b = new PharData($fname2);
22$b['test'] = 'hi';
23
24var_dump($a['a.php']->isWritable());
25var_dump($a['a.php']->isReadable());
26$a['a.php']->chmod(000);
27var_dump($a['a.php']->isWritable());
28var_dump($a['a.php']->isReadable());
29$a['a.php']->chmod(0666);
30var_dump($a['a.php']->isWritable());
31var_dump($a['a.php']->isReadable());
32ini_set('phar.readonly',1);
33clearstatcache();
34var_dump($a['a.php']->isWritable());
35var_dump($a['a.php']->isReadable());
36ini_set('phar.readonly',0);
37clearstatcache();
38var_dump($a['a.php']->isWritable());
39var_dump($a['a.php']->isReadable());
40?>
41archive
42<?php
43ini_set('phar.readonly',0);
44$p = new Phar('doesnotexisthere.phar');
45var_dump($p->isWritable());
46clearstatcache();
47var_dump($a->isWritable());
48var_dump($b->isWritable());
49ini_set('phar.readonly',1);
50clearstatcache();
51var_dump($a->isWritable());
52var_dump($b->isWritable());
53chmod($fname2, 000);
54clearstatcache();
55var_dump($a->isWritable());
56var_dump($b->isWritable());
57chmod($fname2, 0666);
58?>
59--CLEAN--
60<?php
61unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.1.phar.php');
62unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.tar');
63?>
64--EXPECT--
65bool(true)
66bool(true)
67bool(false)
68bool(false)
69bool(true)
70bool(true)
71bool(false)
72bool(true)
73bool(true)
74bool(true)
75archive
76bool(true)
77bool(true)
78bool(true)
79bool(false)
80bool(true)
81bool(false)
82bool(false)
83