Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44955be

Browse files
[Config] Fix ** GlobResource on Windows
1 parent 7fc2552 commit 44955be

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/Symfony/Component/Config/Resource/GlobResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function (\SplFileInfo $file) { return '.' !== $file->getBasename()[0]; }
134134

135135
$prefixLen = strlen($this->prefix);
136136
foreach ($finder->followLinks()->sortByName()->in($this->prefix) as $path => $info) {
137-
if (preg_match($regex, substr($path, $prefixLen)) && $info->isFile()) {
137+
if (preg_match($regex, substr('\\' === \DIRECTORY_SEPARATOR ? str_replace('\\', '/', $path) : $path, $prefixLen)) && $info->isFile()) {
138138
yield $path => $info;
139139
}
140140
}

src/Symfony/Component/Config/Tests/Resource/GlobResourceTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ public function testIterator()
3636
$this->assertEquals(array($file => new \SplFileInfo($file)), $paths);
3737
$this->assertInstanceOf('SplFileInfo', current($paths));
3838
$this->assertSame($dir, $resource->getPrefix());
39+
40+
$resource = new GlobResource($dir, '/**/Resource', true);
41+
42+
$paths = iterator_to_array($resource);
43+
44+
$file = $dir.DIRECTORY_SEPARATOR.'Resource'.DIRECTORY_SEPARATOR.'ConditionalClass.php';
45+
$this->assertEquals(array($file => $file), $paths);
46+
$this->assertInstanceOf('SplFileInfo', current($paths));
47+
$this->assertSame($dir, $resource->getPrefix());
3948
}
4049

4150
public function testIsFreshNonRecursiveDetectsNewFile()

src/Symfony/Component/Config/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
"symfony/filesystem": "~2.8|~3.0"
2121
},
2222
"require-dev": {
23+
"symfony/finder": "~3.3",
2324
"symfony/yaml": "~3.0",
2425
"symfony/dependency-injection": "~3.3"
2526
},
2627
"conflict": {
28+
"symfony/finder": "<3.3",
2729
"symfony/dependency-injection": "<3.3"
2830
},
2931
"suggest": {

0 commit comments

Comments
 (0)