consistently use str_replace to unify directory separators

This commit is contained in:
Tobias Schultze 2015-08-25 14:59:33 +02:00
parent cca29d849a
commit b9760efb02
6 changed files with 8 additions and 8 deletions

View File

@ -26,7 +26,7 @@ class TemplateFilenameParser implements TemplateNameParserInterface
*/
public function parse($file)
{
$parts = explode('/', strtr($file, '\\', '/'));
$parts = explode('/', str_replace('\\', '/', $file));
$elements = explode('.', array_pop($parts));
if (3 > count($elements)) {

View File

@ -50,7 +50,7 @@ class TemplateNameParser extends BaseTemplateNameParser
}
// normalize name
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')));
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name)));
if (false !== strpos($name, '..')) {
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));

View File

@ -140,10 +140,10 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
protected function assertEqualsNormalized($expected, $actual, $message = null)
{
foreach ($expected as $ns => $path) {
$expected[$ns] = strtr($path, '\\', '/');
$expected[$ns] = str_replace('\\', '/', $path);
}
foreach ($actual as $ns => $path) {
$actual[$ns] = strtr($path, '\\', '/');
$actual[$ns] = str_replace('\\', '/', $path);
}
$this->assertEquals($expected, $actual, $message);
}

View File

@ -313,8 +313,8 @@ class Filesystem
{
// Normalize separators on Windows
if ('\\' === DIRECTORY_SEPARATOR) {
$endPath = strtr($endPath, '\\', '/');
$startPath = strtr($startPath, '\\', '/');
$endPath = str_replace('\\', '/', $endPath);
$startPath = str_replace('\\', '/', $startPath);
}
// Split the paths into arrays

View File

@ -44,7 +44,7 @@ class ExcludeDirectoryFilterIterator extends FilterIterator
public function accept()
{
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
$path = strtr($path, '\\', '/');
$path = str_replace('\\', '/', $path);
foreach ($this->patterns as $pattern) {
if (preg_match($pattern, $path)) {
return false;

View File

@ -29,7 +29,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
$filename = $this->current()->getRelativePathname();
if ('\\' === DIRECTORY_SEPARATOR) {
$filename = strtr($filename, '\\', '/');
$filename = str_replace('\\', '/', $filename);
}
// should at least not match one rule to exclude