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

Skip to content

Commit 6bda975

Browse files
[Config] Fix ** GlobResource on Windows
1 parent 7fc2552 commit 6bda975

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ 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+
$this->assertEquals(array($file => $file), $paths);
45+
$this->assertInstanceOf('SplFileInfo', current($paths));
46+
$this->assertSame($dir, $resource->getPrefix());
3947
}
4048

4149
public function testIsFreshNonRecursiveDetectsNewFile()

0 commit comments

Comments
 (0)