Skip to content

Commit 46a373d

Browse files
Rastusiklisachenko
authored andcommitted
Finder glob pattern (#421)
Enumerator supports glob patterns in include files, add webmozart/glob as dev dependency
1 parent 497b81a commit 46a373d

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

composer.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"phpunit/phpunit": "^5.7",
2323
"doctrine/orm": "^2.5",
2424
"symfony/filesystem": "^3.3",
25-
"symfony/process": "^3.3"
25+
"symfony/process": "^3.3",
26+
"webmozart/glob": "^4.1"
2627
},
2728

2829
"suggest": {
@@ -49,7 +50,10 @@
4950
"psr-4": {
5051
"Go\\": "tests/Go/",
5152
"Go\\Tests\\TestProject\\": "tests/Fixtures/project/src/"
52-
}
53+
},
54+
"files": [
55+
"tests/functions.php"
56+
]
5357
},
5458

5559
"minimum-stability": "stable",

src/Instrument/FileSystem/Enumerator.php

-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
namespace Go\Instrument\FileSystem;
1212

1313
use ArrayIterator;
14-
use CallbackFilterIterator;
1514
use InvalidArgumentException;
1615
use LogicException;
17-
use RecursiveIteratorIterator;
1816
use SplFileInfo;
1917
use Symfony\Component\Finder\Finder;
2018
use UnexpectedValueException;
@@ -102,7 +100,6 @@ private function getInPaths()
102100
throw new UnexpectedValueException(sprintf('Path %s is not in %s', $path, $this->rootDirectory));
103101
}
104102

105-
$path = str_replace('*', '', $path);
106103
$inPaths[] = $path;
107104
}
108105

tests/functions.php

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/*
5+
* @author Martin Fris <[email protected]>
6+
*/
7+
namespace Symfony\Component\Finder;
8+
9+
/**
10+
* This helper function overrides the PHP glob() function so it is able to be run with virtual file system,
11+
* which is supported by Webmozart\Glob\Glob
12+
*
13+
* @param $pattern
14+
* @param null $flags
15+
*
16+
* @return string[]
17+
*/
18+
function glob($pattern, $flags = null) {
19+
return \Webmozart\Glob\Glob::glob($pattern, $flags);
20+
}

0 commit comments

Comments
 (0)