Skip to content

Commit 3439216

Browse files
Merge branch '4.4' into 5.2
* 4.4: [Config][DependencyInjection] Uniformize trailing slash handling [PropertyInfo] Make ReflectionExtractor correctly extract nullability [PropertyInfo] fix attribute namespace with recursive traits Check redis extension version [Security] Update Russian translations [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 [Translation] Set default locale for IdentityTranslatorTest
2 parents 6ca378b + b6ae401 commit 3439216

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

Loader/FileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ private function findClasses(string $namespace, string $pattern, array $excludeP
164164
$excludePrefix = $resource->getPrefix();
165165
}
166166

167-
// normalize Windows slashes
168-
$excludePaths[str_replace('\\', '/', $path)] = true;
167+
// normalize Windows slashes and remove trailing slashes
168+
$excludePaths[rtrim(str_replace('\\', '/', $path), '/')] = true;
169169
}
170170
}
171171

Tests/Loader/FileLoaderTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,35 @@ public function testRegisterClassesWithIncompatibleExclude()
238238
'yaml/*'
239239
);
240240
}
241+
242+
/**
243+
* @dataProvider excludeTrailingSlashConsistencyProvider
244+
*/
245+
public function testExcludeTrailingSlashConsistency(string $exclude)
246+
{
247+
$container = new ContainerBuilder();
248+
$loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'));
249+
$loader->registerClasses(
250+
new Definition(),
251+
'Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\\',
252+
'Prototype/*',
253+
$exclude
254+
);
255+
256+
$this->assertTrue($container->has(Foo::class));
257+
$this->assertFalse($container->has(DeeperBaz::class));
258+
}
259+
260+
public function excludeTrailingSlashConsistencyProvider(): iterable
261+
{
262+
yield ['Prototype/OtherDir/AnotherSub/'];
263+
yield ['Prototype/OtherDir/AnotherSub'];
264+
yield ['Prototype/OtherDir/AnotherSub/*'];
265+
yield ['Prototype/*/AnotherSub'];
266+
yield ['Prototype/*/AnotherSub/'];
267+
yield ['Prototype/*/AnotherSub/*'];
268+
yield ['Prototype/OtherDir/AnotherSub/DeeperBaz.php'];
269+
}
241270
}
242271

243272
class TestFileLoader extends FileLoader

0 commit comments

Comments
 (0)