1--TEST--
2Phar: PharFileInfo::__construct
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';
10$pname = 'phar://' . $fname;
11
12try {
13file_put_contents($fname, 'blah');
14$a = new PharFileInfo($pname . '/oops');
15} catch (Exception $e) {
16echo $e->getMessage() . "\n";
17unlink($fname);
18}
19
20try {
21$a = new PharFileInfo(array());
22} catch (TypeError $e) {
23echo $e->getMessage() . "\n";
24}
25
26$a = new Phar($fname);
27$a['a'] = 'hi';
28$b = $a['a'];
29
30try {
31$a = new PharFileInfo($pname . '/oops/I/do/not/exist');
32} catch (Exception $e) {
33echo $e->getMessage() . "\n";
34}
35
36try {
37$b->__construct('oops');
38} catch (Exception $e) {
39echo $e->getMessage() . "\n";
40}
41
42try {
43$a = new PharFileInfo(__FILE__);
44} catch (Exception $e) {
45echo $e->getMessage() . "\n";
46}
47?>
48--CLEAN--
49<?php unlink(__DIR__ . '/' . basename(__FILE__, '.clean.php') . '.phar'); ?>
50--EXPECTF--
51Cannot open phar file 'phar://%spharfileinfo_construct.phar/oops': internal corruption of phar "%spharfileinfo_construct.phar" (truncated entry)
52PharFileInfo::__construct(): Argument #1 ($filename) must be of type string, array given
53Cannot access phar file entry '%s' in archive '%s'
54Cannot call constructor twice
55'%s' is not a valid phar archive URL (must have at least phar://filename.phar)
56