Explicitly use global namespace in function calls

This commit is contained in:
2020-10-23 17:03:51 +02:00
committed by Stefan Rohde-Enslin
parent 14e82826ae
commit 0ea9c31845
2 changed files with 257 additions and 257 deletions

View File

@ -378,33 +378,33 @@ final class NodaTimeAutotranslater {
return self::TRANSLATABLE_UNTIL_END;
}
if (intval($zeit_ende) >= 0 && intval($zeit_beginn) < 0) {
if (\intval($zeit_ende) >= 0 && \intval($zeit_beginn) < 0) {
return self::TRANSLATABLE_NOT;
}
if (($zeit_ende > 0 && intval($zeit_ende) % 100 === 0 and (intval($zeit_beginn) - 1) % 100 === 0)
|| (intval($zeit_beginn) < 0 && intval($zeit_beginn) % 100 === 0 and (intval($zeit_ende) + 1) % 100 === 0)
if (($zeit_ende > 0 && \intval($zeit_ende) % 100 === 0 and (\intval($zeit_beginn) - 1) % 100 === 0)
|| (\intval($zeit_beginn) < 0 && \intval($zeit_beginn) % 100 === 0 and (\intval($zeit_ende) + 1) % 100 === 0)
) {
return self::TRANSLATABLE_CENTURY;
}
if ((intval($zeit_ende) + 1) % 10 === 0 and intval($zeit_beginn) % 10 === 0 and intval($zeit_beginn) > 1000) {
if ((\intval($zeit_ende) + 1) % 10 === 0 and \intval($zeit_beginn) % 10 === 0 and \intval($zeit_beginn) > 1000) {
return self::TRANSLATABLE_DECADE;
}
if (intval($zeit_ende) < 0 && intval($zeit_beginn) < 0
|| (intval($zeit_ende) < 1000 and trim($zeit_zaehlzeit_monat, ", .0") === "")
if (\intval($zeit_ende) < 0 && \intval($zeit_beginn) < 0
|| (\intval($zeit_ende) < 1000 and \trim($zeit_zaehlzeit_monat, ", .0") === "")
) {
return self::TRANSLATABLE_AS_YEAR_WITH_SUFFIX;
}
if ($zeit_ende === $zeit_beginn and trim($zeit_zaehlzeit_monat, ", .0") === "") {
if ($zeit_ende === $zeit_beginn and \trim($zeit_zaehlzeit_monat, ", .0") === "") {
return self::TRANSLATABLE_ONLY_YEAR;
}
if ($zeit_ende !== $zeit_beginn and trim($zeit_zaehlzeit_monat, ", .0") === "") {
if ($zeit_ende !== $zeit_beginn and \trim($zeit_zaehlzeit_monat, ", .0") === "") {
return self::TRANSLATABLE_TIMESPAN_YEARS;
}
// Conditions speaking against translatability.
if (trim($zeit_zaehlzeit_monat, ", .0") === "") {
if (\trim($zeit_zaehlzeit_monat, ", .0") === "") {
return self::TRANSLATABLE_NOT;
}
@ -449,9 +449,9 @@ final class NodaTimeAutotranslater {
case 0:
return $timeName;
case 1:
return sprintf(self::LANGS_TO_CE_FORMAT[$tLang], $timeName);
return \sprintf(self::LANGS_TO_CE_FORMAT[$tLang], $timeName);
case 2:
return sprintf(self::LANGS_TO_BCE_FORMAT[$tLang], $timeName);
return \sprintf(self::LANGS_TO_BCE_FORMAT[$tLang], $timeName);
default:
throw new Exception("Unknown case encountered for time translations.");
}
@ -467,16 +467,16 @@ final class NodaTimeAutotranslater {
*/
public static function translateYearsWithSuffix(array $timeInfo):array {
$start = intval($timeInfo['zeit_beginn']);
$end = intval($timeInfo['zeit_ende']);
$start = \intval($timeInfo['zeit_beginn']);
$end = \intval($timeInfo['zeit_ende']);
$suffixMode = self::getSuffixModeForYearsWSuffix($start, $end);
// Time info to pass
if ($suffixMode === 2) {
$timeInfoToCopy = $timeInfo;
$timeInfoToCopy["zeit_beginn"] = abs($start);
$timeInfoToCopy["zeit_ende"] = abs($end);
$timeInfoToCopy["zeit_beginn"] = \abs($start);
$timeInfoToCopy["zeit_ende"] = \abs($end);
}
$output = [];
@ -495,9 +495,9 @@ final class NodaTimeAutotranslater {
}
else {
if ($start === $end) {
$year = sprintf(self::LANGS_SINGLE_YEAR_FORMAT[$tLang], (string)abs($start));
$year = \sprintf(self::LANGS_SINGLE_YEAR_FORMAT[$tLang], (string)\abs($start));
}
else $year = sprintf(self::LANGS_YEARSPAN_FORMAT[$tLang], (string)abs($start), (string)abs($end));
else $year = \sprintf(self::LANGS_YEARSPAN_FORMAT[$tLang], (string)\abs($start), (string)\abs($end));
}
$output[$tLang] = self::applyBcBceFormat($tLang, $year, $suffixMode);
@ -516,11 +516,11 @@ final class NodaTimeAutotranslater {
*/
public static function translateYearOnly(array $timeInfo):array {
$start = intval($timeInfo['zeit_beginn']);
$start = \intval($timeInfo['zeit_beginn']);
$output = [];
foreach (self::LANGS_SINGLE_YEAR_FORMAT as $tLang => $format) {
$output[$tLang] = sprintf($format, (string)abs($start));
$output[$tLang] = \sprintf($format, (string)\abs($start));
}
return $output;
@ -535,13 +535,13 @@ final class NodaTimeAutotranslater {
*/
public static function translateTimespanYears(array $timeInfo):array {
$start = intval($timeInfo['zeit_beginn']);
$end = intval($timeInfo['zeit_ende']);
$start = \intval($timeInfo['zeit_beginn']);
$end = \intval($timeInfo['zeit_ende']);
$output = [];
if (abs($start) === 1102) throw new Exception(var_export($timeInfo, true));
if (\abs($start) === 1102) throw new Exception(var_export($timeInfo, true));
foreach (self::LANGS_YEARSPAN_FORMAT as $tLang => $format) {
$output[$tLang] = sprintf($format, (string)abs($start), (string)abs($end));
$output[$tLang] = \sprintf($format, (string)\abs($start), (string)\abs($end));
}
return $output;
@ -556,32 +556,32 @@ final class NodaTimeAutotranslater {
*/
public static function translateYearsAsCentury(array $timeInfo):array {
if (intval($timeInfo['zeit_beginn']) > 0) {
if (\intval($timeInfo['zeit_beginn']) > 0) {
// Beginn: 1500. (1501 - 1) / 100 + 1 = 16. 16th century is the time.
$start_cen = ((intval($timeInfo['zeit_beginn']) - 1) / 100) + 1;
$start_cen = ((\intval($timeInfo['zeit_beginn']) - 1) / 100) + 1;
// End: 1600. 16th century is the time.
$end_cen = (intval($timeInfo['zeit_ende']) / 100);
$end_cen = (\intval($timeInfo['zeit_ende']) / 100);
}
else {
// End: -1600. 16th century is the time.
$start_cen = (intval($timeInfo['zeit_beginn']) / 100);
$start_cen = (\intval($timeInfo['zeit_beginn']) / 100);
// End: -1500. (1501 - 1) / 100 + 1 = 16. 16th century is the time.
$end_cen = ((intval($timeInfo['zeit_ende']) + 1) / 100) - 1;
$end_cen = ((\intval($timeInfo['zeit_ende']) + 1) / 100) - 1;
}
$suffixMode = self::getSuffixModeForYearsWSuffix((intval($timeInfo['zeit_beginn']) - 1), intval($timeInfo['zeit_ende']));
$suffixMode = self::getSuffixModeForYearsWSuffix((\intval($timeInfo['zeit_beginn']) - 1), \intval($timeInfo['zeit_ende']));
$output = [];
if ($start_cen === $end_cen) {
foreach (self::LANGS_CENTURY_FORMAT as $tLang => $format) {
$tLangValue = sprintf($format, (string)abs($start_cen));
$tLangValue = \sprintf($format, (string)\abs($start_cen));
$output[$tLang] = self::applyBcBceFormat($tLang, $tLangValue, $suffixMode);
}
}
else {
foreach (self::LANGS_CENTURIES_FORMAT as $tLang => $format) {
$tLangValue = sprintf($format, (string)abs($start_cen), (string)abs($end_cen));
$tLangValue = \sprintf($format, (string)\abs($start_cen), (string)\abs($end_cen));
$output[$tLang] = self::applyBcBceFormat($tLang, $tLangValue, $suffixMode);
}
}
@ -599,25 +599,25 @@ final class NodaTimeAutotranslater {
public static function translateYearsAsDecade(array $timeInfo):array {
// Beginn: 1500. (1501 - 1) / 100 + 1 = 16. 16th century is the time.
$start_cen = (intval($timeInfo['zeit_beginn']));
$start_cen = (\intval($timeInfo['zeit_beginn']));
// End: 1600. 16th century is the time.
$end_cen = (intval($timeInfo['zeit_ende']));
$end_cen = (\intval($timeInfo['zeit_ende']));
$suffixMode = self::getSuffixModeForYearsWSuffix((intval($timeInfo['zeit_beginn']) - 1), intval($timeInfo['zeit_ende']));
$suffixMode = self::getSuffixModeForYearsWSuffix((\intval($timeInfo['zeit_beginn']) - 1), \intval($timeInfo['zeit_ende']));
$output = [];
if ($start_cen === $end_cen - 9) {
foreach (self::LANGS_DECADE_FORMAT as $tLang => $format) {
$tLangValue = sprintf($format, (string)$start_cen, (string)$end_cen);
if (!empty(self::LANGS_SYLLABLE_CLEANING[$tLang])) $tLangValue = strtr($tLangValue, self::LANGS_SYLLABLE_CLEANING[$tLang]);
$tLangValue = \sprintf($format, (string)$start_cen, (string)$end_cen);
if (!empty(self::LANGS_SYLLABLE_CLEANING[$tLang])) $tLangValue = \strtr($tLangValue, self::LANGS_SYLLABLE_CLEANING[$tLang]);
$output[$tLang] = self::applyBcBceFormat($tLang, $tLangValue, $suffixMode);
}
}
else {
foreach (self::LANGS_DECADES_FORMAT as $tLang => $format) {
$tLangValue = sprintf($format, (string)$start_cen, (string)($end_cen - 9));
if (!empty(self::LANGS_SYLLABLE_CLEANING[$tLang])) $tLangValue = strtr($tLangValue, self::LANGS_SYLLABLE_CLEANING[$tLang]);
$tLangValue = \sprintf($format, (string)$start_cen, (string)($end_cen - 9));
if (!empty(self::LANGS_SYLLABLE_CLEANING[$tLang])) $tLangValue = \strtr($tLangValue, self::LANGS_SYLLABLE_CLEANING[$tLang]);
$output[$tLang] = self::applyBcBceFormat($tLang, $tLangValue, $suffixMode);
}
}
@ -634,8 +634,8 @@ final class NodaTimeAutotranslater {
*/
public static function translateYearsAfterStart(array $timeInfo):array {
if (empty(trim((string)$timeInfo['zeit_zaehlzeit_monat'], " ,.;0"))) {
$timeInfo['zeit_beginn'] = strval(intval($timeInfo['zeit_beginn']) - 1);
if (empty(\trim((string)$timeInfo['zeit_zaehlzeit_monat'], " ,.;0"))) {
$timeInfo['zeit_beginn'] = \strval(\intval($timeInfo['zeit_beginn']) - 1);
}
# else throw new Exception("Unhandled split case. Counting time is: " . var_export($timeInfo, true));
$innerTimeInfo = $timeInfo;
@ -646,7 +646,7 @@ final class NodaTimeAutotranslater {
$dateAlone = self::getTranslations($innerTimeInfo)[$tLang];
$timeName = sprintf($format, $dateAlone);
$timeName = \sprintf($format, $dateAlone);
$output[$tLang] = $timeName;
}
@ -663,7 +663,7 @@ final class NodaTimeAutotranslater {
*/
public static function translateYearsSinceStart(array $timeInfo):array {
$start = intval($timeInfo['zeit_beginn']);
$start = \intval($timeInfo['zeit_beginn']);
if (substr((string)$timeInfo['zeit_name'], 0, 5) === "Nach ") {
return self::translateYearsAfterStart($timeInfo);
@ -677,7 +677,7 @@ final class NodaTimeAutotranslater {
$dateAlone = self::getTranslations($innerTimeInfo)[$tLang];
$timeName = sprintf($format, $dateAlone);
$timeName = \sprintf($format, $dateAlone);
$output[$tLang] = $timeName;
}
@ -694,10 +694,10 @@ final class NodaTimeAutotranslater {
*/
public static function translateYearsBeforeEnd(array $timeInfo):array {
if (empty(trim((string)$timeInfo['zeit_zaehlzeit_monat'], " ,.;0"))) {
$timeInfo['zeit_ende'] = strval(intval($timeInfo['zeit_ende']) + 1);
if (empty(\trim((string)$timeInfo['zeit_zaehlzeit_monat'], " ,.;0"))) {
$timeInfo['zeit_ende'] = \strval(\intval($timeInfo['zeit_ende']) + 1);
}
$end = intval($timeInfo['zeit_ende']);
$end = \intval($timeInfo['zeit_ende']);
$innerTimeInfo = $timeInfo;
$innerTimeInfo['zeit_beginn'] = $timeInfo['zeit_ende'];
@ -707,7 +707,7 @@ final class NodaTimeAutotranslater {
$dateAlone = self::getTranslations($innerTimeInfo)[$tLang];
$timeName = sprintf($format, $dateAlone);
$timeName = \sprintf($format, $dateAlone);
$output[$tLang] = $timeName;
}
return $output;
@ -723,7 +723,7 @@ final class NodaTimeAutotranslater {
*/
public static function translateYearsUntilEnd(array $timeInfo):array {
$end = intval($timeInfo['zeit_ende']);
$end = \intval($timeInfo['zeit_ende']);
if (substr((string)$timeInfo['zeit_name'], 0, 4) === "Vor ") {
return self::translateYearsBeforeEnd($timeInfo);
@ -737,7 +737,7 @@ final class NodaTimeAutotranslater {
$dateAlone = self::getTranslations($innerTimeInfo)[$tLang];
$timeName = sprintf($format, $dateAlone);
$timeName = \sprintf($format, $dateAlone);
$output[$tLang] = $timeName;
}
return $output;
@ -785,9 +785,9 @@ final class NodaTimeAutotranslater {
return self::translateYearsWithSuffix($timeInfo);
}
$suffixMode = self::getSuffixModeForYearsWSuffix((intval($timeInfo['zeit_beginn']) - 1), intval($timeInfo['zeit_ende']));
$suffixMode = self::getSuffixModeForYearsWSuffix((\intval($timeInfo['zeit_beginn']) - 1), \intval($timeInfo['zeit_ende']));
if (trim((string)$timeInfo['zeit_zaehlzeit_tag'], ", .0") === "") {
if (\trim((string)$timeInfo['zeit_zaehlzeit_tag'], ", .0") === "") {
$dateStr = "{$timeInfo['zeit_zaehlzeit_jahr']}-{$timeInfo['zeit_zaehlzeit_monat']}-05 00:00:01";
$usecase = self::USECASE_MONTH;
}
@ -796,16 +796,16 @@ final class NodaTimeAutotranslater {
$usecase = self::USECASE_DAY;
}
$dateGeneral = strtotime($dateStr);
$dateGeneral = \strtotime($dateStr);
$output = [];
foreach (self::LANGS_TO_LOCALES as $tLang => $locale) {
setlocale(LC_TIME, $locale);
if ($locale !== setlocale(LC_TIME, "0")) continue;
if ($usecase === self::USECASE_MONTH) $tLangValue = strftime(getMonthFormatByLang($tLang), $dateGeneral ?: 0);
\setlocale(LC_TIME, $locale);
if ($locale !== \setlocale(LC_TIME, "0")) continue;
if ($usecase === self::USECASE_MONTH) $tLangValue = \strftime(getMonthFormatByLang($tLang), $dateGeneral ?: 0);
else { # if ($usecase === self::USECASE_DAY)
$tLangValue = strftime(getDateFormatByLang($tLang), $dateGeneral ?: 0);
$tLangValue = \strftime(getDateFormatByLang($tLang), $dateGeneral ?: 0);
}
$output[$tLang] = self::applyBcBceFormat($tLang, $tLangValue, $suffixMode);