Commit 138aba00 authored by Wouter Wolters's avatar Wouter Wolters Committed by Andreas Fernandez
Browse files

[TASK] Use str_replace instead of strtr to improve readability and clarity purposes

Resolves: #85476
Releases: master
Change-Id: I879bb7546e7e7ca0d46e8d682eb739f76df61b01
Reviewed-on: https://review.typo3.org/57465


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarRudy Gnodde <rgn@windinternet.nl>
Tested-by: default avatarRudy Gnodde <rgn@windinternet.nl>
Reviewed-by: Robert van Kammen's avatarRobert van Kammen <rvkammen@hotmail.com>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent ba63d4a0
......@@ -149,7 +149,7 @@ class ClassLoadingInformationGenerator
$blacklistExpression = null;
if ($ignorePotentialTestClasses) {
$blacklistPathPrefix = realpath($classesPath);
$blacklistPathPrefix = strtr($blacklistPathPrefix, '\\', '/');
$blacklistPathPrefix = str_replace('\\', '/', $blacklistPathPrefix);
$blacklistExpression = "{($blacklistPathPrefix/tests/|$blacklistPathPrefix/Tests/|$blacklistPathPrefix/Resources/|$blacklistPathPrefix/res/|$blacklistPathPrefix/class.ext_update.php)}";
}
foreach (ClassMapGenerator::createMap($classesPath, $blacklistExpression, null, $namespace) as $class => $path) {
......
......@@ -84,8 +84,8 @@ class ServerRequestFactory
}
if (!empty($value)) {
if (strpos($key, 'HTTP_') === 0) {
$name = strtr(substr($key, 5), '_', ' ');
$name = strtr(ucwords(strtolower($name)), ' ', '-');
$name = str_replace('_', ' ', substr($key, 5));
$name = str_replace(' ', '-', ucwords(strtolower($name)));
$name = strtolower($name);
$headers[$name] = $value;
} elseif (strpos($key, 'CONTENT_') === 0) {
......
......@@ -82,7 +82,7 @@ class ClassMapGenerator
continue;
}
if ($blacklist && preg_match($blacklist, strtr($filePath, '\\', '/'))) {
if ($blacklist && preg_match($blacklist, str_replace('\\', '/', $filePath))) {
continue;
}
......@@ -96,7 +96,10 @@ class ClassMapGenerator
if (!isset($map[$class])) {
$map[$class] = $filePath;
} elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class] . ' ' . $filePath, '\\', '/'))) {
} elseif ($io && $map[$class] !== $filePath && !preg_match(
'{/(test|fixture|example|stub)s?/}i',
str_replace('\\', '/', $map[$class] . ' ' . $filePath)
)) {
$io->writeError(
'<warning>Warning: Ambiguous class resolution, "' . $class . '"' .
' was found in both "' . $map[$class] . '" and "' . $filePath . '", the first will be used.</warning>'
......
......@@ -557,7 +557,11 @@ class UpgradeController extends AbstractController
}
// Build array of file (hashes) not affected by current scan, if they are tagged as "FullyScanned"
$parsedRestFile = array_pop($documentationFile->getListEntry(strtr(realpath($restFile->getPathname()), '\\', '/')));
$parsedRestFile = array_pop($documentationFile->getListEntry(str_replace(
'\\',
'/',
realpath($restFile->getPathname())
)));
if (!in_array($parsedRestFile['file_hash'], $foundRestFileHashes, true)
&& in_array('FullyScanned', $parsedRestFile['tags'], true)
) {
......@@ -667,7 +671,11 @@ class UpgradeController extends AbstractController
$restFileLocation = $restFile->getPathname();
break;
}
$parsedRestFile = array_pop($documentationFile->getListEntry(strtr(realpath($restFileLocation), '\\', '/')));
$parsedRestFile = array_pop($documentationFile->getListEntry(str_replace(
'\\',
'/',
realpath($restFileLocation)
)));
$version = GeneralUtility::trimExplode(DIRECTORY_SEPARATOR, $restFileLocation);
array_pop($version);
// something like "8.2" .. "8.7" .. "master"
......@@ -1147,7 +1155,7 @@ class UpgradeController extends AbstractController
{
$documentationFileService = new DocumentationFile();
$documentationFiles = $documentationFileService->findDocumentationFiles(
strtr(realpath(ExtensionManagementUtility::extPath('core') . 'Documentation/Changelog'), '\\', '/')
str_replace('\\', '/', realpath(ExtensionManagementUtility::extPath('core') . 'Documentation/Changelog'))
);
$documentationFiles = array_reverse($documentationFiles);
......
......@@ -55,7 +55,7 @@ class DocumentationFile
$this->registry = new Registry();
}
$this->changelogPath = $changelogDir !== '' ? $changelogDir : realpath(ExtensionManagementUtility::extPath('core') . 'Documentation/Changelog');
$this->changelogPath = strtr($this->changelogPath, '\\', '/');
$this->changelogPath = str_replace('\\', '/', $this->changelogPath);
}
/**
......@@ -75,7 +75,7 @@ class DocumentationFile
$versionDirectories = scandir($path);
$fileInfo = pathinfo($path);
$absolutePath = strtr($fileInfo['dirname'], '\\', '/') . '/' . $fileInfo['basename'];
$absolutePath = str_replace('\\', '/', $fileInfo['dirname']) . '/' . $fileInfo['basename'];
foreach ($versionDirectories as $version) {
$directory = $absolutePath . '/' . $version;
$documentationFiles += $this->getDocumentationFilesForVersion($directory, $version);
......@@ -226,7 +226,7 @@ class DocumentationFile
$documentationFiles = [];
if ($this->isRelevantDirectory($docDirectory, $version)) {
$documentationFiles[$version] = [];
$absolutePath = strtr(PathUtility::dirname($docDirectory), '\\', '/') . '/' . $version;
$absolutePath = str_replace('\\', '/', PathUtility::dirname($docDirectory)) . '/' . $version;
$rstFiles = scandir($docDirectory);
foreach ($rstFiles as $file) {
$fileInfo = pathinfo($file);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment