consistently use str_replace to unify directory separators
This commit is contained in:
parent
cca29d849a
commit
b9760efb02
@ -26,7 +26,7 @@ class TemplateFilenameParser implements TemplateNameParserInterface
|
|||||||
*/
|
*/
|
||||||
public function parse($file)
|
public function parse($file)
|
||||||
{
|
{
|
||||||
$parts = explode('/', strtr($file, '\\', '/'));
|
$parts = explode('/', str_replace('\\', '/', $file));
|
||||||
|
|
||||||
$elements = explode('.', array_pop($parts));
|
$elements = explode('.', array_pop($parts));
|
||||||
if (3 > count($elements)) {
|
if (3 > count($elements)) {
|
||||||
|
@ -50,7 +50,7 @@ class TemplateNameParser extends BaseTemplateNameParser
|
|||||||
}
|
}
|
||||||
|
|
||||||
// normalize name
|
// normalize name
|
||||||
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')));
|
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name)));
|
||||||
|
|
||||||
if (false !== strpos($name, '..')) {
|
if (false !== strpos($name, '..')) {
|
||||||
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
|
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
|
||||||
|
@ -140,10 +140,10 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
|
|||||||
protected function assertEqualsNormalized($expected, $actual, $message = null)
|
protected function assertEqualsNormalized($expected, $actual, $message = null)
|
||||||
{
|
{
|
||||||
foreach ($expected as $ns => $path) {
|
foreach ($expected as $ns => $path) {
|
||||||
$expected[$ns] = strtr($path, '\\', '/');
|
$expected[$ns] = str_replace('\\', '/', $path);
|
||||||
}
|
}
|
||||||
foreach ($actual as $ns => $path) {
|
foreach ($actual as $ns => $path) {
|
||||||
$actual[$ns] = strtr($path, '\\', '/');
|
$actual[$ns] = str_replace('\\', '/', $path);
|
||||||
}
|
}
|
||||||
$this->assertEquals($expected, $actual, $message);
|
$this->assertEquals($expected, $actual, $message);
|
||||||
}
|
}
|
||||||
|
@ -313,8 +313,8 @@ class Filesystem
|
|||||||
{
|
{
|
||||||
// Normalize separators on Windows
|
// Normalize separators on Windows
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
$endPath = strtr($endPath, '\\', '/');
|
$endPath = str_replace('\\', '/', $endPath);
|
||||||
$startPath = strtr($startPath, '\\', '/');
|
$startPath = str_replace('\\', '/', $startPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Split the paths into arrays
|
// Split the paths into arrays
|
||||||
|
@ -44,7 +44,7 @@ class ExcludeDirectoryFilterIterator extends FilterIterator
|
|||||||
public function accept()
|
public function accept()
|
||||||
{
|
{
|
||||||
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
|
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
|
||||||
$path = strtr($path, '\\', '/');
|
$path = str_replace('\\', '/', $path);
|
||||||
foreach ($this->patterns as $pattern) {
|
foreach ($this->patterns as $pattern) {
|
||||||
if (preg_match($pattern, $path)) {
|
if (preg_match($pattern, $path)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -29,7 +29,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
|
|||||||
$filename = $this->current()->getRelativePathname();
|
$filename = $this->current()->getRelativePathname();
|
||||||
|
|
||||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||||
$filename = strtr($filename, '\\', '/');
|
$filename = str_replace('\\', '/', $filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// should at least not match one rule to exclude
|
// should at least not match one rule to exclude
|
||||||
|
Reference in New Issue
Block a user