1--TEST-- 2Phar: invalid set alias or stub via array access 3--SKIPIF-- 4<?php if (!extension_loaded("phar")) die("skip"); ?> 5--INI-- 6phar.readonly=0 7--FILE-- 8<?php 9$fname = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.tar'; 10$fname2 = __DIR__ . '/' . basename(__FILE__, '.php') . '.phar.zip'; 11 12$p = new Phar($fname); 13try { 14 $p['.phar/stub.php'] = 'hi'; 15} catch (Exception $e) { 16 echo $e->getMessage() . "\n"; 17} 18try { 19 $p['.phar/alias.txt'] = 'hi'; 20} catch (Exception $e) { 21 echo $e->getMessage() . "\n"; 22} 23$p = new Phar($fname2); 24try { 25 $p['.phar/stub.php'] = 'hi'; 26} catch (Exception $e) { 27 echo $e->getMessage() . "\n"; 28} 29try { 30 $p['.phar/alias.txt'] = 'hi'; 31} catch (Exception $e) { 32 echo $e->getMessage() . "\n"; 33} 34 35?> 36===DONE=== 37--CLEAN-- 38<?php 39unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.tar'); 40unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar.zip'); 41?> 42--EXPECTF-- 43Cannot set stub ".phar/stub.php" directly in phar "%sinvalid_setstubalias.phar.tar", use setStub 44Cannot set alias ".phar/alias.txt" directly in phar "%sinvalid_setstubalias.phar.tar", use setAlias 45Cannot set stub ".phar/stub.php" directly in phar "%sinvalid_setstubalias.phar.zip", use setStub 46Cannot set alias ".phar/alias.txt" directly in phar "%sinvalid_setstubalias.phar.zip", use setAlias 47===DONE=== 48