File tree 2 files changed +44
-1
lines changed
2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 22
22
use function in_array ;
23
23
use function sort ;
24
24
25
+ use const SORT_FLAG_CASE ;
26
+ use const SORT_NATURAL ;
27
+
25
28
/** @implements IteratorAggregate<string> */
26
29
final class Files implements IteratorAggregate, Countable
27
30
{
@@ -35,7 +38,7 @@ public function add(string $filename): void
35
38
}
36
39
37
40
$ this ->files [] = $ filename ;
38
- sort ($ this ->files );
41
+ sort ($ this ->files , SORT_NATURAL | SORT_FLAG_CASE );
39
42
}
40
43
41
44
/** @return Iterator<string> */
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ /**
6
+ * This file is part of phpDocumentor.
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ *
11
+ * @link https://phpdoc.org
12
+ */
13
+
14
+ namespace phpDocumentor \Guides ;
15
+
16
+ use PHPUnit \Framework \TestCase ;
17
+
18
+ use function iterator_to_array ;
19
+
20
+ class FilesTest extends TestCase
21
+ {
22
+ public function testFilesAreSorted (): void
23
+ {
24
+ $ files = new Files ();
25
+ $ files ->add ('page ' );
26
+ $ files ->add ('Subpage ' );
27
+ $ files ->add ('index ' );
28
+
29
+ $ result = iterator_to_array ($ files ->getIterator ());
30
+
31
+ self ::assertSame (
32
+ [
33
+ 'index ' ,
34
+ 'page ' ,
35
+ 'Subpage ' ,
36
+ ],
37
+ $ result ,
38
+ );
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments