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