xref: /PHP-7.3/ext/phar/tests/phar_oo_004.phpt (revision 17ccbeec)
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===DONE===
77--CLEAN--
78<?php
79unlink(dirname(__FILE__) . '/files/phar_oo_004.phar.php');
80__halt_compiler();
81?>
82--EXPECT--
83int(0)
84string(5) "a.php"
85bool(false)
86bool(false)
87int(1)
88string(1) "b"
89bool(true)
90bool(false)
91int(2)
92string(5) "b.php"
93bool(false)
94bool(false)
95int(3)
96string(5) "e.php"
97bool(false)
98bool(false)
99===MANUAL===
100MyDirectoryIterator::__construct
101MyDirectoryIterator::rewind
102MyDirectoryIterator::valid
103MyDirectoryIterator::current
104MyDirectoryIterator::key
105int(0)
106string(5) "a.php"
107MyDirectoryIterator::next
108MyDirectoryIterator::valid
109MyDirectoryIterator::current
110MyDirectoryIterator::key
111int(1)
112string(1) "b"
113MyDirectoryIterator::next
114MyDirectoryIterator::valid
115MyDirectoryIterator::current
116MyDirectoryIterator::key
117int(2)
118string(5) "b.php"
119MyDirectoryIterator::next
120MyDirectoryIterator::valid
121MyDirectoryIterator::current
122MyDirectoryIterator::key
123int(3)
124string(5) "e.php"
125MyDirectoryIterator::next
126MyDirectoryIterator::valid
127===DONE===
128