xref: /PHP-8.0/ext/phar/tests/phar_oo_002.phpt (revision f8d79582)
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('\\', '/', __DIR__), '*', $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('\\', '/', __DIR__), '*', $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--CLEAN--
49<?php
50unlink(__DIR__ . '/files/phar_oo_002.phar.php');
51__halt_compiler();
52?>
53--EXPECTF--
54string(41) "phar://*/files/phar_oo_002.phar.php%ca.php"
55string(5) "a.php"
56int(32)
57string(4) "file"
58bool(false)
59bool(true)
60bool(false)
61bool(true)
62bool(false)
63bool(false)
64int(%d)
65int(%d)
66int(%d)
67string(37) "phar://*/files/phar_oo_002.phar.php%cb"
68string(1) "b"
69int(0)
70string(3) "dir"
71bool(false)
72bool(true)
73bool(true)
74bool(false)
75bool(true)
76bool(false)
77int(%d)
78int(%d)
79int(%d)
80string(41) "phar://*/files/phar_oo_002.phar.php%cb.php"
81string(5) "b.php"
82int(32)
83string(4) "file"
84bool(false)
85bool(true)
86bool(false)
87bool(true)
88bool(false)
89bool(false)
90int(%d)
91int(%d)
92int(%d)
93string(41) "phar://*/files/phar_oo_002.phar.php%ce.php"
94string(5) "e.php"
95int(32)
96string(4) "file"
97bool(false)
98bool(true)
99bool(false)
100bool(true)
101bool(false)
102bool(false)
103int(%d)
104int(%d)
105int(%d)
106==RECURSIVE==
107string(41) "phar://*/files/phar_oo_002.phar.php%ca.php"
108string(5) "a.php"
109int(32)
110bool(false)
111NULL
112int(0)
113string(43) "phar://*/files/phar_oo_002.phar.php/b%cc.php"
114string(5) "c.php"
115int(34)
116bool(false)
117NULL
118int(0)
119string(43) "phar://*/files/phar_oo_002.phar.php/b%cd.php"
120string(5) "d.php"
121int(34)
122bool(false)
123NULL
124int(0)
125string(41) "phar://*/files/phar_oo_002.phar.php%cb.php"
126string(5) "b.php"
127int(32)
128bool(false)
129NULL
130int(0)
131string(41) "phar://*/files/phar_oo_002.phar.php%ce.php"
132string(5) "e.php"
133int(32)
134bool(false)
135NULL
136int(0)
137