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