12
12
namespace Symfony \Component \Finder \Iterator ;
13
13
14
14
/**
15
- * This iterator just overrides the rewind method in order to correct a PHP bug.
15
+ * This iterator just overrides the rewind method in order to correct a PHP bug,
16
+ * which existed before version 5.5.23/5.6.7.
16
17
*
17
- * @see https://bugs.php.net/bug.php?id=49104
18
+ * @see https://bugs.php.net/bug.php?id=68557
18
19
*
19
20
* @author Alex Bogomazov
20
21
*/
@@ -28,22 +29,24 @@ abstract class FilterIterator extends \FilterIterator
28
29
*/
29
30
public function rewind ()
30
31
{
31
- $ iterator = $ this ;
32
- while ($ iterator instanceof \OuterIterator) {
33
- $ innerIterator = $ iterator ->getInnerIterator ();
32
+ if (version_compare (PHP_VERSION , '5.5.23 ' , '< ' )
33
+ or (version_compare (PHP_VERSION , '5.6.0 ' , '>= ' ) and version_compare (PHP_VERSION , '5.6.7 ' , '< ' ))) {
34
+ $ iterator = $ this ;
35
+ while ($ iterator instanceof \OuterIterator) {
36
+ $ innerIterator = $ iterator ->getInnerIterator ();
34
37
35
- if ($ innerIterator instanceof RecursiveDirectoryIterator) {
36
- if ($ innerIterator ->isRewindable ()) {
37
- $ innerIterator ->next ();
38
- $ innerIterator ->rewind ();
38
+ if ($ innerIterator instanceof RecursiveDirectoryIterator) {
39
+ if ($ innerIterator ->isRewindable ()) {
40
+ $ innerIterator ->next ();
41
+ $ innerIterator ->rewind ();
42
+ }
43
+ } elseif ($ iterator ->getInnerIterator () instanceof \FilesystemIterator) {
44
+ $ iterator ->getInnerIterator ()->next ();
45
+ $ iterator ->getInnerIterator ()->rewind ();
39
46
}
40
- } elseif ($ iterator ->getInnerIterator () instanceof \FilesystemIterator) {
41
- $ iterator ->getInnerIterator ()->next ();
42
- $ iterator ->getInnerIterator ()->rewind ();
47
+ $ iterator = $ iterator ->getInnerIterator ();
43
48
}
44
- $ iterator = $ iterator ->getInnerIterator ();
45
49
}
46
-
47
50
parent ::rewind ();
48
51
}
49
52
}
0 commit comments