1--TEST-- 2Phar: addFile/addFromString 3--SKIPIF-- 4<?php if (!extension_loaded("phar")) die("skip"); ?> 5--INI-- 6phar.readonly=0 7--FILE-- 8<?php 9$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.phar.php'; 10$pname = 'phar://' . $fname; 11$phar = new Phar($fname); 12$phar->addFromString('a', 'hi'); 13echo file_get_contents($pname . '/a') . "\n"; 14$phar->addFile($pname . '/a', 'b'); 15echo file_get_contents($pname . '/b') . "\n"; 16try { 17$phar->addFile($pname . '/a'); 18} catch (Exception $e) { 19echo $e->getMessage() . "\n"; 20} 21try { 22$phar->addFile($pname . '/a', 'a'); 23} catch (Exception $e) { 24echo $e->getMessage() . "\n"; 25} 26try { 27$phar->addFile(dirname(__FILE__) . '/does/not/exist'); 28} catch (Exception $e) { 29echo $e->getMessage() . "\n"; 30} 31try { 32$phar->addFile($pname . '/a', '.phar/stub.php'); 33} catch (Exception $e) { 34echo $e->getMessage() . "\n"; 35} 36try { 37$phar->addFromString('.phar/stub.php', 'hi'); 38} catch (Exception $e) { 39echo $e->getMessage() . "\n"; 40} 41?> 42===DONE=== 43--CLEAN-- 44<?php unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.php'); ?> 45--EXPECTF-- 46hi 47hi 48Entry phar://%saddfuncs.phar.php/a does not exist and cannot be created: phar error: invalid path "phar://%saddfuncs.phar.php/a" contains double slash 49Entry a does not exist and cannot be created: phar error: file "a" in phar "%saddfuncs.phar.php" cannot be opened for writing, readable file pointers are open 50phar error: unable to open file "%s/does/not/exist" to add to phar archive 51Cannot create any files in magic ".phar" directory 52Cannot create any files in magic ".phar" directory 53===DONE=== 54