1--TEST--
2Phar: invalid set alias or stub via array access
3--EXTENSIONS--
4phar
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--EXPECTF--
37Cannot set stub ".phar/stub.php" directly in phar "%sinvalid_setstubalias.phar.tar", use setStub
38Cannot set alias ".phar/alias.txt" directly in phar "%sinvalid_setstubalias.phar.tar", use setAlias
39Cannot set stub ".phar/stub.php" directly in phar "%sinvalid_setstubalias.phar.zip", use setStub
40Cannot set alias ".phar/alias.txt" directly in phar "%sinvalid_setstubalias.phar.zip", use setAlias
41