Skip to content

Commit 03ac25f

Browse files
Merge branch '5.2' into 5.x
* 5.2: (23 commits) [Console] Fix Windows code page support [SecurityBundle] Allow ips parameter in access_control accept comma-separated string [Form] Add TranslatableMessage support to choice_label option of ChoiceType Remove code that deals with legacy behavior of PHP_Incomplete_Class [Config][DependencyInjection] Uniformize trailing slash handling [PropertyInfo] Make ReflectionExtractor correctly extract nullability [PropertyInfo] fix attribute namespace with recursive traits [PhpUnitBridge] Fix tests with `@doesNotPerformAssertions` annotations Check redis extension version [Security] Update Russian translations [Notifier] Fix return SentMessage then Messenger not used [VarExporter] Add support of PHP enumerations [Security] Added missing Japanese translations [Security] Added missing Polish translations [Security] Add missing Italian translations #41051 [Security] Missing translations pt_BR getProtocolVersion may return null Fix return type on isAllowedProperty method Make FailoverTransport always pick the first transport [TwigBridge] Fix HTML for translatable custom-file label in Bootstrap 4 theme ...
2 parents 9c9953f + 8dfa5f8 commit 03ac25f

File tree

6 files changed

+25
-2
lines changed

6 files changed

+25
-2
lines changed

Loader/FileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ public function import($resource, string $type = null, bool $ignoreErrors = fals
7676
$excluded = [];
7777
foreach ((array) $exclude as $pattern) {
7878
foreach ($this->glob($pattern, true, $_, false, true) as $path => $info) {
79-
// normalize Windows slashes
80-
$excluded[str_replace('\\', '/', $path)] = true;
79+
// normalize Windows slashes and remove trailing slashes
80+
$excluded[rtrim(str_replace('\\', '/', $path), '/')] = true;
8181
}
8282
}
8383

Tests/Fixtures/ExcludeTrailingSlash/bar.txt

Whitespace-only changes.

Tests/Fixtures/ExcludeTrailingSlash/exclude/baz.txt

Whitespace-only changes.

Tests/Fixtures/ExcludeTrailingSlash/foo.txt

Whitespace-only changes.

Tests/Loader/FileLoaderTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,28 @@ public function testImportWithExclude()
127127
$this->assertCount(2, $loadedFiles);
128128
$this->assertNotContains('ExcludeFile.txt', $loadedFiles);
129129
}
130+
131+
/**
132+
* @dataProvider excludeTrailingSlashConsistencyProvider
133+
*/
134+
public function testExcludeTrailingSlashConsistency(string $exclude)
135+
{
136+
$loader = new TestFileLoader(new FileLocator(__DIR__.'/../Fixtures'));
137+
$loadedFiles = $loader->import('ExcludeTrailingSlash/*', null, false, null, $exclude);
138+
$this->assertCount(2, $loadedFiles);
139+
$this->assertNotContains('baz.txt', $loadedFiles);
140+
}
141+
142+
public function excludeTrailingSlashConsistencyProvider(): iterable
143+
{
144+
yield [__DIR__.'/../Fixtures/Exclude/ExcludeToo/'];
145+
yield [__DIR__.'/../Fixtures/Exclude/ExcludeToo'];
146+
yield [__DIR__.'/../Fixtures/Exclude/ExcludeToo/*'];
147+
yield [__DIR__.'/../Fixtures/*/ExcludeToo'];
148+
yield [__DIR__.'/../Fixtures/*/ExcludeToo/'];
149+
yield [__DIR__.'/../Fixtures/Exclude/ExcludeToo/*'];
150+
yield [__DIR__.'/../Fixtures/Exclude/ExcludeToo/AnotheExcludedFile.txt'];
151+
}
130152
}
131153

132154
class TestFileLoader extends FileLoader

Tests/Resource/GlobResourceTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public function testBraceFallback()
177177

178178
$expected = [
179179
$dir.'/Exclude/ExcludeToo/AnotheExcludedFile.txt',
180+
$dir.'/ExcludeTrailingSlash/exclude/baz.txt',
180181
$dir.'/foo.xml',
181182
];
182183

0 commit comments

Comments
 (0)