xref: /PHP-7.3/ext/phar/tests/phar_oo_002.phpt (revision 17ccbeec)
1--TEST--
2Phar object: iterator & entries
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.readonly=1
9phar.require_hash=0
10--FILE--
11<?php
12
13require_once 'files/phar_oo_test.inc';
14
15$phar = new Phar($fname);
16$phar->setInfoClass('SplFileInfo');
17foreach($phar as $name => $ent)
18{
19	var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
20	var_dump($ent->getFilename());
21	var_dump($ent->getSize());
22	var_dump($ent->getType());
23	var_dump($ent->isWritable());
24	var_dump($ent->isReadable());
25	var_dump($ent->isExecutable());
26	var_dump($ent->isFile());
27	var_dump($ent->isDir());
28	var_dump($ent->isLink());
29	var_dump($ent->getCTime());
30	var_dump($ent->getMTime());
31	var_dump($ent->getATime());
32}
33
34echo "==RECURSIVE==\n";
35
36$phar = new Phar($fname);
37foreach(new RecursiveIteratorIterator($phar) as $name => $ent)
38{
39	var_dump(str_replace(str_replace('\\', '/', dirname(__FILE__)), '*', $name));
40	var_dump(str_replace('\\', '/', $ent->getFilename()));
41	var_dump($ent->getCompressedSize());
42	var_dump($ent->isCRCChecked());
43	var_dump($ent->isCRCChecked() ? $ent->getCRC32() : NULL);
44	var_dump($ent->getPharFlags());
45}
46
47?>
48===DONE===
49--CLEAN--
50<?php
51unlink(dirname(__FILE__) . '/files/phar_oo_002.phar.php');
52__halt_compiler();
53?>
54--EXPECTF--
55string(41) "phar://*/files/phar_oo_002.phar.php%ca.php"
56string(5) "a.php"
57int(32)
58string(4) "file"
59bool(false)
60bool(true)
61bool(false)
62bool(true)
63bool(false)
64bool(false)
65int(%d)
66int(%d)
67int(%d)
68string(37) "phar://*/files/phar_oo_002.phar.php%cb"
69string(1) "b"
70int(0)
71string(3) "dir"
72bool(false)
73bool(true)
74bool(true)
75bool(false)
76bool(true)
77bool(false)
78int(%d)
79int(%d)
80int(%d)
81string(41) "phar://*/files/phar_oo_002.phar.php%cb.php"
82string(5) "b.php"
83int(32)
84string(4) "file"
85bool(false)
86bool(true)
87bool(false)
88bool(true)
89bool(false)
90bool(false)
91int(%d)
92int(%d)
93int(%d)
94string(41) "phar://*/files/phar_oo_002.phar.php%ce.php"
95string(5) "e.php"
96int(32)
97string(4) "file"
98bool(false)
99bool(true)
100bool(false)
101bool(true)
102bool(false)
103bool(false)
104int(%d)
105int(%d)
106int(%d)
107==RECURSIVE==
108string(41) "phar://*/files/phar_oo_002.phar.php%ca.php"
109string(5) "a.php"
110int(32)
111bool(false)
112NULL
113int(0)
114string(43) "phar://*/files/phar_oo_002.phar.php/b%cc.php"
115string(5) "c.php"
116int(34)
117bool(false)
118NULL
119int(0)
120string(43) "phar://*/files/phar_oo_002.phar.php/b%cd.php"
121string(5) "d.php"
122int(34)
123bool(false)
124NULL
125int(0)
126string(41) "phar://*/files/phar_oo_002.phar.php%cb.php"
127string(5) "b.php"
128int(32)
129bool(false)
130NULL
131int(0)
132string(41) "phar://*/files/phar_oo_002.phar.php%ce.php"
133string(5) "e.php"
134int(32)
135bool(false)
136NULL
137int(0)
138===DONE===
139