xref: /php-src/ext/spl/tests/bug77263.phpt (revision b3e08881)
1--TEST--
2Bug #77263 (Segfault when using 2 RecursiveFilterIterator)
3--FILE--
4<?php
5$dir = __DIR__ . '/bug77263';
6mkdir($dir);
7mkdir("$dir/subdir");
8touch("$dir/file1");
9touch("$dir/subdir/file2");
10
11class Filter1 extends RecursiveFilterIterator {
12    public function accept(): bool { return $this->getInnerIterator()->getSubPathname() != ''; }
13}
14
15class Filter2 extends RecursiveFilterIterator {
16    public function accept(): bool { return $this->getInnerIterator()->getSubPathname() != ' '; }
17}
18
19$iterator = new RecursiveDirectoryIterator($dir, FilesystemIterator::SKIP_DOTS );
20
21$iterator = new Filter1( $iterator );
22
23$iterator = new Filter2( $iterator );
24
25$iterator = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD );
26
27foreach ( $iterator as $item ) {
28}
29?>
30OK
31--CLEAN--
32<?php
33$dir = __DIR__ . '/bug77263';
34unlink("$dir/file1");
35unlink("$dir/subdir/file2");
36rmdir("$dir/subdir");
37rmdir($dir);
38?>
39--EXPECT--
40OK
41