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, which existed before version 5.5.23 .
16
16
*
17
- * @see https://bugs.php.net/bug.php?id=49104
17
+ * @see https://bugs.php.net/bug.php?id=68557
18
18
*
19
19
* @author Alex Bogomazov
20
20
*/
@@ -28,22 +28,24 @@ abstract class FilterIterator extends \FilterIterator
28
28
*/
29
29
public function rewind ()
30
30
{
31
- $ iterator = $ this ;
32
- while ($ iterator instanceof \OuterIterator) {
33
- $ innerIterator = $ iterator ->getInnerIterator ();
31
+ if (version_compare (PHP_VERSION , '5.5.23 ' , '< ' )
32
+ or (version_compare (PHP_VERSION , '5.6.0 ' , '>= ' ) and version_compare (PHP_VERSION , '5.6.7 ' , '< ' ))) {
33
+ $ iterator = $ this ;
34
+ while ($ iterator instanceof \OuterIterator) {
35
+ $ innerIterator = $ iterator ->getInnerIterator ();
34
36
35
- if ($ innerIterator instanceof RecursiveDirectoryIterator) {
36
- if ($ innerIterator ->isRewindable ()) {
37
- $ innerIterator ->next ();
38
- $ innerIterator ->rewind ();
37
+ if ($ innerIterator instanceof RecursiveDirectoryIterator) {
38
+ if ($ innerIterator ->isRewindable ()) {
39
+ $ innerIterator ->next ();
40
+ $ innerIterator ->rewind ();
41
+ }
42
+ } elseif ($ iterator ->getInnerIterator () instanceof \FilesystemIterator) {
43
+ $ iterator ->getInnerIterator ()->next ();
44
+ $ iterator ->getInnerIterator ()->rewind ();
39
45
}
40
- } elseif ($ iterator ->getInnerIterator () instanceof \FilesystemIterator) {
41
- $ iterator ->getInnerIterator ()->next ();
42
- $ iterator ->getInnerIterator ()->rewind ();
46
+ $ iterator = $ iterator ->getInnerIterator ();
43
47
}
44
- $ iterator = $ iterator ->getInnerIterator ();
45
48
}
46
-
47
49
parent ::rewind ();
48
50
}
49
51
}
0 commit comments