From 3eedf9e2f092fcaf5fa6119cb19a3be56be553c6 Mon Sep 17 00:00:00 2001 From: oleibman <10341515+oleibman@users.noreply.github.com> Date: Fri, 5 Jan 2024 01:43:50 -0800 Subject: [PATCH] Better Typing in Test Members Change "mixed" declarations to more accurate types in test members; in particular, change those that would be flagged if we were to run Phpstan at level 9 (we currently run level 8). I may or may not follow up with source code (over 700 level-9 problems remain for src), but, as with strict typing, there is no reason to avoid the effort for test members. It was necessary to update some doc blocks in src to accommodate this change. However, no executable code is touched. --- .php-cs-fixer.dist.php | 2 +- .phpcs.xml.dist | 1 + bin/check-phpdoc-types | 8 +++---- phpstan.neon.dist | 1 + .../Calculation/DateTimeExcel/Date.php | 4 ++-- .../Calculation/DateTimeExcel/DateValue.php | 4 ++-- .../Calculation/DateTimeExcel/TimeValue.php | 2 +- .../Calculation/DateTimeExcel/Week.php | 2 +- .../Calculation/Engineering/Compare.php | 12 +++++----- .../Calculation/Engineering/ConvertBinary.php | 10 ++++---- .../Engineering/ConvertDecimal.php | 10 ++++---- .../Calculation/Engineering/ConvertHex.php | 6 ++--- .../Calculation/Engineering/ConvertOctal.php | 6 ++--- src/PhpSpreadsheet/Shared/Font.php | 4 ++-- .../Calculation/CalculationTest.php | 4 ++-- .../Functions/DateTime/DateTest.php | 4 ++-- .../Functions/DateTime/DateValueTest.php | 19 ++++++++------- .../Functions/DateTime/DaysTest.php | 4 ++-- .../Functions/DateTime/TimeTest.php | 4 ++-- .../Functions/DateTime/TimeValueTest.php | 4 ++-- .../Functions/DateTime/WeekDayTest.php | 4 ++-- .../Functions/Engineering/Bin2DecTest.php | 12 ++++++---- .../Functions/Engineering/Bin2HexTest.php | 12 ++++++---- .../Functions/Engineering/Bin2OctTest.php | 12 ++++++---- .../Functions/Engineering/BitAndTest.php | 4 ++-- .../Functions/Engineering/BitLShiftTest.php | 4 ++-- .../Functions/Engineering/BitOrTest.php | 4 ++-- .../Functions/Engineering/BitRShiftTest.php | 4 ++-- .../Functions/Engineering/BitXorTest.php | 4 ++-- .../Functions/Engineering/ComplexTest.php | 1 + .../Functions/Engineering/ConvertUoMTest.php | 4 ++-- .../Functions/Engineering/Dec2BinTest.php | 12 ++++++---- .../Functions/Engineering/Dec2HexTest.php | 12 ++++++---- .../Functions/Engineering/Dec2OctTest.php | 12 ++++++---- .../Functions/Engineering/DeltaTest.php | 4 ++-- .../Functions/Engineering/GeStepTest.php | 4 ++-- .../Functions/Engineering/Hex2BinTest.php | 12 ++++++---- .../Functions/Engineering/Hex2DecTest.php | 12 ++++++---- .../Functions/Engineering/Hex2OctTest.php | 12 ++++++---- .../Functions/Engineering/ImAbsTest.php | 4 ++-- .../Functions/Engineering/ImArgumentTest.php | 4 ++-- .../Functions/Engineering/ImConjugateTest.php | 5 ++-- .../Functions/Engineering/ImCosTest.php | 5 ++-- .../Functions/Engineering/ImCoshTest.php | 5 ++-- .../Functions/Engineering/ImCotTest.php | 5 ++-- .../Functions/Engineering/ImCscTest.php | 6 +++-- .../Functions/Engineering/ImCschTest.php | 5 ++-- .../Functions/Engineering/ImDivTest.php | 5 ++-- .../Functions/Engineering/ImExpTest.php | 5 ++-- .../Functions/Engineering/ImLnTest.php | 5 ++-- .../Functions/Engineering/ImLog10Test.php | 5 ++-- .../Functions/Engineering/ImLog2Test.php | 5 ++-- .../Functions/Engineering/ImPowerTest.php | 5 ++-- .../Functions/Engineering/ImProductTest.php | 5 +++- .../Functions/Engineering/ImRealTest.php | 4 ++-- .../Functions/Engineering/ImSecTest.php | 5 ++-- .../Functions/Engineering/ImSechTest.php | 5 ++-- .../Functions/Engineering/ImSinTest.php | 5 ++-- .../Functions/Engineering/ImSinhTest.php | 5 ++-- .../Functions/Engineering/ImSqrtTest.php | 5 ++-- .../Functions/Engineering/ImSubTest.php | 5 ++-- .../Functions/Engineering/ImSumTest.php | 5 +++- .../Functions/Engineering/ImTanTest.php | 5 ++-- .../Functions/Engineering/ImaginaryTest.php | 4 ++-- .../Functions/Engineering/Oct2BinTest.php | 12 ++++++---- .../Functions/Engineering/Oct2DecTest.php | 12 ++++++---- .../Functions/Engineering/Oct2HexTest.php | 12 ++++++---- .../Functions/Financial/HelpersTest.php | 2 +- .../Functions/FormulaArguments.php | 7 +++++- .../Calculation/Functions/Logical/AndTest.php | 2 +- .../Calculation/Functions/Logical/OrTest.php | 2 +- .../Functions/Logical/SwitchTest.php | 2 +- .../LookupRef/IndirectInternationalTest.php | 1 + .../Functions/LookupRef/MatchTest.php | 4 ++-- .../Functions/MathTrig/AcotTest.php | 2 +- .../Functions/MathTrig/AcothTest.php | 2 +- .../Functions/MathTrig/CotTest.php | 2 +- .../Functions/MathTrig/CothTest.php | 2 +- .../Functions/MathTrig/CscTest.php | 2 +- .../Functions/MathTrig/CschTest.php | 2 +- .../Functions/MathTrig/EvenTest.php | 2 +- .../Functions/MathTrig/MRoundTest.php | 2 +- .../Functions/MathTrig/MdeTermTest.php | 2 +- .../Functions/MathTrig/OddTest.php | 2 +- .../Functions/MathTrig/RandBetweenTest.php | 2 +- .../Functions/MathTrig/RomanTest.php | 2 +- .../Functions/MathTrig/RoundDownTest.php | 2 +- .../Functions/MathTrig/RoundTest.php | 2 +- .../Functions/MathTrig/RoundUpTest.php | 2 +- .../Functions/MathTrig/SecTest.php | 2 +- .../Functions/MathTrig/SechTest.php | 2 +- .../Functions/MathTrig/SignTest.php | 2 +- .../Functions/MathTrig/SubTotalTest.php | 6 ++--- .../Statistical/AllSetupTeardown.php | 7 ++++-- .../Statistical/ChiDistLeftTailTest.php | 1 + .../Statistical/ChiInvLeftTailTest.php | 1 + .../Statistical/ChiInvRightTailTest.php | 1 + .../Functions/Statistical/LinEstTest.php | 2 +- .../Functions/Statistical/LogEstTest.php | 2 +- .../Functions/TextData/LeftTest.php | 2 +- .../Functions/TextData/LowerTest.php | 2 +- .../Functions/TextData/MidTest.php | 2 +- .../Functions/TextData/ProperTest.php | 2 +- .../Functions/TextData/RightTest.php | 2 +- .../Functions/TextData/UpperTest.php | 2 +- .../Functions/TextData/ValueToTextTest.php | 2 +- .../Cell/AdvancedValueBinderTest.php | 2 +- .../Cell/CellAddressTest.php | 2 +- .../Cell/CoordinateTest.php | 12 +++++----- .../Custom/ComplexAssert.php | 4 ++-- .../Document/PropertiesTest.php | 5 ++-- .../Functional/ReadFilterTest.php | 4 ++-- tests/PhpSpreadsheetTests/Helper/HtmlTest.php | 2 +- .../Reader/Ods/OdsPropertiesTest.php | 2 ++ .../Reader/Security/XmlScannerTest.php | 6 ++--- .../Reader/Xls/RichTextSizeTest.php | 4 +++- .../Reader/Xlsx/PropertiesTest.php | 2 ++ .../Reader/Xlsx/XlsxRootZipFilesTest.php | 2 ++ .../Reader/Xml/XmlLoadTest.php | 1 + .../Shared/CodePageTest.php | 4 +++- tests/PhpSpreadsheetTests/Shared/DateTest.php | 24 +++++++++++-------- tests/PhpSpreadsheetTests/Shared/FontTest.php | 6 ++--- .../Shared/StringHelperInvalidCharTest.php | 1 + .../Shared/Trend/ExponentialBestFitTest.php | 13 ++++++---- .../Shared/Trend/LinearBestFitTest.php | 13 ++++++---- tests/PhpSpreadsheetTests/Style/ColorTest.php | 4 ++-- .../Worksheet/AutoFilter/DateGroupTest.php | 1 + .../Writer/Html/HtmlNumberFormatTest.php | 4 ++-- .../Writer/Xls/WorkbookTest.php | 1 + .../Writer/Xlsx/ArrayFormulaPrefixTest.php | 2 ++ 130 files changed, 372 insertions(+), 253 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index fb50aeaf5..3450555d9 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -3,7 +3,7 @@ $finder = PhpCsFixer\Finder::create() ->exclude('vendor') ->notPath('src/PhpSpreadsheet/Writer/ZipStream3.php') - ->name('/(\.php|^generate-document|^generate-locales)$/') + ->name('/(\.php|^generate-document|^generate-locales|^check-phpdoc-types)$/') ->in(__DIR__); $config = new PhpCsFixer\Config(); diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index d902156dc..ccaa25f0a 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -8,6 +8,7 @@ infra bin/generate-document bin/generate-locales + bin/check-phpdoc-types samples/Header.php */tests/Core/*/*Test\.(inc|css|js)$ diff --git a/bin/check-phpdoc-types b/bin/check-phpdoc-types index 7f69315fa..b28c25331 100755 --- a/bin/check-phpdoc-types +++ b/bin/check-phpdoc-types @@ -10,9 +10,9 @@ */ function checkPhpDocTypes(): void { - $content = `git diff --cached` ?? `git diff` ?? `git show HEAD`; - preg_match_all('~^\+ +\* @(param|var) (mixed|string|int|float|bool|null|array|\?|\|)+( \$\w+)?$~m', $content, $parameters); - preg_match_all('~^\+ +\* @return (mixed|string|int|float|bool|null|array|void|\?|\|)+$~m', $content, $returns); + $content = shell_exec('git diff --cached') ?? shell_exec('git diff') ?? shell_exec('git show HEAD'); + preg_match_all('~^\+ +\* @(param|var) (mixed|string|int|float|bool|null|array|\?|\|)+( \$\w+)?$~m', "$content", $parameters); + preg_match_all('~^\+ +\* @return (mixed|string|int|float|bool|null|array|void|\?|\|)+$~m', "$content", $returns); $errors = [ ...$parameters[0], @@ -21,7 +21,7 @@ function checkPhpDocTypes(): void if ($errors) { echo 'PHP native types must be used instead of PHPDoc types (without comments), for the following lines:' . PHP_EOL . PHP_EOL; - echo join(PHP_EOL, $errors) . PHP_EOL; + echo implode(PHP_EOL, $errors) . PHP_EOL; exit(1); } } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e7d0eb41b..de7dee864 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -12,6 +12,7 @@ parameters: - infra/ - bin/generate-document - bin/generate-locales + - bin/check-phpdoc-types excludePaths: - src/PhpSpreadsheet/Chart/Renderer/JpGraph.php - src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php index 9dd7f7a29..c9c645881 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php @@ -27,7 +27,7 @@ class Date * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. * - * @param array|int|string $year The value of the year argument can include one to four digits. + * @param array|float|int|string $year The value of the year argument can include one to four digits. * Excel interprets the year argument according to the configured * date system: 1900 or 1904. * If year is between 0 (zero) and 1899 (inclusive), Excel adds that @@ -63,7 +63,7 @@ class Date * If an array of numbers is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function fromYMD(array|int|string $year, array|float|int|string $month, array|float|int|string $day): mixed + public static function fromYMD(array|float|int|string $year, array|float|int|string $month, array|float|int|string $day): mixed { if (is_array($year) || is_array($month) || is_array($day)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $year, $month, $day); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php index 4daa74ab6..4bf75dd3d 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php @@ -24,7 +24,7 @@ class DateValue * Excel Function: * DATEVALUE(dateValue) * - * @param null|array|int|string $dateValue Text that represents a date in a Microsoft Excel date format. + * @param null|array|bool|float|int|string $dateValue Text that represents a date in a Microsoft Excel date format. * For example, "1/30/2008" or "30-Jan-2008" are text strings within * quotation marks that represent dates. Using the default date * system in Excel for Windows, date_text must represent a date from @@ -39,7 +39,7 @@ class DateValue * If an array of numbers is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function fromString(null|array|string|int|bool $dateValue): mixed + public static function fromString(null|array|string|int|bool|float $dateValue): mixed { if (is_array($dateValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $dateValue); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php index 5a2f2461b..88a4affac 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php @@ -25,7 +25,7 @@ class TimeValue * Excel Function: * TIMEVALUE(timeValue) * - * @param null|array|string $timeValue A text string that represents a time in any one of the Microsoft + * @param null|array|bool|int|string $timeValue A text string that represents a time in any one of the Microsoft * Excel time formats; for example, "6:45 PM" and "18:45" text strings * within quotation marks that represent time. * Date information in time_text is ignored. diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php index 1d02c2073..e620b4ca0 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php @@ -137,7 +137,7 @@ class Week * Excel Function: * WEEKDAY(dateValue[,style]) * - * @param null|array|float|int|string $dateValue Excel date serial value (float), PHP date timestamp (integer), + * @param null|array|bool|float|int|string $dateValue Excel date serial value (float), PHP date timestamp (integer), * PHP DateTime object, or a standard date string * Or can be an array of date values * @param mixed $style A number that determines the type of return value diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Compare.php b/src/PhpSpreadsheet/Calculation/Engineering/Compare.php index 8b0b86a4e..9e3275fc2 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Compare.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Compare.php @@ -20,16 +20,16 @@ class Compare * functions you calculate the count of equal pairs. This function is also known as the * Kronecker Delta function. * - * @param array|float $a the first number + * @param array|bool|float|int|string $a the first number * Or can be an array of values - * @param array|float $b The second number. If omitted, b is assumed to be zero. + * @param array|bool|float|int|string $b The second number. If omitted, b is assumed to be zero. * Or can be an array of values * * @return array|int|string (string in the event of an error) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function DELTA(array|float|bool|string $a, array|float|bool|string $b = 0.0): array|string|int + public static function DELTA(array|float|bool|string|int $a, array|float|bool|string|int $b = 0.0): array|string|int { if (is_array($a) || is_array($b)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $a, $b); @@ -55,16 +55,16 @@ class Compare * Use this function to filter a set of values. For example, by summing several GESTEP * functions you calculate the count of values that exceed a threshold. * - * @param array|float $number the value to test against step + * @param array|bool|float|int|string $number the value to test against step * Or can be an array of values - * @param null|array|float $step The threshold value. If you omit a value for step, GESTEP uses zero. + * @param null|array|bool|float|int|string $step The threshold value. If you omit a value for step, GESTEP uses zero. * Or can be an array of values * * @return array|int|string (string in the event of an error) * If an array of numbers is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function GESTEP(array|float|bool|string $number, $step = 0.0): array|string|int + public static function GESTEP(array|float|bool|string|int $number, $step = 0.0): array|string|int { if (is_array($number) || is_array($step)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $step); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php index f21b4d5a3..9c00dcb54 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php @@ -15,7 +15,7 @@ class ConvertBinary extends ConvertBase * Excel Function: * BIN2DEC(x) * - * @param array|string $value The binary number (as a string) that you want to convert. The number + * @param array|bool|float|int|string $value The binary number (as a string) that you want to convert. The number * cannot contain more than 10 characters (10 bits). The most significant * bit of number is the sign bit. The remaining 9 bits are magnitude bits. * Negative numbers are represented using two's-complement notation. @@ -58,14 +58,14 @@ class ConvertBinary extends ConvertBase * Excel Function: * BIN2HEX(x[,places]) * - * @param array|string $value The binary number (as a string) that you want to convert. The number + * @param array|bool|float|int|string $value The binary number (as a string) that you want to convert. The number * cannot contain more than 10 characters (10 bits). The most significant * bit of number is the sign bit. The remaining 9 bits are magnitude bits. * Negative numbers are represented using two's-complement notation. * If number is not a valid binary number, or if number contains more than * 10 characters (10 bits), BIN2HEX returns the #NUM! error value. * Or can be an array of values - * @param array|int $places The number of characters to use. If places is omitted, BIN2HEX uses the + * @param null|array|float|int|string $places The number of characters to use. If places is omitted, BIN2HEX uses the * minimum number of characters necessary. Places is useful for padding the * return value with leading 0s (zeros). * If places is not an integer, it is truncated. @@ -111,14 +111,14 @@ class ConvertBinary extends ConvertBase * Excel Function: * BIN2OCT(x[,places]) * - * @param array|string $value The binary number (as a string) that you want to convert. The number + * @param array|bool|float|int|string $value The binary number (as a string) that you want to convert. The number * cannot contain more than 10 characters (10 bits). The most significant * bit of number is the sign bit. The remaining 9 bits are magnitude bits. * Negative numbers are represented using two's-complement notation. * If number is not a valid binary number, or if number contains more than * 10 characters (10 bits), BIN2OCT returns the #NUM! error value. * Or can be an array of values - * @param array|int $places The number of characters to use. If places is omitted, BIN2OCT uses the + * @param null|array|float|int|string $places The number of characters to use. If places is omitted, BIN2OCT uses the * minimum number of characters necessary. Places is useful for padding the * return value with leading 0s (zeros). * If places is not an integer, it is truncated. diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php index 14ee68795..923caa96d 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php @@ -22,7 +22,7 @@ class ConvertDecimal extends ConvertBase * Excel Function: * DEC2BIN(x[,places]) * - * @param array|string $value The decimal integer you want to convert. If number is negative, + * @param array|bool|float|int|string $value The decimal integer you want to convert. If number is negative, * valid place values are ignored and DEC2BIN returns a 10-character * (10-bit) binary number in which the most significant bit is the sign * bit. The remaining 9 bits are magnitude bits. Negative numbers are @@ -33,7 +33,7 @@ class ConvertDecimal extends ConvertBase * If DEC2BIN requires more than places characters, it returns the #NUM! * error value. * Or can be an array of values - * @param array|int $places The number of characters to use. If places is omitted, DEC2BIN uses + * @param null|array|float|int|string $places The number of characters to use. If places is omitted, DEC2BIN uses * the minimum number of characters necessary. Places is useful for * padding the return value with leading 0s (zeros). * If places is not an integer, it is truncated. @@ -79,7 +79,7 @@ class ConvertDecimal extends ConvertBase * Excel Function: * DEC2HEX(x[,places]) * - * @param array|string $value The decimal integer you want to convert. If number is negative, + * @param array|bool|float|int|string $value The decimal integer you want to convert. If number is negative, * places is ignored and DEC2HEX returns a 10-character (40-bit) * hexadecimal number in which the most significant bit is the sign * bit. The remaining 39 bits are magnitude bits. Negative numbers @@ -90,7 +90,7 @@ class ConvertDecimal extends ConvertBase * If DEC2HEX requires more than places characters, it returns the * #NUM! error value. * Or can be an array of values - * @param array|int $places The number of characters to use. If places is omitted, DEC2HEX uses + * @param null|array|float|int|string $places The number of characters to use. If places is omitted, DEC2HEX uses * the minimum number of characters necessary. Places is useful for * padding the return value with leading 0s (zeros). * If places is not an integer, it is truncated. @@ -155,7 +155,7 @@ class ConvertDecimal extends ConvertBase * Excel Function: * DEC2OCT(x[,places]) * - * @param array|string $value The decimal integer you want to convert. If number is negative, + * @param array|bool|float|int|string $value The decimal integer you want to convert. If number is negative, * places is ignored and DEC2OCT returns a 10-character (30-bit) * octal number in which the most significant bit is the sign bit. * The remaining 29 bits are magnitude bits. Negative numbers are diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php index 9d39acfbc..0003a9fda 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php @@ -15,7 +15,7 @@ class ConvertHex extends ConvertBase * Excel Function: * HEX2BIN(x[,places]) * - * @param array|string $value The hexadecimal number you want to convert. + * @param array|bool|float|string $value The hexadecimal number you want to convert. * Number cannot contain more than 10 characters. * The most significant bit of number is the sign bit (40th bit from the right). * The remaining 9 bits are magnitude bits. @@ -65,7 +65,7 @@ class ConvertHex extends ConvertBase * Excel Function: * HEX2DEC(x) * - * @param array|string $value The hexadecimal number you want to convert. This number cannot + * @param array|bool|float|int|string $value The hexadecimal number you want to convert. This number cannot * contain more than 10 characters (40 bits). The most significant * bit of number is the sign bit. The remaining 39 bits are magnitude * bits. Negative numbers are represented using two's-complement @@ -118,7 +118,7 @@ class ConvertHex extends ConvertBase * Excel Function: * HEX2OCT(x[,places]) * - * @param array|string $value The hexadecimal number you want to convert. Number cannot + * @param array|bool|float|int|string $value The hexadecimal number you want to convert. Number cannot * contain more than 10 characters. The most significant bit of * number is the sign bit. The remaining 39 bits are magnitude * bits. Negative numbers are represented using two's-complement diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php index 8436a63ef..5e3c12482 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php @@ -15,7 +15,7 @@ class ConvertOctal extends ConvertBase * Excel Function: * OCT2BIN(x[,places]) * - * @param array|string $value The octal number you want to convert. Number may not + * @param array|bool|float|int|string $value The octal number you want to convert. Number may not * contain more than 10 characters. The most significant * bit of number is the sign bit. The remaining 29 bits * are magnitude bits. Negative numbers are represented @@ -69,7 +69,7 @@ class ConvertOctal extends ConvertBase * Excel Function: * OCT2DEC(x) * - * @param array|string $value The octal number you want to convert. Number may not contain + * @param array|bool|float|int|string $value The octal number you want to convert. Number may not contain * more than 10 octal characters (30 bits). The most significant * bit of number is the sign bit. The remaining 29 bits are * magnitude bits. Negative numbers are represented using @@ -118,7 +118,7 @@ class ConvertOctal extends ConvertBase * Excel Function: * OCT2HEX(x[,places]) * - * @param array|string $value The octal number you want to convert. Number may not contain + * @param array|bool|float|int|string $value The octal number you want to convert. Number may not contain * more than 10 octal characters (30 bits). The most significant * bit of number is the sign bit. The remaining 29 bits are * magnitude bits. Negative numbers are represented using diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index 788d72539..01af7ba18 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -499,11 +499,11 @@ class Font /** * Calculate an (approximate) pixel size, based on a font points size. * - * @param int $fontSizeInPoints Font size (in points) + * @param float|int $fontSizeInPoints Font size (in points) * * @return int Font size (in pixels) */ - public static function fontSizeToPixels(int $fontSizeInPoints): int + public static function fontSizeToPixels(float|int $fontSizeInPoints): int { return (int) ((4 / 3) * $fontSizeInPoints); } diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php index 7e5204ad2..79685d267 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -35,7 +35,7 @@ class CalculationTest extends TestCase /** * @dataProvider providerBinaryComparisonOperation */ - public function testBinaryComparisonOperation(mixed $formula, mixed $expectedResultExcel, mixed $expectedResultOpenOffice): void + public function testBinaryComparisonOperation(string $formula, mixed $expectedResultExcel, mixed $expectedResultOpenOffice): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); $resultExcel = Calculation::getInstance()->_calculateFormulaValue($formula); @@ -360,7 +360,7 @@ class CalculationTest extends TestCase */ public function testFullExecutionDataPruning( mixed $expectedResult, - mixed $dataArray, + array $dataArray, string $formula, string $cellCoordinates, array $shouldBeSetInCacheCells = [], diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php index 494b41b90..57d535a03 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateTest.php @@ -39,9 +39,9 @@ class DateTest extends TestCase /** * @dataProvider providerDATE */ - public function testDirectCallToDATE(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToDATE(float|string $expectedResult, int|string $year, float|int|string $month, float|int|string $day): void { - $result = Date::fromYMD(...$args); + $result = Date::fromYMD($year, $month, $day); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php index edee0db08..27b652e42 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateValueTest.php @@ -42,32 +42,35 @@ class DateValueTest extends TestCase return is_string($expectedResult) && str_starts_with($expectedResult, 'Y-'); } - private function parseTemplatedExpectation(string $expectedResult): string + private function parseTemplatedExpectation(float|int|string $expectedResult): string { - return (string) DateValue::fromString( + /** @var float */ + $x = DateValue::fromString( (new DateTimeImmutable( - str_replace('Y', (new DateTimeImmutable('now'))->format('Y'), $expectedResult) + str_replace('Y', (new DateTimeImmutable('now'))->format('Y'), (string) $expectedResult) ))->format('Y-m-d') ); + + return (string) $x; } /** * @dataProvider providerDATEVALUE */ - public function testDirectCallToDATEVALUE(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToDATEVALUE(int|string $expectedResult, bool|int|string $value): void { if ($this->expectationIsTemplate($expectedResult)) { - $expectedResult = $this->parseTemplatedExpectation($expectedResult); + $expectedResult = $this->parseTemplatedExpectation((string) $expectedResult); } - $result = DateValue::fromString(...$args); + $result = DateValue::fromString($value); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8); } /** * @dataProvider providerDATEVALUE */ - public function testDATEVALUEAsFormula(mixed $expectedResult, mixed ...$args): void + public function testDATEVALUEAsFormula(float|int|string $expectedResult, mixed ...$args): void { if ($this->expectationIsTemplate($expectedResult)) { $expectedResult = $this->parseTemplatedExpectation($expectedResult); @@ -85,7 +88,7 @@ class DateValueTest extends TestCase /** * @dataProvider providerDATEVALUE */ - public function testDATEVALUEInWorksheet(mixed $expectedResult, mixed ...$args): void + public function testDATEVALUEInWorksheet(float|int|string $expectedResult, mixed ...$args): void { if ($this->expectationIsTemplate($expectedResult)) { $expectedResult = $this->parseTemplatedExpectation($expectedResult); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php index 0911cf478..8a783a3ec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -18,9 +18,9 @@ class DaysTest extends TestCase /** * @dataProvider providerDAYS */ - public function testDirectCallToDAYS(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToDAYS(int|string $expectedResult, int|string $date1, int|string $date2): void { - $result = Days::between(...$args); + $result = Days::between($date1, $date2); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php index f1097ba1b..3f757315b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeTest.php @@ -39,9 +39,9 @@ class TimeTest extends TestCase /** * @dataProvider providerTIME */ - public function testDirectCallToTIME(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToTIME(float|string $expectedResult, int|string $hour, bool|int $minute, int $second): void { - $result = Time::fromHMS(...$args); + $result = Time::fromHMS($hour, $minute, $second); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-12); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php index aca549142..f512d4c45 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/TimeValueTest.php @@ -33,9 +33,9 @@ class TimeValueTest extends TestCase /** * @dataProvider providerTIMEVALUE */ - public function testDirectCallToTIMEVALUE(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToTIMEVALUE(int|float|string $expectedResult, bool|int|string $value): void { - $result = TimeValue::fromString(...$args); + $result = TimeValue::fromString($value); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php index a29dd09a1..c147b8446 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -32,9 +32,9 @@ class WeekDayTest extends TestCase /** * @dataProvider providerWEEKDAY */ - public function testDirectCallToWEEKDAY(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToWEEKDAY(int|string $expectedResult, bool|int|string $dateValue, null|int|string $style = null): void { - $result = Week::day(...$args); + $result = ($style === null) ? Week::day($dateValue) : Week::day($dateValue, $style); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php index 0577a341a..1f4c1ad37 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2DecTest.php @@ -30,9 +30,9 @@ class Bin2DecTest extends TestCase /** * @dataProvider providerBIN2DEC */ - public function testDirectCallToBIN2DEC(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToBIN2DEC(string $expectedResult, bool|int|string $arg1): void { - $result = ConvertBinary::toDecimal(...$args); + $result = ConvertBinary::toDecimal($arg1); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Bin2DecTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=BIN2DEC({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Bin2DecTest extends TestCase /** * @dataProvider providerBIN2DECOds */ - public function testBIN2DECOds(mixed $expectedResult, mixed ...$args): void + public function testBIN2DECOds(string $expectedResult, bool $arg1): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertBinary::toDecimal(...$args); + $result = ConvertBinary::toDecimal($arg1); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Bin2DecTest extends TestCase $formula = '=BIN2DEC(101.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('5', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php index 2ed3ed21f..b2cf5bc40 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2HexTest.php @@ -30,9 +30,9 @@ class Bin2HexTest extends TestCase /** * @dataProvider providerBIN2HEX */ - public function testDirectCallToBIN2HEX(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToBIN2HEX(mixed $expectedResult, bool|float|int|string $value, null|float|int|string $digits = null): void { - $result = ConvertBinary::toHex(...$args); + $result = ($digits === null) ? ConvertBinary::toHex($value) : ConvertBinary::toHex($value, $digits); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Bin2HexTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=BIN2HEX({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Bin2HexTest extends TestCase /** * @dataProvider providerBIN2HEXOds */ - public function testBIN2HEXOds(mixed $expectedResult, mixed ...$args): void + public function testBIN2HEXOds(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertBinary::toDecimal(...$args); + $result = ($digits === null) ? ConvertBinary::toHex($value) : ConvertBinary::toHex($value, $digits); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Bin2HexTest extends TestCase $formula = '=BIN2HEX(101.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('5', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php index b15bbd3eb..f0db0c1fb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Bin2OctTest.php @@ -30,9 +30,9 @@ class Bin2OctTest extends TestCase /** * @dataProvider providerBIN2OCT */ - public function testDirectCallToBIN2OCT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToBIN2OCT(mixed $expectedResult, bool|float|int|string $value, null|float|int|string $digits = null): void { - $result = ConvertBinary::toOctal(...$args); + $result = ($digits === null) ? ConvertBinary::toOctal($value) : ConvertBinary::toOctal($value, $digits); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Bin2OctTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=BIN2OCT({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Bin2OctTest extends TestCase /** * @dataProvider providerBIN2OCTOds */ - public function testBIN2OCTOds(mixed $expectedResult, mixed ...$args): void + public function testBIN2OCTOds(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertBinary::toDecimal(...$args); + $result = ($digits === null) ? ConvertBinary::toOctal($value) : ConvertBinary::toOctal($value, $digits); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Bin2OctTest extends TestCase $formula = '=BIN2OCT(101.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('5', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php index 047ec142c..ed3ba5562 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php @@ -16,9 +16,9 @@ class BitAndTest extends TestCase /** * @dataProvider providerBITAND */ - public function testDirectCallToBITAND(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToBITAND(mixed $expectedResult, null|bool|int|float|string $arg1, null|bool|int|float|string $arg2): void { - $result = BitWise::BITAND(...$args); + $result = BitWise::BITAND($arg1, $arg2); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php index 3a21e3f1a..a0bd6b758 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitLShiftTest.php @@ -16,9 +16,9 @@ class BitLShiftTest extends TestCase /** * @dataProvider providerBITLSHIFT */ - public function testDirectCallToBITLSHIFT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToBITLSHIFT(float|int|string $expectedResult, null|bool|int|float|string $arg1, null|bool|int|float|string $arg2): void { - $result = BitWise::BITLSHIFT(...$args); + $result = BitWise::BITLSHIFT($arg1, $arg2); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php index b697e9116..9471f27d2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitOrTest.php @@ -16,9 +16,9 @@ class BitOrTest extends TestCase /** * @dataProvider providerBITOR */ - public function testDirectCallToBITOR(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToBITOR(mixed $expectedResult, null|bool|int|float|string $arg1, null|bool|int|float|string $arg2): void { - $result = BitWise::BITOR(...$args); + $result = BitWise::BITOR($arg1, $arg2); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php index 46f866886..e68173e36 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitRShiftTest.php @@ -16,9 +16,9 @@ class BitRShiftTest extends TestCase /** * @dataProvider providerBITRSHIFT */ - public function testDirectCallToBITRSHIFT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToBITRSHIFT(float|int|string $expectedResult, null|bool|int|float|string $arg1, null|bool|int|float|string $arg2): void { - $result = BitWise::BITRSHIFT(...$args); + $result = BitWise::BITRSHIFT($arg1, $arg2); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php index b62c9cc9c..a9e6489b9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitXorTest.php @@ -16,9 +16,9 @@ class BitXorTest extends TestCase /** * @dataProvider providerBITXOR */ - public function testDirectCallToBITXOR(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToBITXOR(int|string $expectedResult, null|bool|int|float|string $arg1, null|bool|int|float|string $arg2): void { - $result = BitWise::BITXOR(...$args); + $result = BitWise::BITXOR($arg1, $arg2); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php index 75dc792bf..17954601b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ComplexTest.php @@ -36,6 +36,7 @@ class ComplexTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=COMPLEX({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php index fd9b7bca3..a41e23f78 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ConvertUoMTest.php @@ -48,9 +48,9 @@ class ConvertUoMTest extends TestCase /** * @dataProvider providerCONVERTUOM */ - public function testDirectCallToCONVERTUOM(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToCONVERTUOM(float|int|string $expectedResult, float|int|string $value, string $from, string $to): void { - $result = ConvertUOM::convert(...$args); + $result = ConvertUOM::convert($value, $from, $to); self::assertEqualsWithDelta($expectedResult, $result, self::UOM_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php index 13f74b353..51f73261f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2BinTest.php @@ -29,9 +29,9 @@ class Dec2BinTest extends TestCase /** * @dataProvider providerDEC2BIN */ - public function testDirectCallToDEC2BIN(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToDEC2BIN(mixed $expectedResult, bool|float|int|string $value, null|float|int|string $digits = null): void { - $result = ConvertDecimal::toBinary(...$args); + $result = ($digits === null) ? ConvertDecimal::toBinary($value) : ConvertDecimal::toBinary($value, $digits); self::assertSame($expectedResult, $result); } @@ -50,6 +50,7 @@ class Dec2BinTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DEC2BIN({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -110,11 +111,11 @@ class Dec2BinTest extends TestCase /** * @dataProvider providerDEC2BINOds */ - public function testDEC2BINOds(mixed $expectedResult, mixed ...$args): void + public function testDEC2BINOds(mixed $expectedResult, bool|float|int|string $value, null|float|int|string $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertDecimal::toBinary(...$args); + $result = ($digits === null) ? ConvertDecimal::toBinary($value) : ConvertDecimal::toBinary($value, $digits); self::assertSame($expectedResult, $result); } @@ -129,14 +130,17 @@ class Dec2BinTest extends TestCase $formula = '=DEC2BIN(5.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('101', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('101', $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('101', $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php index 7529d2782..2be971d81 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2HexTest.php @@ -29,9 +29,9 @@ class Dec2HexTest extends TestCase /** * @dataProvider providerDEC2HEX */ - public function testDirectCallToDEC2HEX(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToDEC2HEX(mixed $expectedResult, bool|float|int|string $value, null|float|int|string $digits = null): void { - $result = ConvertDecimal::toHex(...$args); + $result = ($digits === null) ? ConvertDecimal::toHex($value) : ConvertDecimal::toHex($value, $digits); self::assertSame($expectedResult, $result); } @@ -50,6 +50,7 @@ class Dec2HexTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DEC2HEX({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -110,11 +111,11 @@ class Dec2HexTest extends TestCase /** * @dataProvider providerDEC2HEXOds */ - public function testDEC2HEXOds(mixed $expectedResult, mixed ...$args): void + public function testDEC2HEXOds(mixed $expectedResult, bool|float|int|string $value, null|float|int|string $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertDecimal::toHex(...$args); + $result = ($digits === null) ? ConvertDecimal::toHex($value) : ConvertDecimal::toHex($value, $digits); self::assertSame($expectedResult, $result); } @@ -129,14 +130,17 @@ class Dec2HexTest extends TestCase $formula = '=DEC2HEX(17.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('11', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('11', $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('11', $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php index 42252f5c7..320710701 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Dec2OctTest.php @@ -29,9 +29,9 @@ class Dec2OctTest extends TestCase /** * @dataProvider providerDEC2OCT */ - public function testDirectCallToDEC2OCT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToDEC2OCT(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { - $result = ConvertDecimal::toOctal(...$args); + $result = ($digits === null) ? ConvertDecimal::toOctal($value) : ConvertDecimal::toOctal($value, $digits); self::assertSame($expectedResult, $result); } @@ -50,6 +50,7 @@ class Dec2OctTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=DEC2OCT({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -110,11 +111,11 @@ class Dec2OctTest extends TestCase /** * @dataProvider providerDEC2OCTOds */ - public function testDEC2OCTOds(mixed $expectedResult, mixed ...$args): void + public function testDEC2OCTOds(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertDecimal::toOctal(...$args); + $result = ($digits === null) ? ConvertDecimal::toOctal($value) : ConvertDecimal::toOctal($value, $digits); self::assertSame($expectedResult, $result); } @@ -129,14 +130,17 @@ class Dec2OctTest extends TestCase $formula = '=DEC2OCT(17.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('21', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('21', $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('21', $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php index 72c9ce4f6..6dbd164ec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/DeltaTest.php @@ -16,9 +16,9 @@ class DeltaTest extends TestCase /** * @dataProvider providerDELTA */ - public function testDirectCallToDELTA(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToDELTA(mixed $expectedResult, bool|float|int|string $arg1, null|bool|float|int|string $arg2 = null): void { - $result = Compare::delta(...$args); + $result = ($arg2 === null) ? Compare::delta($arg1) : Compare::delta($arg1, $arg2); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php index dbf6c9c17..34b42ceae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/GeStepTest.php @@ -16,9 +16,9 @@ class GeStepTest extends TestCase /** * @dataProvider providerGESTEP */ - public function testDirectCallToGESTEP(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToGESTEP(int|string $expectedResult, bool|float|int|string $arg1, null|bool|float|int|string $arg2 = null): void { - $result = Compare::geStep(...$args); + $result = ($arg2 === null) ? Compare::geStep($arg1) : Compare::geStep($arg1, $arg2); self::assertSame($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php index 4a3ee2558..bcd263235 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2BinTest.php @@ -30,9 +30,9 @@ class Hex2BinTest extends TestCase /** * @dataProvider providerHEX2BIN */ - public function testDirectCallToHEX2BIN(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToHEX2BIN(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { - $result = ConvertHex::toBinary(...$args); + $result = ($digits === null) ? ConvertHex::toBinary($value) : ConvertHex::toBinary($value, $digits); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Hex2BinTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=HEX2BIN({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Hex2BinTest extends TestCase /** * @dataProvider providerHEX2BINOds */ - public function testHEX2BINOds(mixed $expectedResult, mixed ...$args): void + public function testHEX2BINOds(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertHex::toBinary(...$args); + $result = ($digits === null) ? ConvertHex::toBinary($value) : ConvertHex::toBinary($value, $digits); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Hex2BinTest extends TestCase $formula = '=HEX2BIN(10.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('10000', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php index ba0d5f8d0..7586b43ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2DecTest.php @@ -30,9 +30,9 @@ class Hex2DecTest extends TestCase /** * @dataProvider providerHEX2DEC */ - public function testDirectCallToHEX2DEC(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToHEX2DEC(mixed $expectedResult, bool|float|int|string $value): void { - $result = ConvertHex::toDecimal(...$args); + $result = ConvertHex::toDecimal($value); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Hex2DecTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=HEX2DEC({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Hex2DecTest extends TestCase /** * @dataProvider providerHEX2DECOds */ - public function testHEX2DECOds(mixed $expectedResult, mixed ...$args): void + public function testHEX2DECOds(mixed $expectedResult, bool|float|int|string $value): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertHex::toDecimal(...$args); + $result = ConvertHex::toDecimal($value); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Hex2DecTest extends TestCase $formula = '=HEX2DEC(10.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('16', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php index 4486271dd..603d4b2dc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Hex2OctTest.php @@ -30,9 +30,9 @@ class Hex2OctTest extends TestCase /** * @dataProvider providerHEX2OCT */ - public function testDirectCallToHEX2OCT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToHEX2OCT(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { - $result = ConvertHex::toOctal(...$args); + $result = ($digits === null) ? ConvertHex::toOctal($value) : ConvertHex::toOctal($value, $digits); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Hex2OctTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=HEX2OCT({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Hex2OctTest extends TestCase /** * @dataProvider providerHEX2OCTOds */ - public function testHEX2OCTOds(mixed $expectedResult, mixed ...$args): void + public function testHEX2OCTOds(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertHex::toOctal(...$args); + $result = ($digits === null) ? ConvertHex::toOctal($value) : ConvertHex::toOctal($value, $digits); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Hex2OctTest extends TestCase $formula = '=HEX2OCT(10.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('20', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php index 8b76473a8..2325a3b13 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImAbsTest.php @@ -18,9 +18,9 @@ class ImAbsTest extends TestCase /** * @dataProvider providerIMABS */ - public function testDirectCallToIMABS(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMABS(float|int|string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMABS(...$args); + $result = ComplexFunctions::IMABS($arg); self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php index 885a79280..6b15ddaf9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImArgumentTest.php @@ -24,9 +24,9 @@ class ImArgumentTest extends TestCase /** * @dataProvider providerIMARGUMENT */ - public function testDirectCallToIMARGUMENT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMARGUMENT(float|int|string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMARGUMENT(...$args); + $result = ComplexFunctions::IMARGUMENT($arg); self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php index f09e97ca7..86b5d8163 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImConjugateTest.php @@ -28,9 +28,9 @@ class ImConjugateTest extends TestCase /** * @dataProvider providerIMCONJUGATE */ - public function testDirectCallToIMCONJUGATE(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMCONJUGATE(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMCONJUGATE(...$args); + $result = ComplexFunctions::IMCONJUGATE($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImConjugateTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMCONJUGATE({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php index 6c7858636..e50487f54 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCosTest.php @@ -28,9 +28,9 @@ class ImCosTest extends TestCase /** * @dataProvider providerIMCOS */ - public function testDirectCallToIMCOS(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMCOS(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMCOS(...$args); + $result = ComplexFunctions::IMCOS($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImCosTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMCOS({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php index cb4afbb53..e1e4f144e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCoshTest.php @@ -28,9 +28,9 @@ class ImCoshTest extends TestCase /** * @dataProvider providerIMCOSH */ - public function testDirectCallToIMCOSH(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMCOSH(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMCOSH(...$args); + $result = ComplexFunctions::IMCOSH($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImCoshTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMCOSH({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php index 8237fa162..59832f470 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCotTest.php @@ -28,9 +28,9 @@ class ImCotTest extends TestCase /** * @dataProvider providerIMCOT */ - public function testDirectCallToIMCOT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMCOT(float|string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMCOT(...$args); + $result = ComplexFunctions::IMCOT($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImCotTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMCOT({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php index 3c9d524eb..ff6d76f9e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCscTest.php @@ -28,9 +28,9 @@ class ImCscTest extends TestCase /** * @dataProvider providerIMCSC */ - public function testDirectCallToIMCSC(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMCSC(float|string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMCSC(...$args); + $result = ComplexFunctions::IMCSC($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImCscTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMCSC({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), @@ -123,6 +124,7 @@ class ImCscTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMCSC({$complex})"; + /** @var array> */ $result = $calculation->_calculateFormulaValue($formula); // Avoid testing for excess precision foreach ($expectedResult as &$array) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php index 9d333cdfd..8bada9ce4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImCschTest.php @@ -28,9 +28,9 @@ class ImCschTest extends TestCase /** * @dataProvider providerIMCSCH */ - public function testDirectCallToIMCSCH(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMCSCH(float|string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMCSCH(...$args); + $result = ComplexFunctions::IMCSCH($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImCschTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMCSCH({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php index 6e6eee44a..9e6f1444b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImDivTest.php @@ -28,9 +28,9 @@ class ImDivTest extends TestCase /** * @dataProvider providerIMDIV */ - public function testDirectCallToIMDIV(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMDIV(string $expectedResult, string $dividend, string $divisor): void { - $result = ComplexOperations::IMDIV(...$args); + $result = ComplexOperations::IMDIV($dividend, $divisor); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImDivTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMDIV({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php index 504f0ad85..a6834310c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImExpTest.php @@ -28,9 +28,9 @@ class ImExpTest extends TestCase /** * @dataProvider providerIMEXP */ - public function testDirectCallToIMEXP(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMEXP(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMEXP(...$args); + $result = ComplexFunctions::IMEXP($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImExpTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMEXP({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php index aa2b78bee..f7a762453 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLnTest.php @@ -28,9 +28,9 @@ class ImLnTest extends TestCase /** * @dataProvider providerIMLN */ - public function testDirectCallToIMLN(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMLN(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMLN(...$args); + $result = ComplexFunctions::IMLN($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImLnTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMLN({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php index 12a9abf9b..848e7f86d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog10Test.php @@ -28,9 +28,9 @@ class ImLog10Test extends TestCase /** * @dataProvider providerIMLOG10 */ - public function testDirectCallToIMLOG10(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMLOG10(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMLOG10(...$args); + $result = ComplexFunctions::IMLOG10($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImLog10Test extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMLOG10({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php index d6f79885c..ba9bd7652 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImLog2Test.php @@ -28,9 +28,9 @@ class ImLog2Test extends TestCase /** * @dataProvider providerIMLOG2 */ - public function testDirectCallToIMLOG2(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMLOG2(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMLOG2(...$args); + $result = ComplexFunctions::IMLOG2($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImLog2Test extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMLOG2({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php index 276c6a95b..62d462b4d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImPowerTest.php @@ -28,9 +28,9 @@ class ImPowerTest extends TestCase /** * @dataProvider providerIMPOWER */ - public function testDirectCallToIMPOWER(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMPOWER(float|int|string $expectedResult, string $arg1, float|int|string $arg2): void { - $result = ComplexFunctions::IMPOWER(...$args); + $result = ComplexFunctions::IMPOWER($arg1, $arg2); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImPowerTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMPOWER({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php index bf71c4556..15112f909 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImProductTest.php @@ -27,8 +27,10 @@ class ImProductTest extends TestCase /** * @dataProvider providerIMPRODUCT + * + * @param string ...$args variadic arguments */ - public function testDirectCallToIMPRODUCT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMPRODUCT(mixed $expectedResult, ...$args): void { $result = ComplexOperations::IMPRODUCT(...$args); self::assertTrue( @@ -52,6 +54,7 @@ class ImProductTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMPRODUCT({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php index 8e69951a0..4cbc4a783 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImRealTest.php @@ -24,9 +24,9 @@ class ImRealTest extends TestCase /** * @dataProvider providerIMREAL */ - public function testDirectCallToIMREAL(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMREAL(float|int|string $expectedResult, float|int|string $arg): void { - $result = Complex::IMREAL(...$args); + $result = Complex::IMREAL((string) $arg); self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php index 0bdb72e78..6e2436dfa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSecTest.php @@ -28,9 +28,9 @@ class ImSecTest extends TestCase /** * @dataProvider providerIMSEC */ - public function testDirectCallToIMSEC(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMSEC(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMSEC(...$args); + $result = ComplexFunctions::IMSEC($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImSecTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMSEC({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php index ec4e55ac8..d1a4d999d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSechTest.php @@ -28,9 +28,9 @@ class ImSechTest extends TestCase /** * @dataProvider providerIMSECH */ - public function testDirectCallToIMSECH(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMSECH(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMSECH(...$args); + $result = ComplexFunctions::IMSECH($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImSechTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMSECH({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php index 702398f44..83aab29e2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinTest.php @@ -28,9 +28,9 @@ class ImSinTest extends TestCase /** * @dataProvider providerIMSIN */ - public function testDirectCallToIMSIN(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMSIN(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMSIN(...$args); + $result = ComplexFunctions::IMSIN($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImSinTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMSIN({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php index e200e38ce..ecef552c5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSinhTest.php @@ -28,9 +28,9 @@ class ImSinhTest extends TestCase /** * @dataProvider providerIMSINH */ - public function testDirectCallToIMSINH(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMSINH(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMSINH(...$args); + $result = ComplexFunctions::IMSINH($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImSinhTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMSINH({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php index 890fe480e..cffb1bba4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSqrtTest.php @@ -28,9 +28,9 @@ class ImSqrtTest extends TestCase /** * @dataProvider providerIMSQRT */ - public function testDirectCallToIMSQRT(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMSQRT(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMSQRT(...$args); + $result = ComplexFunctions::IMSQRT($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImSqrtTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMSQRT({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php index f33ec5e3a..adc35c75d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSubTest.php @@ -28,9 +28,9 @@ class ImSubTest extends TestCase /** * @dataProvider providerIMSUB */ - public function testDirectCallToIMSUB(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMSUB(string $expectedResult, string $arg1, string $arg2): void { - $result = ComplexOperations::IMSUB(...$args); + $result = ComplexOperations::IMSUB($arg1, $arg2); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImSubTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMSUB({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php index 66508b99a..b1690c8a3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImSumTest.php @@ -27,8 +27,10 @@ class ImSumTest extends TestCase /** * @dataProvider providerIMSUM + * + * @param string ...$args variadic arguments */ - public function testDirectCallToIMSUM(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMSUM(mixed $expectedResult, ...$args): void { $result = ComplexOperations::IMSUM(...$args); self::assertTrue( @@ -52,6 +54,7 @@ class ImSumTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMSUM({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php index 15cb1298f..cf553c7c5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImTanTest.php @@ -28,9 +28,9 @@ class ImTanTest extends TestCase /** * @dataProvider providerIMTAN */ - public function testDirectCallToIMTAN(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMTAN(string $expectedResult, string $arg): void { - $result = ComplexFunctions::IMTAN(...$args); + $result = ComplexFunctions::IMTAN($arg); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $result, self::COMPLEX_PRECISION), $this->complexAssert->getErrorMessage() @@ -52,6 +52,7 @@ class ImTanTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=IMTAN({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertTrue( $this->complexAssert->assertComplexEquals($expectedResult, $this->trimIfQuoted((string) $result), self::COMPLEX_PRECISION), diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php index af26adf14..f62cc1d89 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/ImaginaryTest.php @@ -24,9 +24,9 @@ class ImaginaryTest extends TestCase /** * @dataProvider providerIMAGINARY */ - public function testDirectCallToIMAGINARY(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToIMAGINARY(float|int|string $expectedResult, float|int|string $arg): void { - $result = Complex::IMAGINARY(...$args); + $result = Complex::IMAGINARY((string) $arg); self::assertEqualsWithDelta($expectedResult, $result, self::COMPLEX_PRECISION); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php index aee679ff4..9e02a442f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2BinTest.php @@ -30,9 +30,9 @@ class Oct2BinTest extends TestCase /** * @dataProvider providerOCT2BIN */ - public function testDirectCallToOCT2BIN(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToOCT2BIN(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { - $result = ConvertOctal::toBinary(...$args); + $result = ($digits === null) ? ConvertOctal::toBinary($value) : ConvertOctal::toBinary($value, $digits); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Oct2BinTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=OCT2BIN({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Oct2BinTest extends TestCase /** * @dataProvider providerOCT2BINOds */ - public function testOCT2BINOds(mixed $expectedResult, mixed ...$args): void + public function testOCT2BINOds(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertOctal::toBinary(...$args); + $result = ($digits === null) ? ConvertOctal::toBinary($value) : ConvertOctal::toBinary($value, $digits); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Oct2BinTest extends TestCase $formula = '=OCT2BIN(10.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('1000', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php index 04412a190..45a868e6a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2DecTest.php @@ -30,9 +30,9 @@ class Oct2DecTest extends TestCase /** * @dataProvider providerOCT2DEC */ - public function testDirectCallToOCT2DEC(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToOCT2DEC(mixed $expectedResult, bool|string $value): void { - $result = ConvertOctal::toDecimal(...$args); + $result = ConvertOctal::toDecimal($value); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Oct2DecTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=OCT2DEC({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Oct2DecTest extends TestCase /** * @dataProvider providerOCT2DECOds */ - public function testOCT2DECOds(mixed $expectedResult, mixed ...$args): void + public function testOCT2DECOds(mixed $expectedResult, bool|string $value): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertOctal::toDecimal(...$args); + $result = ConvertOctal::toDecimal($value); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Oct2DecTest extends TestCase $formula = '=OCT2DEC(10.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('8', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php index badafdf87..a350bd759 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/Oct2HexTest.php @@ -30,9 +30,9 @@ class Oct2HexTest extends TestCase /** * @dataProvider providerOCT2HEX */ - public function testDirectCallToOCT2HEX(mixed $expectedResult, mixed ...$args): void + public function testDirectCallToOCT2HEX(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { - $result = ConvertOctal::toHex(...$args); + $result = ($digits === null) ? ConvertOctal::toHex($value) : ConvertOctal::toHex($value, $digits); self::assertSame($expectedResult, $result); } @@ -51,6 +51,7 @@ class Oct2HexTest extends TestCase $calculation = Calculation::getInstance(); $formula = "=OCT2HEX({$arguments})"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame($expectedResult, $this->trimIfQuoted((string) $result)); } @@ -111,11 +112,11 @@ class Oct2HexTest extends TestCase /** * @dataProvider providerOCT2HEXOds */ - public function testOCT2HEXOds(mixed $expectedResult, mixed ...$args): void + public function testOCT2HEXOds(mixed $expectedResult, bool|float|int|string $value, ?int $digits = null): void { Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); - $result = ConvertOctal::toHex(...$args); + $result = ($digits === null) ? ConvertOctal::toHex($value) : ConvertOctal::toHex($value, $digits); self::assertSame($expectedResult, $result); } @@ -130,14 +131,17 @@ class Oct2HexTest extends TestCase $formula = '=OCT2HEX(20.1)'; Functions::setCompatibilityMode(Functions::COMPATIBILITY_GNUMERIC); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame('10', $this->trimIfQuoted((string) $result), 'Gnumeric'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'OpenOffice'); Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL); + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertSame(ExcelError::NAN(), $this->trimIfQuoted((string) $result), 'Excel'); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/HelpersTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/HelpersTest.php index 6cceaf423..1d5087034 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/HelpersTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/HelpersTest.php @@ -12,7 +12,7 @@ class HelpersTest extends TestCase /** * @dataProvider providerDaysPerYear */ - public function testDaysPerYear(mixed $expectedResult, mixed $year, mixed $basis): void + public function testDaysPerYear(mixed $expectedResult, int $year, int|string $basis): void { $result = Helpers::daysPerYear($year, $basis); self::assertSame($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/FormulaArguments.php b/tests/PhpSpreadsheetTests/Calculation/Functions/FormulaArguments.php index 16c5d81bc..0454c0f14 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/FormulaArguments.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/FormulaArguments.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions; +use Exception; use PhpOffice\PhpSpreadsheet\Cell\CellAddress; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use Stringable; @@ -81,7 +82,11 @@ class FormulaArguments implements Stringable return $value ? 'TRUE' : 'FALSE'; } - return (string) $value; + if (is_scalar($value) || $value instanceof Stringable) { + return (string) $value; + } + + throw new Exception('Cannot convert object to string'); } public function __toString(): string diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php index c9dacefd2..277318cf2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php @@ -22,7 +22,7 @@ class AndTest extends AllSetupTeardown /** * @dataProvider providerANDLiteral */ - public function testANDLiteral(mixed $expectedResult, mixed $formula): void + public function testANDLiteral(bool|string $expectedResult, float|int|string $formula): void { $sheet = $this->getSheet(); $sheet->getCell('A1')->setValue("=AND($formula)"); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php index 6f369f573..c54448e03 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php @@ -22,7 +22,7 @@ class OrTest extends AllSetupTeardown /** * @dataProvider providerORLiteral */ - public function testORLiteral(mixed $expectedResult, mixed $formula): void + public function testORLiteral(bool|string $expectedResult, float|int|string $formula): void { $sheet = $this->getSheet(); $sheet->getCell('A1')->setValue("=OR($formula)"); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php index 1ef186060..c07daa8b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -24,7 +24,7 @@ class SwitchTest extends AllSetupTeardown /** * @dataProvider providerSwitchArray */ - public function testIfsArray(array $expectedResult, mixed $expression, mixed $value1, string $result1, mixed $value2, string $result2, string $default): void + public function testIfsArray(array $expectedResult, int $expression, int $value1, string $result1, int $value2, string $result2, string $default): void { $calculation = Calculation::getInstance(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectInternationalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectInternationalTest.php index 1cfcfc603..e0624ed8d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectInternationalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectInternationalTest.php @@ -53,6 +53,7 @@ class IndirectInternationalTest extends AllSetupTeardown $sheet->getCell('B10')->setValue('=INDIRECT("R1C3", false)'); $maxRow = $sheet->getHighestRow(); for ($row = 2; $row <= $maxRow; ++$row) { + /** @var null|bool|float|int|string */ $rowLocale = $sheet->getCell("A$row")->getValue(); if (in_array($rowLocale, $sameAsEnglish, true) && in_array($locale, $sameAsEnglish, true)) { $expectedResult = 'text'; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php index 6a1c809f1..211680f7d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatchTest.php @@ -11,7 +11,7 @@ class MatchTest extends AllSetupTeardown /** * @dataProvider providerMATCH */ - public function testMATCH(mixed $expectedResult, mixed $input, array $array, mixed $type = null): void + public function testMATCH(mixed $expectedResult, mixed $input, array $array, null|float|int|string $type = null): void { if (is_array($expectedResult)) { $expectedResult = $expectedResult[0]; @@ -42,7 +42,7 @@ class MatchTest extends AllSetupTeardown /** * @dataProvider providerMATCH */ - public function testMATCHLibre(mixed $expectedResult, mixed $input, array $array, mixed $type = null): void + public function testMATCHLibre(mixed $expectedResult, mixed $input, array $array, null|float|int|string $type = null): void { $this->setOpenOffice(); if (is_array($expectedResult)) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php index eabdd5115..8e508aa15 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -11,7 +11,7 @@ class AcotTest extends AllSetupTeardown /** * @dataProvider providerACOT */ - public function testACOT(mixed $expectedResult, mixed $number): void + public function testACOT(float|int|string $expectedResult, float|int|string $number): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php index 3935a32e9..85ccdf44a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -11,7 +11,7 @@ class AcothTest extends AllSetupTeardown /** * @dataProvider providerACOTH */ - public function testACOTH(mixed $expectedResult, mixed $number): void + public function testACOTH(float|int|string $expectedResult, float|int|string $number): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php index d7c71af59..d47520334 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -11,7 +11,7 @@ class CotTest extends AllSetupTeardown /** * @dataProvider providerCOT */ - public function testCOT(mixed $expectedResult, mixed $angle): void + public function testCOT(float|int|string $expectedResult, float|int|string $angle): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php index 1527ef764..d41b09370 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -11,7 +11,7 @@ class CothTest extends AllSetupTeardown /** * @dataProvider providerCOTH */ - public function testCOTH(mixed $expectedResult, mixed $angle): void + public function testCOTH(float|int|string $expectedResult, float|int|string $angle): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php index 2b64c71a8..5cf58296e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -11,7 +11,7 @@ class CscTest extends AllSetupTeardown /** * @dataProvider providerCSC */ - public function testCSC(mixed $expectedResult, mixed $angle): void + public function testCSC(float|int|string $expectedResult, float|int|string $angle): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php index 9f2bf9050..5865c4c82 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -11,7 +11,7 @@ class CschTest extends AllSetupTeardown /** * @dataProvider providerCSCH */ - public function testCSCH(mixed $expectedResult, mixed $angle): void + public function testCSCH(float|int|string $expectedResult, float|int|string $angle): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php index 88166169e..4f56e921a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -11,7 +11,7 @@ class EvenTest extends AllSetupTeardown /** * @dataProvider providerEVEN */ - public function testEVEN(mixed $expectedResult, mixed $value): void + public function testEVEN(int|string $expectedResult, float|int|string $value): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php index 520f6d50e..eab6e20ae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MRoundTest.php @@ -11,7 +11,7 @@ class MRoundTest extends AllSetupTeardown /** * @dataProvider providerMROUND */ - public function testMROUND(mixed $expectedResult, mixed $formula): void + public function testMROUND(float|int|string $expectedResult, string $formula): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php index 8928f32c7..cd9b090a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MdeTermTest.php @@ -9,7 +9,7 @@ class MdeTermTest extends AllSetupTeardown /** * @dataProvider providerMDETERM */ - public function testMDETERM2(mixed $expectedResult, mixed $matrix): void + public function testMDETERM2(float|int|string $expectedResult, array|int|float|string $matrix): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php index de4522368..d73235a7c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -11,7 +11,7 @@ class OddTest extends AllSetupTeardown /** * @dataProvider providerODD */ - public function testODD(mixed $expectedResult, mixed $value): void + public function testODD(int|string $expectedResult, float|int|string $value): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php index bd0f8a701..6086685f9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandBetweenTest.php @@ -11,7 +11,7 @@ class RandBetweenTest extends AllSetupTeardown /** * @dataProvider providerRANDBETWEEN */ - public function testRANDBETWEEN(mixed $expectedResult, mixed $min = 'omitted', mixed $max = 'omitted'): void + public function testRANDBETWEEN(int|string $expectedResult, null|bool|int|string $min = 'omitted', null|bool|int|string $max = 'omitted'): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php index 1e536a11a..de8be1b07 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RomanTest.php @@ -11,7 +11,7 @@ class RomanTest extends AllSetupTeardown /** * @dataProvider providerROMAN */ - public function testROMAN(mixed $expectedResult, mixed $formula): void + public function testROMAN(string $expectedResult, string $formula): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php index b65da3627..2f5945d3f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -11,7 +11,7 @@ class RoundDownTest extends AllSetupTeardown /** * @dataProvider providerRoundDown */ - public function testRoundDown(mixed $expectedResult, mixed $formula): void + public function testRoundDown(float|int|string $expectedResult, float|int|string $formula): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php index b9d776242..91dcc8610 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php @@ -11,7 +11,7 @@ class RoundTest extends AllSetupTeardown /** * @dataProvider providerRound */ - public function testRound(mixed $expectedResult, mixed $formula): void + public function testRound(float|int|string $expectedResult, float|int|string $formula): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php index 5ad00d36e..79a32ed68 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -11,7 +11,7 @@ class RoundUpTest extends AllSetupTeardown /** * @dataProvider providerRoundUp */ - public function testRoundUp(mixed $expectedResult, mixed $formula): void + public function testRoundUp(float|int|string $expectedResult, float|int|string $formula): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php index 4485b566f..3c391b687 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -11,7 +11,7 @@ class SecTest extends AllSetupTeardown /** * @dataProvider providerSEC */ - public function testSEC(mixed $expectedResult, mixed $angle): void + public function testSEC(float|int|string $expectedResult, float|int|string $angle): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php index 7605f95fc..632685070 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -11,7 +11,7 @@ class SechTest extends AllSetupTeardown /** * @dataProvider providerSECH */ - public function testSECH(mixed $expectedResult, mixed $angle): void + public function testSECH(float|int|string $expectedResult, float|int|string $angle): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php index 436d0fe02..a767de73d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -11,7 +11,7 @@ class SignTest extends AllSetupTeardown /** * @dataProvider providerSIGN */ - public function testSIGN(mixed $expectedResult, mixed $value): void + public function testSIGN(float|int|string $expectedResult, float|int|string $value): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php index b93b7f260..cc694aa49 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php @@ -9,7 +9,7 @@ class SubTotalTest extends AllSetupTeardown /** * @dataProvider providerSUBTOTAL */ - public function testSubtotal(mixed $expectedResult, mixed $type): void + public function testSubtotal(float|int|string $expectedResult, float|int|string $type): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -29,7 +29,7 @@ class SubTotalTest extends AllSetupTeardown /** * @dataProvider providerSUBTOTAL */ - public function testSubtotalColumnHidden(mixed $expectedResult, mixed $type): void + public function testSubtotalColumnHidden(float|int|string $expectedResult, float|int|string $type): void { // Hidden columns don't affect calculation, only hidden rows $this->mightHaveException($expectedResult); @@ -63,7 +63,7 @@ class SubTotalTest extends AllSetupTeardown /** * @dataProvider providerSUBTOTALHIDDEN */ - public function testSubtotalRowHidden(mixed $expectedResult, mixed $type): void + public function testSubtotalRowHidden(mixed $expectedResult, int $type): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php index 5b728fefa..f1a660e47 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php @@ -10,6 +10,7 @@ use PhpOffice\PhpSpreadsheet\Cell\DataType; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; use PHPUnit\Framework\TestCase; +use Stringable; class AllSetupTeardown extends TestCase { @@ -162,7 +163,9 @@ class AllSetupTeardown extends TestCase } else { $formula .= $comma; $comma = ','; - $formula .= $this->convertToString($arg); + /** @var string */ + $argx = $arg; + $formula .= $this->convertToString($argx); } } $formula .= ')'; @@ -210,7 +213,7 @@ class AllSetupTeardown extends TestCase self::assertEqualsWithDelta($expectedResult, $sheet->getCell('Z99')->getCalculatedValue(), 1.0e-8, 'arguments supplied as ranges'); } - private function convertToString(mixed $arg): string + private function convertToString(null|bool|float|int|string|Stringable $arg): string { if (is_string($arg)) { return '"' . $arg . '"'; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php index a9319cee6..ba9e26438 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php @@ -29,6 +29,7 @@ class ChiDistLeftTailTest extends AllSetupTeardown $calculation = Calculation::getInstance(); $formula = "=CHISQ.DIST({$values}, {$degrees}, false)"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-14); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php index d12f3b3f4..483575756 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php @@ -28,6 +28,7 @@ class ChiInvLeftTailTest extends AllSetupTeardown $degrees = 7; $calculation = Calculation::getInstance(); $formula = "=CHISQ.INV($probability, $degrees)"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8); $formula = "=CHISQ.DIST($result, $degrees)"; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php index 82da0a6d6..971ea5515 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php @@ -28,6 +28,7 @@ class ChiInvRightTailTest extends AllSetupTeardown $degrees = 7; $calculation = Calculation::getInstance(); $formula = "=CHISQ.INV.RT($probability, $degrees)"; + /** @var float|int|string */ $result = $calculation->_calculateFormulaValue($formula); self::assertEqualsWithDelta($expectedResult, $result, 1.0e-8); $formula = "=CHISQ.DIST.RT($result, $degrees)"; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php index 1c86b7128..d8a3fd8be 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php @@ -13,7 +13,7 @@ class LinEstTest extends TestCase /** * @dataProvider providerLINEST */ - public function testLINEST(array $expectedResult, mixed $yValues, mixed $xValues, mixed $const, mixed $stats): void + public function testLINEST(array $expectedResult, array $yValues, array $xValues, mixed $const, mixed $stats): void { $result = Statistical\Trends::LINEST($yValues, $xValues, $const, $stats); self::assertIsArray($result); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php index 9c1314eb7..93524d2d0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogEstTest.php @@ -13,7 +13,7 @@ class LogEstTest extends TestCase /** * @dataProvider providerLOGEST */ - public function testLOGEST(array $expectedResult, mixed $yValues, mixed $xValues, mixed $const, mixed $stats): void + public function testLOGEST(array $expectedResult, array $yValues, array $xValues, mixed $const, mixed $stats): void { $result = Statistical\Trends::LOGEST($yValues, $xValues, $const, $stats); self::assertIsArray($result); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php index 4be89c238..94ac23fd4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -42,7 +42,7 @@ class LeftTest extends AllSetupTeardown /** * @dataProvider providerLocaleLEFT */ - public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value, mixed $characters): void + public function testLowerWithLocaleBoolean(string $expectedResult, string $locale, mixed $value, mixed $characters): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php index 7549a3a4a..279332c6f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -34,7 +34,7 @@ class LowerTest extends AllSetupTeardown /** * @dataProvider providerLocaleLOWER */ - public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value): void + public function testLowerWithLocaleBoolean(string $expectedResult, string $locale, mixed $value): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php index 4a103f2bf..364fb1686 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -48,7 +48,7 @@ class MidTest extends AllSetupTeardown /** * @dataProvider providerLocaleMID */ - public function testMiddleWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value, mixed $offset, mixed $characters): void + public function testMiddleWithLocaleBoolean(string $expectedResult, string $locale, mixed $value, mixed $offset, mixed $characters): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php index a3aee9143..6df021fe6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -34,7 +34,7 @@ class ProperTest extends AllSetupTeardown /** * @dataProvider providerLocaleLOWER */ - public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value): void + public function testLowerWithLocaleBoolean(string $expectedResult, string $locale, mixed $value): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php index d2bc68362..1ecc051fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -42,7 +42,7 @@ class RightTest extends AllSetupTeardown /** * @dataProvider providerLocaleRIGHT */ - public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value, mixed $characters): void + public function testLowerWithLocaleBoolean(string $expectedResult, string $locale, mixed $value, mixed $characters): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php index 964a2accb..7522373da 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -34,7 +34,7 @@ class UpperTest extends AllSetupTeardown /** * @dataProvider providerLocaleLOWER */ - public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value): void + public function testLowerWithLocaleBoolean(string $expectedResult, string $locale, mixed $value): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueToTextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueToTextTest.php index 9aa277e44..37c33701e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueToTextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueToTextTest.php @@ -12,7 +12,7 @@ class ValueToTextTest extends AllSetupTeardown /** * @dataProvider providerVALUE */ - public function testVALUETOTEXT(mixed $expectedResult, mixed $value, mixed $format): void + public function testVALUETOTEXT(mixed $expectedResult, mixed $value, int|string $format): void { $sheet = $this->getSheet(); $this->setCell('A1', $value); diff --git a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php index 3ab89878b..7183b4fa7 100644 --- a/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php +++ b/tests/PhpSpreadsheetTests/Cell/AdvancedValueBinderTest.php @@ -86,7 +86,7 @@ class AdvancedValueBinderTest extends TestCase /** * @dataProvider currencyProvider */ - public function testCurrency(mixed $value, mixed $valueBinded, mixed $thousandsSeparator, mixed $decimalSeparator, mixed $currencyCode): void + public function testCurrency(string $value, float $valueBinded, string $thousandsSeparator, string $decimalSeparator, string $currencyCode): void { StringHelper::setCurrencyCode($currencyCode); StringHelper::setDecimalSeparator($decimalSeparator); diff --git a/tests/PhpSpreadsheetTests/Cell/CellAddressTest.php b/tests/PhpSpreadsheetTests/Cell/CellAddressTest.php index 2cddc48a0..28caf171b 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellAddressTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellAddressTest.php @@ -41,7 +41,7 @@ class CellAddressTest extends TestCase /** * @dataProvider providerCreateFromCellAddressException */ - public function testCreateFromCellAddressException(mixed $cellAddress): void + public function testCreateFromCellAddressException(int|string $cellAddress): void { $this->expectException(Exception::class); $this->expectExceptionMessage( diff --git a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php index e1a527496..d15592830 100644 --- a/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CoordinateTest.php @@ -14,7 +14,7 @@ class CoordinateTest extends TestCase /** * @dataProvider providerColumnString */ - public function testColumnIndexFromString(mixed $expectedResult, mixed $string): void + public function testColumnIndexFromString(mixed $expectedResult, string $string): void { $columnIndex = Coordinate::columnIndexFromString($string); self::assertEquals($expectedResult, $columnIndex); @@ -180,9 +180,9 @@ class CoordinateTest extends TestCase /** * @dataProvider providerAbsoluteReferences */ - public function testAbsoluteReferenceFromString(mixed $expectedResult, mixed $rangeSet): void + public function testAbsoluteReferenceFromString(mixed $expectedResult, int|string $rangeSet): void { - $result = Coordinate::absoluteReference($rangeSet); + $result = Coordinate::absoluteReference((string) $rangeSet); self::assertEquals($expectedResult, $result); } @@ -209,7 +209,7 @@ class CoordinateTest extends TestCase /** * @dataProvider providerSplitRange */ - public function testSplitRange(mixed $expectedResult, string $rangeSet): void + public function testSplitRange(array $expectedResult, string $rangeSet): void { $result = Coordinate::splitRange($rangeSet); foreach ($result as $key => $split) { @@ -229,7 +229,7 @@ class CoordinateTest extends TestCase /** * @dataProvider providerBuildRange */ - public function testBuildRange(mixed $expectedResult, mixed $rangeSets): void + public function testBuildRange(mixed $expectedResult, array $rangeSets): void { $result = Coordinate::buildRange($rangeSets); self::assertEquals($expectedResult, $result); @@ -368,7 +368,7 @@ class CoordinateTest extends TestCase /** * @dataProvider providerMergeRangesInCollection */ - public function testMergeRangesInCollection(mixed $expectedResult, mixed $rangeSets): void + public function testMergeRangesInCollection(mixed $expectedResult, array $rangeSets): void { $result = Coordinate::mergeRangesInCollection($rangeSets); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php b/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php index 7efef0302..45b734958 100644 --- a/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php +++ b/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php @@ -53,7 +53,7 @@ class ComplexAssert extends TestCase public function assertComplexEquals(mixed $expected, mixed $actual, ?float $delta = null): bool { if ($expected === INF || (is_string($expected) && $expected[0] === '#')) { - return $this->testExpectedExceptions($expected, $actual); + return $this->testExpectedExceptions($expected, (is_string($actual) || is_float($actual)) ? $actual : 'neither string nor float'); } if ($delta === null) { @@ -90,7 +90,7 @@ class ComplexAssert extends TestCase return $this->errorMessage; } - public function runAssertComplexEquals(mixed $expected, mixed $actual, ?float $delta = null): void + public function runAssertComplexEquals(string $expected, array|float|string $actual, ?float $delta = null): void { self::assertTrue($this->assertComplexEquals($expected, $actual, $delta), $this->getErrorMessage()); } diff --git a/tests/PhpSpreadsheetTests/Document/PropertiesTest.php b/tests/PhpSpreadsheetTests/Document/PropertiesTest.php index 0ada72200..b81edc824 100644 --- a/tests/PhpSpreadsheetTests/Document/PropertiesTest.php +++ b/tests/PhpSpreadsheetTests/Document/PropertiesTest.php @@ -47,7 +47,7 @@ class PropertiesTest extends TestCase /** * @dataProvider providerCreationTime */ - public function testSetCreated(mixed $expectedCreationTime, mixed $created): void + public function testSetCreated(null|int $expectedCreationTime, null|int|string $created): void { $expectedCreationTime = $expectedCreationTime ?? $this->startTime; @@ -76,7 +76,7 @@ class PropertiesTest extends TestCase /** * @dataProvider providerModifiedTime */ - public function testSetModified(mixed $expectedModifiedTime, mixed $modified): void + public function testSetModified(mixed $expectedModifiedTime, null|int|string $modified): void { $expectedModifiedTime = $expectedModifiedTime ?? $this->startTime; @@ -162,6 +162,7 @@ class PropertiesTest extends TestCase } self::assertTrue($this->properties->isCustomPropertySet($propertyName)); self::assertSame($expectedType, $this->properties->getCustomPropertyType($propertyName)); + /** @var float|int|string */ $result = $this->properties->getCustomPropertyValue($propertyName); if ($expectedType === Properties::PROPERTY_TYPE_DATE) { $result = Date::formattedDateTimeFromTimestamp("$result", 'Y-m-d', new DateTimeZone('UTC')); diff --git a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php index 64f3b0549..7b352dde2 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php @@ -36,7 +36,7 @@ class ReadFilterTest extends AbstractFunctional * * @dataProvider providerCellsValues */ - public function testXlsxLoadWithoutReadFilter(mixed $format, array $arrayData): void + public function testXlsxLoadWithoutReadFilter(string $format, array $arrayData): void { $spreadsheet = new Spreadsheet(); @@ -61,7 +61,7 @@ class ReadFilterTest extends AbstractFunctional * * @dataProvider providerCellsValues */ - public function testXlsxLoadWithReadFilter(mixed $format, array $arrayData): void + public function testXlsxLoadWithReadFilter(string $format, array $arrayData): void { $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet()->fromArray($arrayData, null, 'A1'); diff --git a/tests/PhpSpreadsheetTests/Helper/HtmlTest.php b/tests/PhpSpreadsheetTests/Helper/HtmlTest.php index 9ab898c0a..784eb4c55 100644 --- a/tests/PhpSpreadsheetTests/Helper/HtmlTest.php +++ b/tests/PhpSpreadsheetTests/Helper/HtmlTest.php @@ -13,7 +13,7 @@ class HtmlTest extends TestCase /** * @dataProvider providerUtf8EncodingSupport */ - public function testUtf8EncodingSupport(mixed $expected, mixed $input): void + public function testUtf8EncodingSupport(string $expected, string $input): void { $html = new Html(); $actual = $html->toRichTextObject($input); diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/OdsPropertiesTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/OdsPropertiesTest.php index b9722ec13..89c8d8d84 100644 --- a/tests/PhpSpreadsheetTests/Reader/Ods/OdsPropertiesTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Ods/OdsPropertiesTest.php @@ -58,6 +58,7 @@ class OdsPropertiesTest extends AbstractFunctional foreach ($customPropertySet as $propertyName => $testData) { self::assertTrue($properties->isCustomPropertySet($propertyName)); self::assertSame($testData['type'], $properties->getCustomPropertyType($propertyName)); + /** @var float|int|string */ $result = $properties->getCustomPropertyValue($propertyName); if ($properties->getCustomPropertyType($propertyName) == Properties::PROPERTY_TYPE_DATE) { $result = Date::formattedDateTimeFromTimestamp("$result", 'Y-m-d'); @@ -103,6 +104,7 @@ class OdsPropertiesTest extends AbstractFunctional foreach ($customPropertySet as $propertyName => $testData) { self::assertTrue($properties->isCustomPropertySet($propertyName)); self::assertSame($testData['type'], $properties->getCustomPropertyType($propertyName)); + /** @var float|int|string */ $result = $properties->getCustomPropertyValue($propertyName); if ($properties->getCustomPropertyType($propertyName) == Properties::PROPERTY_TYPE_DATE) { $result = Date::formattedDateTimeFromTimestamp("$result", 'Y-m-d'); diff --git a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php index 7f78d8422..982c557ec 100644 --- a/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php @@ -16,7 +16,7 @@ class XmlScannerTest extends TestCase /** * @dataProvider providerValidXML */ - public function testValidXML(mixed $filename, mixed $expectedResult): void + public function testValidXML(string $filename, string $expectedResult): void { $reader = XmlScanner::getInstance(new \PhpOffice\PhpSpreadsheet\Reader\Xml()); $result = $reader->scanFile($filename); @@ -40,7 +40,7 @@ class XmlScannerTest extends TestCase /** * @dataProvider providerInvalidXML */ - public function testInvalidXML(mixed $filename): void + public function testInvalidXML(string $filename): void { $this->expectException(ReaderException::class); @@ -93,7 +93,7 @@ class XmlScannerTest extends TestCase /** * @dataProvider providerValidXMLForCallback */ - public function testSecurityScanWithCallback(mixed $filename, mixed $expectedResult): void + public function testSecurityScanWithCallback(string $filename, string $expectedResult): void { $fileReader = new Xlsx(); $scanner = $fileReader->getSecurityScannerOrThrow(); diff --git a/tests/PhpSpreadsheetTests/Reader/Xls/RichTextSizeTest.php b/tests/PhpSpreadsheetTests/Reader/Xls/RichTextSizeTest.php index 39f2edd79..bcd803242 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xls/RichTextSizeTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xls/RichTextSizeTest.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Reader\Xls; use PhpOffice\PhpSpreadsheet\Reader\Xls; +use PhpOffice\PhpSpreadsheet\RichText\RichText; use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional; class RichTextSizeTest extends AbstractFunctional @@ -16,8 +17,9 @@ class RichTextSizeTest extends AbstractFunctional $spreadsheet = $reader->load($filename); $sheet = $spreadsheet->getSheetByNameOrThrow('橱柜门板'); $text = $sheet->getCell('L15')->getValue(); + self::assertInstanceOf(RichText::class, $text); $elements = $text->getRichTextElements(); - self::assertEquals(10, $elements[2]->getFont()->getSize()); + self::assertEquals(10, $elements[2]->getFont()?->getSize()); $spreadsheet->disconnectWorksheets(); } } diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/PropertiesTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/PropertiesTest.php index 9773a89fd..803477a8f 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/PropertiesTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/PropertiesTest.php @@ -45,6 +45,7 @@ class PropertiesTest extends AbstractFunctional foreach ($customPropertySet as $propertyName => $testData) { self::assertTrue($properties->isCustomPropertySet($propertyName)); self::assertSame($testData['type'], $properties->getCustomPropertyType($propertyName)); + /** @var float|int */ $result = $properties->getCustomPropertyValue($propertyName); if ($properties->getCustomPropertyType($propertyName) == Properties::PROPERTY_TYPE_DATE) { $result = Date::formattedDateTimeFromTimestamp("$result", 'Y-m-d', new DateTimeZone('UTC')); @@ -87,6 +88,7 @@ class PropertiesTest extends AbstractFunctional foreach ($customPropertySet as $propertyName => $testData) { self::assertTrue($properties->isCustomPropertySet($propertyName)); self::assertSame($testData['type'], $properties->getCustomPropertyType($propertyName)); + /** @var float|int */ $result = $properties->getCustomPropertyValue($propertyName); if ($properties->getCustomPropertyType($propertyName) == Properties::PROPERTY_TYPE_DATE) { $result = Date::formattedDateTimeFromTimestamp("$result", 'Y-m-d', new DateTimeZone('UTC')); diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxRootZipFilesTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxRootZipFilesTest.php index f83e7989d..dafe87149 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxRootZipFilesTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxRootZipFilesTest.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx; use PhpOffice\PhpSpreadsheet\Reader\Xlsx; +use PhpOffice\PhpSpreadsheet\RichText\RichText; use PHPUnit\Framework\TestCase; class XlsxRootZipFilesTest extends TestCase @@ -17,6 +18,7 @@ class XlsxRootZipFilesTest extends TestCase $reader = new Xlsx(); $spreadsheet = $reader->load($filename); $sheet = $spreadsheet->getActiveSheet(); + /** @var RichText */ $value = $sheet->getCell('A1')->getValue(); self::assertSame('TEST CELL', $value->getPlainText()); } diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php index cf815e5ab..beded2509 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php @@ -66,6 +66,7 @@ class XmlLoadTest extends TestCase self::assertEquals('2010-09-03T21:48:39Z', $result); self::assertEquals('AbCd1234', $props->getCustomPropertyValue('my_API_Token')); self::assertEquals('2', $props->getCustomPropertyValue('myאInt')); + /** @var string */ $creationDate = $props->getCustomPropertyValue('my_API_Token_Expiry'); $result = Date::formattedDateTimeFromTimestamp("$creationDate", 'Y-m-d\\TH:i:s\\Z', new DateTimeZone('UTC')); self::assertEquals('2019-01-31T07:00:00Z', $result); diff --git a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php index ab3825eea..e7c021835 100644 --- a/tests/PhpSpreadsheetTests/Shared/CodePageTest.php +++ b/tests/PhpSpreadsheetTests/Shared/CodePageTest.php @@ -12,8 +12,10 @@ class CodePageTest extends TestCase { /** * @dataProvider providerCodePage + * + * @param string|string[] $expectedResult */ - public function testCodePageNumberToName(mixed $expectedResult, mixed $codePageIndex): void + public function testCodePageNumberToName(array|string $expectedResult, int $codePageIndex): void { if ($expectedResult === 'exception') { $this->expectException(Exception::class); diff --git a/tests/PhpSpreadsheetTests/Shared/DateTest.php b/tests/PhpSpreadsheetTests/Shared/DateTest.php index 7839cfc45..f4f125688 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace PhpOffice\PhpSpreadsheetTests\Shared; +use DateTimeInterface; use DateTimeZone; use PhpOffice\PhpSpreadsheet\Exception; use PhpOffice\PhpSpreadsheet\Shared\Date; @@ -51,9 +52,9 @@ class DateTest extends TestCase /** * @dataProvider providerDateTimeExcelToTimestamp1900 */ - public function testDateTimeExcelToTimestamp1900(mixed $expectedResult, mixed $excelDateTimeValue): void + public function testDateTimeExcelToTimestamp1900(float|int $expectedResult, float|int $excelDateTimeValue): void { - if (is_numeric($expectedResult) && ($expectedResult > PHP_INT_MAX || $expectedResult < PHP_INT_MIN)) { + if ($expectedResult > PHP_INT_MAX || $expectedResult < PHP_INT_MIN) { self::markTestSkipped('Test invalid on 32-bit system.'); } Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -70,7 +71,7 @@ class DateTest extends TestCase /** * @dataProvider providerDateTimeTimestampToExcel1900 */ - public function testDateTimeTimestampToExcel1900(mixed $expectedResult, mixed $unixTimestamp): void + public function testDateTimeTimestampToExcel1900(float|int $expectedResult, float|int|string $unixTimestamp): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -86,7 +87,7 @@ class DateTest extends TestCase /** * @dataProvider providerDateTimeDateTimeToExcel */ - public function testDateTimeDateTimeToExcel(mixed $expectedResult, mixed $dateTimeObject): void + public function testDateTimeDateTimeToExcel(float|int $expectedResult, DateTimeInterface $dateTimeObject): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -101,12 +102,14 @@ class DateTest extends TestCase /** * @dataProvider providerDateTimeFormattedPHPToExcel1900 + * + * @param array{0: int, 1: int, 2: int, 3: int, 4: int, 5: float|int} $args Array containing year/month/day/hours/minutes/seconds */ - public function testDateTimeFormattedPHPToExcel1900(mixed $expectedResult, mixed ...$args): void + public function testDateTimeFormattedPHPToExcel1900(mixed $expectedResult, ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); - $result = Date::formattedPHPToExcel(...$args); + $result = Date::formattedPHPToExcel(...$args); // @phpstan-ignore-line self::assertEqualsWithDelta($expectedResult, $result, 1E-5); } @@ -118,9 +121,9 @@ class DateTest extends TestCase /** * @dataProvider providerDateTimeExcelToTimestamp1904 */ - public function testDateTimeExcelToTimestamp1904(mixed $expectedResult, mixed $excelDateTimeValue): void + public function testDateTimeExcelToTimestamp1904(float|int $expectedResult, float|int $excelDateTimeValue): void { - if (is_numeric($expectedResult) && ($expectedResult > PHP_INT_MAX || $expectedResult < PHP_INT_MIN)) { + if ($expectedResult > PHP_INT_MAX || $expectedResult < PHP_INT_MIN) { self::markTestSkipped('Test invalid on 32-bit system.'); } Date::setExcelCalendar(Date::CALENDAR_MAC_1904); @@ -137,7 +140,7 @@ class DateTest extends TestCase /** * @dataProvider providerDateTimeTimestampToExcel1904 */ - public function testDateTimeTimestampToExcel1904(mixed $expectedResult, mixed $unixTimestamp): void + public function testDateTimeTimestampToExcel1904(mixed $expectedResult, float|int|string $unixTimestamp): void { Date::setExcelCalendar(Date::CALENDAR_MAC_1904); @@ -167,7 +170,7 @@ class DateTest extends TestCase /** * @dataProvider providerDateTimeExcelToTimestamp1900Timezone */ - public function testDateTimeExcelToTimestamp1900Timezone(mixed $expectedResult, mixed $excelDateTimeValue, mixed $timezone): void + public function testDateTimeExcelToTimestamp1900Timezone(int $expectedResult, float|int $excelDateTimeValue, string $timezone): void { if (is_numeric($expectedResult) && ($expectedResult > PHP_INT_MAX || $expectedResult < PHP_INT_MIN)) { self::markTestSkipped('Test invalid on 32-bit system.'); @@ -206,6 +209,7 @@ class DateTest extends TestCase $spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('B1', 'x'); + /** @var float|int|string */ $val = $sheet->getCell('B1')->getValue(); self::assertFalse(Date::timestampToExcel($val)); diff --git a/tests/PhpSpreadsheetTests/Shared/FontTest.php b/tests/PhpSpreadsheetTests/Shared/FontTest.php index 27ebe4398..e9b1a2ed8 100644 --- a/tests/PhpSpreadsheetTests/Shared/FontTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FontTest.php @@ -44,7 +44,7 @@ class FontTest extends TestCase /** * @dataProvider providerFontSizeToPixels */ - public function testFontSizeToPixels(mixed $expectedResult, mixed $size): void + public function testFontSizeToPixels(float|int $expectedResult, float|int $size): void { $result = Font::fontSizeToPixels($size); self::assertEquals($expectedResult, $result); @@ -58,7 +58,7 @@ class FontTest extends TestCase /** * @dataProvider providerInchSizeToPixels */ - public function testInchSizeToPixels(mixed $expectedResult, mixed $size): void + public function testInchSizeToPixels(float|int $expectedResult, float|int $size): void { $result = Font::inchSizeToPixels($size); self::assertEqualsWithDelta($expectedResult, $result, self::FONT_PRECISION); @@ -72,7 +72,7 @@ class FontTest extends TestCase /** * @dataProvider providerCentimeterSizeToPixels */ - public function testCentimeterSizeToPixels(mixed $expectedResult, mixed $size): void + public function testCentimeterSizeToPixels(float $expectedResult, float $size): void { $result = Font::centimeterSizeToPixels($size); self::assertEqualsWithDelta($expectedResult, $result, self::FONT_PRECISION); diff --git a/tests/PhpSpreadsheetTests/Shared/StringHelperInvalidCharTest.php b/tests/PhpSpreadsheetTests/Shared/StringHelperInvalidCharTest.php index 5ee095377..eb46beaf3 100644 --- a/tests/PhpSpreadsheetTests/Shared/StringHelperInvalidCharTest.php +++ b/tests/PhpSpreadsheetTests/Shared/StringHelperInvalidCharTest.php @@ -36,6 +36,7 @@ class StringHelperInvalidCharTest extends TestCase self::assertSame($value[1] === $value[2], StringHelper::isUTF8((string) $value[1])); ++$row; $expected = $value[2]; + self::assertIsString($sheet->getCell("A$row")->getValue()); self::assertSame( $expected, $sheet->getCell("B$row")->getValue(), diff --git a/tests/PhpSpreadsheetTests/Shared/Trend/ExponentialBestFitTest.php b/tests/PhpSpreadsheetTests/Shared/Trend/ExponentialBestFitTest.php index ec44ff4c0..e6f26bf6e 100644 --- a/tests/PhpSpreadsheetTests/Shared/Trend/ExponentialBestFitTest.php +++ b/tests/PhpSpreadsheetTests/Shared/Trend/ExponentialBestFitTest.php @@ -11,14 +11,17 @@ class ExponentialBestFitTest extends TestCase { /** * @dataProvider providerExponentialBestFit + * + * @param array $yValues + * @param array $xValues */ public function testExponentialBestFit( - mixed $expectedSlope, - mixed $expectedIntersect, - mixed $expectedGoodnessOfFit, + array $expectedSlope, + array $expectedIntersect, + array $expectedGoodnessOfFit, mixed $expectedEquation, - mixed $yValues, - mixed $xValues + array $yValues, + array $xValues ): void { $bestFit = new ExponentialBestFit($yValues, $xValues); $slope = $bestFit->getSlope(1); diff --git a/tests/PhpSpreadsheetTests/Shared/Trend/LinearBestFitTest.php b/tests/PhpSpreadsheetTests/Shared/Trend/LinearBestFitTest.php index 6f150ffa9..e9de8a2e5 100644 --- a/tests/PhpSpreadsheetTests/Shared/Trend/LinearBestFitTest.php +++ b/tests/PhpSpreadsheetTests/Shared/Trend/LinearBestFitTest.php @@ -13,14 +13,17 @@ class LinearBestFitTest extends TestCase /** * @dataProvider providerLinearBestFit + * + * @param array $yValues + * @param array $xValues */ public function testLinearBestFit( - mixed $expectedSlope, - mixed $expectedIntersect, - mixed $expectedGoodnessOfFit, + array $expectedSlope, + array $expectedIntersect, + array $expectedGoodnessOfFit, mixed $expectedEquation, - mixed $yValues, - mixed $xValues + array $yValues, + array $xValues ): void { $bestFit = new LinearBestFit($yValues, $xValues); $slope = $bestFit->getSlope(1); diff --git a/tests/PhpSpreadsheetTests/Style/ColorTest.php b/tests/PhpSpreadsheetTests/Style/ColorTest.php index 4848f5cf9..91f03e3fe 100644 --- a/tests/PhpSpreadsheetTests/Style/ColorTest.php +++ b/tests/PhpSpreadsheetTests/Style/ColorTest.php @@ -133,9 +133,9 @@ class ColorTest extends TestCase /** * @dataProvider providerColorChangeBrightness */ - public function testChangeBrightness(mixed $expectedResult, mixed ...$args): void + public function testChangeBrightness(string $expectedResult, string $hexColorValue, float $adjustPercentages): void { - $result = Color::changeBrightness(...$args); + $result = Color::changeBrightness($hexColorValue, $adjustPercentages); self::assertEquals($expectedResult, $result); } diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php index dc02ca7b8..c06cb633f 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php @@ -128,6 +128,7 @@ class DateGroupTest extends SetupTeardown { $year = 2011; $sheet = $this->initSheet($year); + /** @var int|string */ $cellA2 = $sheet->getCell('A2')->getCalculatedValue(); $columnFilter = $sheet->getAutoFilter()->getColumn('C'); $columnFilter->setFilterType(Column::AUTOFILTER_FILTERTYPE_FILTER); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php b/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php index f792f9252..de81f35e8 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php @@ -138,7 +138,7 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional /** * @dataProvider providerNumberFormat */ - public function testFormatValueWithMask(mixed $expectedResult, mixed $val, mixed $fmt): void + public function testFormatValueWithMask(mixed $expectedResult, mixed $val, string $fmt): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -170,7 +170,7 @@ class HtmlNumberFormatTest extends Functional\AbstractFunctional /** * @dataProvider providerNumberFormatDates */ - public function testFormatValueWithMaskDate(mixed $expectedResult, mixed $val, mixed $fmt): void + public function testFormatValueWithMaskDate(mixed $expectedResult, mixed $val, string $fmt): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php index 01a68974e..253ea3039 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php @@ -77,6 +77,7 @@ class WorkbookTest extends TestCase $propertyPalette->setAccessible(true); $palette = $propertyPalette->getValue($this->workbook); + self::assertIsArray($palette); $newColor1 = [0x00, 0x00, 0x01, 0x00]; $newColor2 = [0x00, 0x00, 0x02, 0x00]; diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFormulaPrefixTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFormulaPrefixTest.php index e6d6e085f..55eacf68f 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFormulaPrefixTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/ArrayFormulaPrefixTest.php @@ -38,6 +38,7 @@ class ArrayFormulaPrefixTest extends AbstractFunctional //Write formula $cell = $worksheet->getCell('A7'); $cell->setValueExplicit('=TEXTJOIN("",TRUE,IF(ISNUMBER(A1:A6), A1:A6,""))', DataType::TYPE_FORMULA); + /** @var array */ $attrs = $cell->getFormulaAttributes(); $attrs['t'] = 'array'; $cell->setFormulaAttributes($attrs); @@ -74,6 +75,7 @@ class ArrayFormulaPrefixTest extends AbstractFunctional //Write formula $cell = $worksheet->getCell('A7'); $cell->setValueExplicit('=SUM(LEN(A1:A6))', DataType::TYPE_FORMULA); + /** @var array */ $attrs = $cell->getFormulaAttributes(); $attrs['t'] = 'array'; $cell->setFormulaAttributes($attrs);