From 65309dbe78f0b49afe89a157c1798ef4d2aeca37 Mon Sep 17 00:00:00 2001 From: MarkBaker Date: Thu, 20 May 2021 18:53:41 +0200 Subject: [PATCH] Fix unit tests for function list markdown, and style issues for DOLLAR/USDOLLAR --- infra/LocaleGenerator.php | 27 ++++---- .../Calculation/Financial/Dollar.php | 2 - .../Functions/Financial/UsDollarTest.php | 1 - .../DocumentGeneratorTest.php | 68 +++++++++---------- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/infra/LocaleGenerator.php b/infra/LocaleGenerator.php index ca09c2bb..0339fc6c 100644 --- a/infra/LocaleGenerator.php +++ b/infra/LocaleGenerator.php @@ -2,8 +2,10 @@ namespace PhpOffice\PhpSpreadsheetInfra; +use Exception; use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\IOFactory; +use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\Column; use PhpOffice\PhpSpreadsheet\Worksheet\Row; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; @@ -25,24 +27,24 @@ class LocaleGenerator private const ENGLISH_REFERENCE_COLUMN = 'B'; /** - * @var string $translationSpreadsheetName + * @var string */ protected $translationSpreadsheetName; /** - * @var string $translationBaseFolder + * @var string */ protected $translationBaseFolder; protected $phpSpreadsheetFunctions; /** - * @var Spreadsheet $translationSpreadsheet + * @var Spreadsheet */ protected $translationSpreadsheet; /** - * @var Worksheet $localeTranslations + * @var Worksheet */ protected $localeTranslations; @@ -51,7 +53,7 @@ class LocaleGenerator protected $errorCodeMap = []; /** - * @var Worksheet $functionNameTranslations + * @var Worksheet */ private $functionNameTranslations; @@ -69,7 +71,7 @@ class LocaleGenerator $this->phpSpreadsheetFunctions = $phpSpreadsheetFunctions; } - public function generateLocales() + public function generateLocales(): void { $this->openTranslationWorkbook(); @@ -90,7 +92,7 @@ class LocaleGenerator } } - protected function buildConfigFileForLocale($column, $locale) + protected function buildConfigFileForLocale($column, $locale): void { $language = $this->localeTranslations->getCell($column . self::ENGLISH_LANGUAGE_NAME_ROW)->getValue(); $localeLanguage = $this->localeTranslations->getCell($column . self::LOCALE_LANGUAGE_NAME_ROW)->getValue(); @@ -114,7 +116,7 @@ class LocaleGenerator fclose($configFile); } - protected function writeConfigArgumentSeparator($configFile, $column) + protected function writeConfigArgumentSeparator($configFile, $column): void { $translationCell = $this->localeTranslations->getCell($column . self::ARGUMENT_SEPARATOR_ROW); $localeValue = $translationCell->getValue(); @@ -122,11 +124,11 @@ class LocaleGenerator $functionTranslation = "ArgumentSeparator = {$localeValue}" . PHP_EOL; fwrite($configFile, $functionTranslation); } else { - echo "No Argument Separator defined", PHP_EOL; + echo 'No Argument Separator defined', PHP_EOL; } } - protected function buildFunctionsFileForLocale($column, $locale) + protected function buildFunctionsFileForLocale($column, $locale): void { $language = $this->functionNameTranslations->getCell($column . self::ENGLISH_LANGUAGE_NAME_ROW)->getValue(); $localeLanguage = $this->functionNameTranslations->getCell($column . self::LOCALE_LANGUAGE_NAME_ROW) @@ -159,7 +161,7 @@ class LocaleGenerator $configFileName = realpath($localeFolder . DIRECTORY_SEPARATOR . 'config'); echo "Writing locale configuration to {$configFileName}", PHP_EOL; - $configFile = fopen($configFileName, 'w'); + $configFile = fopen($configFileName, 'wb'); $this->writeFileHeader($configFile, $localeLanguage, $language, 'locale settings'); return $configFile; @@ -173,7 +175,7 @@ class LocaleGenerator $functionFileName = realpath($localeFolder . DIRECTORY_SEPARATOR . 'functions'); echo "Writing local function names to {$functionFileName}", PHP_EOL; - $functionFile = fopen($functionFileName, 'w'); + $functionFile = fopen($functionFileName, 'wb'); $this->writeFileHeader($functionFile, $localeLanguage, $language, 'function name translations'); return $functionFile; @@ -300,6 +302,7 @@ class LocaleGenerator echo 'CATEGORY: ', $cell->getValue(), PHP_EOL; $this->functionNameMap[$cell->getValue()] = $cell->getRow(); } + continue; } if ($cell->getValue() != '') { diff --git a/src/PhpSpreadsheet/Calculation/Financial/Dollar.php b/src/PhpSpreadsheet/Calculation/Financial/Dollar.php index 7791a0eb..e6a0392a 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Dollar.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Dollar.php @@ -2,9 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\Financial; -use PhpOffice\PhpSpreadsheet\Calculation\Exception; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\MathTrig\Round; use PhpOffice\PhpSpreadsheet\Calculation\TextData\Format; class Dollar diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php index 833d9702..770b8ffa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php @@ -11,7 +11,6 @@ class UsDollarTest extends TestCase * @dataProvider providerUSDOLLAR * * @param mixed $expectedResult - * @param mixed $message */ public function testUSDOLLAR($expectedResult, ...$args): void { diff --git a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php index 45000f8e..8d6b15bf 100644 --- a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php @@ -41,16 +41,16 @@ class DocumentGeneratorTest extends TestCase ## A -Excel Function | Category | PhpSpreadsheet Function ---------------------|--------------------------------|------------------------------------------- -ABS | CATEGORY_MATH_AND_TRIG | abs -AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd +Excel Function | Category | PhpSpreadsheet Function +-------------------------|--------------------------------|-------------------------------------- +ABS | CATEGORY_MATH_AND_TRIG | abs +AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd ## I -Excel Function | Category | PhpSpreadsheet Function ---------------------|--------------------------------|------------------------------------------- -IFS | CATEGORY_LOGICAL | **Not yet Implemented** +Excel Function | Category | PhpSpreadsheet Function +-------------------------|--------------------------------|-------------------------------------- +IFS | CATEGORY_LOGICAL | **Not yet Implemented** EXPECTED @@ -72,66 +72,66 @@ EXPECTED ## CATEGORY_CUBE -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_DATABASE -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_DATE_AND_TIME -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_ENGINEERING -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_FINANCIAL -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_INFORMATION -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_LOGICAL -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- -AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd -IFS | **Not yet Implemented** +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- +AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd +IFS | **Not yet Implemented** ## CATEGORY_LOOKUP_AND_REFERENCE -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_MATH_AND_TRIG -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- -ABS | abs +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- +ABS | abs ## CATEGORY_STATISTICAL -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_TEXT_AND_DATA -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- ## CATEGORY_WEB -Excel Function | PhpSpreadsheet Function ---------------------|------------------------------------------- +Excel Function | PhpSpreadsheet Function +-------------------------|-------------------------------------- EXPECTED