Skip to content

Check For and Eliminate Octal Literals #3682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
'not_operator_with_successor_space' => false, // idem
'nullable_type_declaration_for_default_null_value' => true,
'object_operator_without_whitespace' => true,
'octal_notation' => true,
'ordered_class_elements' => false, // We prefer to keep some freedom
'ordered_imports' => true,
'ordered_interfaces' => true,
Expand Down
27 changes: 23 additions & 4 deletions infra/LocaleGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class LocaleGenerator

private const ARGUMENT_SEPARATOR_ROW = 5;
private const ERROR_CODES_FIRST_ROW = 8;
private const CURRENCY_SYMBOL_ROW = 19;

private const FUNCTION_NAME_LIST_FIRST_ROW = 4;
private const ENGLISH_FUNCTION_CATEGORIES_COLUMN = 'A';
Expand Down Expand Up @@ -104,6 +105,7 @@ protected function buildConfigFileForLocale($column, $locale): void
$configFile = $this->openConfigFile($locale, $language, $localeLanguage);

$this->writeConfigArgumentSeparator($configFile, $column);
$this->writeConfigCurrencySymbol($configFile, $column);
$this->writeFileSectionHeader($configFile, 'Error Codes');

foreach ($this->errorCodeMap as $errorCode => $row) {
Expand Down Expand Up @@ -134,6 +136,21 @@ protected function writeConfigArgumentSeparator($configFile, $column): void
}
}

protected function writeConfigCurrencySymbol($configFile, $column): void
{
$translationCell = $this->localeTranslations->getCell($column . self::CURRENCY_SYMBOL_ROW);
$localeValue = $translationCell->getValue();
if (!empty($localeValue)) {
$functionTranslation = "currencySymbol = {$localeValue}" . self::EOL;
fwrite($configFile, '##' . self::EOL);
fwrite($configFile, '## (For future use)' . self::EOL);
fwrite($configFile, '##' . self::EOL);
fwrite($configFile, $functionTranslation);
} else {
$this->log('No Currency Symbol defined');
}
}

protected function buildFunctionsFileForLocale($column, $locale): void
{
$language = $this->functionNameTranslations->getCell($column . self::ENGLISH_LANGUAGE_NAME_ROW)->getValue();
Expand Down Expand Up @@ -164,7 +181,7 @@ protected function openConfigFile(string $locale, string $language, string $loca
$this->log("Building locale {$locale} ($language) configuration");
$localeFolder = $this->getLocaleFolder($locale);

$configFileName = realpath($localeFolder . DIRECTORY_SEPARATOR . 'config');
$configFileName = realpath($localeFolder) . DIRECTORY_SEPARATOR . 'config';
$this->log("Writing locale configuration to {$configFileName}");

$configFile = fopen($configFileName, 'wb');
Expand All @@ -178,7 +195,7 @@ protected function openFunctionNameFile(string $locale, string $language, string
$this->log("Building locale {$locale} ($language) function names");
$localeFolder = $this->getLocaleFolder($locale);

$functionFileName = realpath($localeFolder . DIRECTORY_SEPARATOR . 'functions');
$functionFileName = realpath($localeFolder) . DIRECTORY_SEPARATOR . 'functions';
$this->log("Writing local function names to {$functionFileName}");

$functionFile = fopen($functionFileName, 'wb');
Expand All @@ -189,11 +206,13 @@ protected function openFunctionNameFile(string $locale, string $language, string

protected function getLocaleFolder(string $locale): string
{
$lastchar = substr($this->translationBaseFolder, -1);
$dirsep = ($lastchar === '/' || $lastchar === '\\') ? '' : DIRECTORY_SEPARATOR;
$localeFolder = $this->translationBaseFolder .
DIRECTORY_SEPARATOR .
$dirsep .
str_replace('_', DIRECTORY_SEPARATOR, $locale);
if (!file_exists($localeFolder) || !is_dir($localeFolder)) {
mkdir($localeFolder, 0777, true);
mkdir($localeFolder, 7 * 64 + 7 * 8 + 7, true); // octal 777
}

return $localeFolder;
Expand Down
Binary file modified src/PhpSpreadsheet/Calculation/locale/Translations.xlsx
Binary file not shown.
33 changes: 15 additions & 18 deletions src/PhpSpreadsheet/Calculation/locale/bg/config
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
############################################################
##
## PhpSpreadsheet
## PhpSpreadsheet - locale settings
##
## български (Bulgarian)
##
##


ArgumentSeparator = ;

############################################################

ArgumentSeparator = ;
##
## (For future use)
## (For future use)
##
currencySymbol = лв

currencySymbol = лв

##
## Excel Error Codes (For future use)

## Error Codes
##
NULL = #ПРАЗНО!
DIV0 = #ДЕЛ/0!
VALUE = #СТОЙНОСТ!
REF = #РЕФ!
NAME = #ИМЕ?
NUM = #ЧИСЛО!
NA = #Н/Д
NULL = #ПРАЗНО!
DIV0 = #ДЕЛ/0!
VALUE = #СТОЙНОСТ!
REF = #РЕФ!
NAME = #ИМЕ?
NUM = #ЧИСЛО!
NA = #Н/Д
Loading