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