xref: /PHP-8.0/ext/phar/tests/phar_oo_004.phpt (revision f8d79582)
1--TEST--
2Phar and DirectoryIterator
3--SKIPIF--
4<?php
5if (!extension_loaded("phar")) die("skip");
6?>
7--INI--
8phar.require_hash=0
9--FILE--
10<?php
11
12require_once 'files/phar_oo_test.inc';
13
14$it = new DirectoryIterator('phar://'.$fname);
15
16foreach($it as $name => $ent)
17{
18    var_dump($name);
19    var_dump($ent->getFilename());
20    var_dump($ent->isDir());
21    var_dump($ent->isDot());
22}
23
24?>
25===MANUAL===
26<?php
27
28class MyDirectoryIterator extends DirectoryIterator
29{
30    function __construct($dir)
31    {
32        echo __METHOD__ . "\n";
33        parent::__construct($dir);
34    }
35
36    function rewind()
37    {
38        echo __METHOD__ . "\n";
39        parent::rewind();
40    }
41
42    function valid()
43    {
44        echo __METHOD__ . "\n";
45        return parent::valid();
46    }
47
48    function key()
49    {
50        echo __METHOD__ . "\n";
51        return parent::key();
52    }
53
54    function current()
55    {
56        echo __METHOD__ . "\n";
57        return parent::current();
58    }
59
60    function next()
61    {
62        echo __METHOD__ . "\n";
63        parent::next();
64    }
65}
66
67$it = new MyDirectoryIterator('phar://'.$fname);
68
69foreach($it as $name => $ent)
70{
71    var_dump($name);
72    var_dump($ent->getFilename());
73}
74
75?>
76--CLEAN--
77<?php
78unlink(__DIR__ . '/files/phar_oo_004.phar.php');
79__halt_compiler();
80?>
81--EXPECT--
82int(0)
83string(5) "a.php"
84bool(false)
85bool(false)
86int(1)
87string(1) "b"
88bool(true)
89bool(false)
90int(2)
91string(5) "b.php"
92bool(false)
93bool(false)
94int(3)
95string(5) "e.php"
96bool(false)
97bool(false)
98===MANUAL===
99MyDirectoryIterator::__construct
100MyDirectoryIterator::rewind
101MyDirectoryIterator::valid
102MyDirectoryIterator::current
103MyDirectoryIterator::key
104int(0)
105string(5) "a.php"
106MyDirectoryIterator::next
107MyDirectoryIterator::valid
108MyDirectoryIterator::current
109MyDirectoryIterator::key
110int(1)
111string(1) "b"
112MyDirectoryIterator::next
113MyDirectoryIterator::valid
114MyDirectoryIterator::current
115MyDirectoryIterator::key
116int(2)
117string(5) "b.php"
118MyDirectoryIterator::next
119MyDirectoryIterator::valid
120MyDirectoryIterator::current
121MyDirectoryIterator::key
122int(3)
123string(5) "e.php"
124MyDirectoryIterator::next
125MyDirectoryIterator::valid
126