Skip to content

Commit b9760ef

Browse files
committed
consistently use str_replace to unify directory separators
1 parent cca29d8 commit b9760ef

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TemplateFilenameParser implements TemplateNameParserInterface
2626
*/
2727
public function parse($file)
2828
{
29-
$parts = explode('/', strtr($file, '\\', '/'));
29+
$parts = explode('/', str_replace('\\', '/', $file));
3030

3131
$elements = explode('.', array_pop($parts));
3232
if (3 > count($elements)) {

src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function parse($name)
5050
}
5151

5252
// normalize name
53-
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')));
53+
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name)));
5454

5555
if (false !== strpos($name, '..')) {
5656
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));

src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,10 @@ public function testCreateMapFinderSupport()
140140
protected function assertEqualsNormalized($expected, $actual, $message = null)
141141
{
142142
foreach ($expected as $ns => $path) {
143-
$expected[$ns] = strtr($path, '\\', '/');
143+
$expected[$ns] = str_replace('\\', '/', $path);
144144
}
145145
foreach ($actual as $ns => $path) {
146-
$actual[$ns] = strtr($path, '\\', '/');
146+
$actual[$ns] = str_replace('\\', '/', $path);
147147
}
148148
$this->assertEquals($expected, $actual, $message);
149149
}

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ public function makePathRelative($endPath, $startPath)
313313
{
314314
// Normalize separators on Windows
315315
if ('\\' === DIRECTORY_SEPARATOR) {
316-
$endPath = strtr($endPath, '\\', '/');
317-
$startPath = strtr($startPath, '\\', '/');
316+
$endPath = str_replace('\\', '/', $endPath);
317+
$startPath = str_replace('\\', '/', $startPath);
318318
}
319319

320320
// Split the paths into arrays

src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(\Iterator $iterator, array $directories)
4444
public function accept()
4545
{
4646
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
47-
$path = strtr($path, '\\', '/');
47+
$path = str_replace('\\', '/', $path);
4848
foreach ($this->patterns as $pattern) {
4949
if (preg_match($pattern, $path)) {
5050
return false;

src/Symfony/Component/Finder/Iterator/PathFilterIterator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function accept()
2929
$filename = $this->current()->getRelativePathname();
3030

3131
if ('\\' === DIRECTORY_SEPARATOR) {
32-
$filename = strtr($filename, '\\', '/');
32+
$filename = str_replace('\\', '/', $filename);
3333
}
3434

3535
// should at least not match one rule to exclude

0 commit comments

Comments
 (0)