diff --git a/CHANGELOG.md b/CHANGELOG.md index c3bb9e7edc..9118916cd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org). ## Unreleased - TBD +### MINOR BREAKING CHANGE + +- Typing was strengthened by leveraging native typing. While this should not change any behavior, it might need minor + adaption of your code if you use static analysis tools such as PHPStan or + Psalm. [PR #3718](https://github.com/PHPOffice/PhpSpreadsheet/pull/3718) + ### Added - Split screens (Xlsx and Xml only, not 100% complete). [Issue #3601](https://github.com/PHPOffice/PhpSpreadsheet/issues/3601) [PR #3622](https://github.com/PHPOffice/PhpSpreadsheet/pull/3622) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index b894ce1381..f6ce123adc 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -19,8 +19,5 @@ parameters: processTimeout: 300.0 checkMissingIterableValueType: false ignoreErrors: - - '~^Parameter \#1 \$im(age)? of function (imagedestroy|imageistruecolor|imagealphablending|imagesavealpha|imagecolortransparent|imagecolorsforindex|imagesavealpha|imagesx|imagesy|imagepng|imagecolorat) expects (GdImage|resource), GdImage\|resource given\.$~' - - '~^Parameter \#2 \$src_im(age)? of function imagecopy expects (GdImage|resource), GdImage\|resource given\.$~' # Accept a bit anything for assert methods - '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~' - - '~^Method PhpOffice\\PhpSpreadsheetTests\\.*\:\:test.*\(\) has parameter \$args with no type specified\.$~' diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index ef4fb6ce0d..18bdd63470 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -74,10 +74,8 @@ class Calculation /** * Instance of the spreadsheet this Calculation Engine is using. - * - * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet; /** * Calculation cache. @@ -93,10 +91,7 @@ class Calculation */ private $calculationCacheEnabled = true; - /** - * @var BranchPruner - */ - private $branchPruner; + private BranchPruner $branchPruner; /** * @var bool @@ -127,10 +122,8 @@ class Calculation /** * The debug log generated by the calculation engine. - * - * @var Logger */ - private $debugLog; + private Logger $debugLog; /** * Flag to determine how formula errors should be handled @@ -155,17 +148,13 @@ class Calculation /** * Reference Helper. - * - * @var ReferenceHelper */ - private static $referenceHelper; + private static ReferenceHelper $referenceHelper; /** * An array of the nested cell references accessed by the calculation engine, used for the debug log. - * - * @var CyclicReferenceStack */ - private $cyclicReferenceStack; + private CyclicReferenceStack $cyclicReferenceStack; /** @var array */ private $cellStack = []; @@ -3018,7 +3007,7 @@ public static function getFALSE(): string * * @return bool Success or failure */ - public static function setArrayReturnType($returnType) + public static function setArrayReturnType($returnType): bool { if ( ($returnType == self::RETURN_ARRAY_AS_VALUE) || @@ -3164,10 +3153,8 @@ private function getLocaleFile(string $localeDir, string $locale, string $langua * Set the locale code. * * @param string $locale The locale to use for formula translation, eg: 'en_us' - * - * @return bool */ - public function setLocale(string $locale) + public function setLocale(string $locale): bool { // Identify our locale and language $language = $locale = strtolower($locale); @@ -3341,12 +3328,7 @@ private static function translateFormula(array $from, array $to, string $formula /** @var ?array */ private static $functionReplaceToLocale; - /** - * @param string $formula - * - * @return string - */ - public function _translateFormulaToLocale($formula) + public function _translateFormulaToLocale(string $formula): string { // Build list of function names and constants for translation if (self::$functionReplaceFromExcel === null) { @@ -3384,12 +3366,7 @@ public function _translateFormulaToLocale($formula) /** @var ?array */ private static $functionReplaceToExcel; - /** - * @param string $formula - * - * @return string - */ - public function _translateFormulaToEnglish($formula) + public function _translateFormulaToEnglish(string $formula): string { if (self::$functionReplaceFromLocale === null) { self::$functionReplaceFromLocale = []; @@ -3438,11 +3415,9 @@ public static function localeFunc($function) /** * Wrap string values in quotes. * - * @param mixed $value - * * @return mixed */ - public static function wrapResult($value) + public static function wrapResult(mixed $value) { if (is_string($value)) { // Error values cannot be "wrapped" @@ -3783,10 +3758,8 @@ public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = n * 0 = no resize * 1 = shrink to fit * 2 = extend to fit - * - * @return array */ - private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1) + private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1): array { // Examine each of the two operands, and turn them into an array if they aren't one already // Note that this function should only be called if one or both of the operand is already an array @@ -3824,7 +3797,7 @@ private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1) * * @return int[] An array comprising the number of rows, and number of columns */ - public static function getMatrixDimensions(array &$matrix) + public static function getMatrixDimensions(array &$matrix): array { $matrixRows = count($matrix); $matrixColumns = 0; @@ -3845,14 +3818,14 @@ public static function getMatrixDimensions(array &$matrix) /** * Ensure that paired matrix operands are both matrices of the same size. * - * @param mixed $matrix1 First matrix operand - * @param mixed $matrix2 Second matrix operand + * @param array $matrix1 First matrix operand + * @param array $matrix2 Second matrix operand * @param int $matrix1Rows Row size of first matrix operand * @param int $matrix1Columns Column size of first matrix operand * @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand */ - private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void + private static function resizeMatricesShrink(array &$matrix1, array &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Rows < $matrix1Rows) { @@ -3888,14 +3861,14 @@ private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, /** * Ensure that paired matrix operands are both matrices of the same size. * - * @param mixed $matrix1 First matrix operand - * @param mixed $matrix2 Second matrix operand + * @param array $matrix1 First matrix operand + * @param array $matrix2 Second matrix operand * @param int $matrix1Rows Row size of first matrix operand * @param int $matrix1Columns Column size of first matrix operand * @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand */ - private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void + private static function resizeMatricesExtend(array &$matrix1, array &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Columns < $matrix1Columns) { @@ -3976,10 +3949,8 @@ private function showValue($value) * Format type and details of an operand for display in the log (based on operand type). * * @param mixed $value First matrix operand - * - * @return null|string */ - private function showTypeDetails($value) + private function showTypeDetails($value): ?string { if ($this->debugLog->getWriteDebugLog()) { $testArray = Functions::flattenArray($value); @@ -4013,11 +3984,9 @@ private function showTypeDetails($value) } /** - * @param string $formula - * * @return false|string False indicates an error */ - private function convertMatrixReferences($formula) + private function convertMatrixReferences(string $formula): false|string { static $matrixReplaceFrom = [self::FORMULA_OPEN_MATRIX_BRACE, ';', self::FORMULA_CLOSE_MATRIX_BRACE]; static $matrixReplaceTo = ['MKMATRIX(MKMATRIX(', '),MKMATRIX(', '))']; @@ -4120,7 +4089,7 @@ private function convertMatrixReferences($formula) * * @return array|false */ - private function internalParseFormula($formula, ?Cell $cell = null) + private function internalParseFormula($formula, ?Cell $cell = null): bool|array { if (($formula = $this->convertMatrixReferences(trim($formula))) === false) { return false; @@ -4444,6 +4413,7 @@ private function internalParseFormula($formula, ?Cell $cell = null) } elseif ($val === Information\ExcelError::REF()) { $stackItemReference = $val; } else { + /** @var non-empty-string $startRowColRef */ $startRowColRef = $output[count($output) - 1]['value'] ?? ''; [$rangeWS1, $startRowColRef] = Worksheet::extractSheetTitle($startRowColRef, true); $rangeSheetRef = $rangeWS1; @@ -4470,7 +4440,7 @@ private function internalParseFormula($formula, ?Cell $cell = null) $valx = $val; $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestDataColumn($valx) : AddressRange::MAX_COLUMN; // Max 16,384 columns for Excel2007 $val = "{$rangeWS2}{$endRowColRef}{$val}"; - } elseif (ctype_alpha($val) && strlen($val) <= 3) { + } elseif (ctype_alpha($val) && strlen($val ?? '') <= 3) { // Column range $stackItemType = 'Column Reference'; $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestDataRow($val) : AddressRange::MAX_ROW; // Max 1,048,576 rows for Excel2007 @@ -4614,11 +4584,9 @@ private function internalParseFormula($formula, ?Cell $cell = null) } /** - * @param array $operandData - * * @return mixed */ - private static function dataTestReference(&$operandData) + private static function dataTestReference(array &$operandData) { $operand = $operandData['value']; if (($operandData['reference'] === null) && (is_array($operand))) { @@ -4807,6 +4775,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null) } else { $sheet1 = ($pCellWorksheet !== null) ? $pCellWorksheet->getTitle() : ''; } + $sheet1 ??= ''; [$sheet2, $operand2Data['reference']] = Worksheet::extractSheetTitle($operand2Data['reference'], true); if (empty($sheet2)) { @@ -4837,7 +4806,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null) } } - $oData = array_merge(explode(':', $operand1Data['reference']), explode(':', $operand2Data['reference'])); + $oData = array_merge(explode(':', $operand1Data['reference'] ?? ''), explode(':', $operand2Data['reference'] ?? '')); $oCol = $oRow = []; $breakNeeded = false; foreach ($oData as $oDatum) { @@ -5224,10 +5193,8 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null) /** * @param mixed $operand * @param mixed $stack - * - * @return bool */ - private function validateBinaryOperand(&$operand, &$stack) + private function validateBinaryOperand(&$operand, &$stack): bool { if (is_array($operand)) { if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) { @@ -5268,11 +5235,8 @@ private function validateBinaryOperand(&$operand, &$stack) /** * @param mixed $operand1 * @param mixed $operand2 - * @param string $operation - * - * @return array */ - private function executeArrayComparison($operand1, $operand2, $operation, Stack &$stack, bool $recursingArrays) + private function executeArrayComparison($operand1, $operand2, string $operation, Stack &$stack, bool $recursingArrays): array { $result = []; if (!is_array($operand2)) { @@ -5314,12 +5278,8 @@ private function executeArrayComparison($operand1, $operand2, $operation, Stack /** * @param mixed $operand1 * @param mixed $operand2 - * @param string $operation - * @param bool $recursingArrays - * - * @return mixed */ - private function executeBinaryComparisonOperation($operand1, $operand2, $operation, Stack &$stack, $recursingArrays = false) + private function executeBinaryComparisonOperation($operand1, $operand2, string $operation, Stack &$stack, bool $recursingArrays = false): array|bool { // If we're dealing with matrix operations, we want a matrix result if ((is_array($operand1)) || (is_array($operand2))) { @@ -5476,7 +5436,7 @@ private function executeNumericBinaryOperation($operand1, $operand2, $operation, * * @return false */ - protected function raiseFormulaError(string $errorMessage, int $code = 0, ?Throwable $exception = null) + protected function raiseFormulaError(string $errorMessage, int $code = 0, ?Throwable $exception = null): bool { $this->formulaError = $errorMessage; $this->cyclicReferenceStack->clear(); @@ -5495,9 +5455,9 @@ protected function raiseFormulaError(string $errorMessage, int $code = 0, ?Throw * @param Worksheet $worksheet Worksheet * @param bool $resetLog Flag indicating whether calculation log should be reset or not * - * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. + * @return array Array of values in range if range contains more than one element. Otherwise, a single value is returned. */ - public function extractCellRange(&$range = 'A1', ?Worksheet $worksheet = null, $resetLog = true) + public function extractCellRange(&$range = 'A1', ?Worksheet $worksheet = null, bool $resetLog = true): array { // Return value $returnValue = []; @@ -5547,9 +5507,9 @@ public function extractCellRange(&$range = 'A1', ?Worksheet $worksheet = null, $ * @param null|Worksheet $worksheet Worksheet * @param bool $resetLog Flag indicating whether calculation log should be reset or not * - * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. + * @return array|string Array of values in range if range contains more than one element. Otherwise, a single value is returned. */ - public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet = null, $resetLog = true) + public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet = null, bool $resetLog = true): string|array { // Return value $returnValue = []; @@ -5607,10 +5567,8 @@ public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet = * Is a specific function implemented? * * @param string $function Function Name - * - * @return bool */ - public function isImplemented($function) + public function isImplemented($function): bool { $function = strtoupper($function); $notImplemented = !isset(self::$phpSpreadsheetFunctions[$function]) || (is_array(self::$phpSpreadsheetFunctions[$function]['functionCall']) && self::$phpSpreadsheetFunctions[$function]['functionCall'][1] === 'DUMMY'); @@ -5628,10 +5586,8 @@ public static function getFunctions(): array /** * Get a list of implemented Excel function names. - * - * @return array */ - public function getImplementedFunctionNames() + public function getImplementedFunctionNames(): array { $returnValue = []; foreach (self::$phpSpreadsheetFunctions as $functionName => $function) { @@ -5697,12 +5653,9 @@ private function getArgumentDefaultValue(ReflectionParameter $methodArgument) /** * Add cell reference if needed while making sure that it is the last argument. * - * @param bool $passCellReference * @param array|string $functionCall - * - * @return array */ - private function addCellReference(array $args, $passCellReference, $functionCall, ?Cell $cell = null) + private function addCellReference(array $args, bool $passCellReference, $functionCall, ?Cell $cell = null): array { if ($passCellReference) { if (is_array($functionCall)) { diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php index 017c57106b..547d6062c3 100644 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ b/src/PhpSpreadsheet/Calculation/Database.php @@ -25,7 +25,7 @@ class Database * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -71,12 +71,10 @@ public static function DAVERAGE($database, $field, $criteria) * the column label in which you specify a condition for the * column. * - * @return int|string - * * @TODO The field argument is optional. If field is omitted, DCOUNT counts all records in the * database that match the criteria. */ - public static function DCOUNT($database, $field, $criteria) + public static function DCOUNT($database, $field, $criteria): string|int { return Database\DCount::evaluate($database, $field, $criteria); } @@ -97,7 +95,7 @@ public static function DCOUNT($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -107,10 +105,8 @@ public static function DCOUNT($database, $field, $criteria) * includes at least one column label and at least one cell below * the column label in which you specify a condition for the * column. - * - * @return int|string */ - public static function DCOUNTA($database, $field, $criteria) + public static function DCOUNTA($database, $field, $criteria): string|int { return Database\DCountA::evaluate($database, $field, $criteria); } @@ -132,7 +128,7 @@ public static function DCOUNTA($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -167,7 +163,7 @@ public static function DGET($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -202,7 +198,7 @@ public static function DMAX($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -236,7 +232,7 @@ public static function DMIN($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -271,7 +267,7 @@ public static function DPRODUCT($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -306,7 +302,7 @@ public static function DSTDEV($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -340,7 +336,7 @@ public static function DSTDEVP($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -375,7 +371,7 @@ public static function DSUM($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -410,7 +406,7 @@ public static function DVAR($database, $field, $criteria) * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for diff --git a/src/PhpSpreadsheet/Calculation/Database/DAverage.php b/src/PhpSpreadsheet/Calculation/Database/DAverage.php index 245e970d6a..9388e469c7 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DAverage.php +++ b/src/PhpSpreadsheet/Calculation/Database/DAverage.php @@ -19,7 +19,7 @@ class DAverage extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -32,7 +32,7 @@ class DAverage extends DatabaseAbstract * * @return float|string */ - public static function evaluate($database, $field, $criteria) + public static function evaluate($database, $field, $criteria): string|int|float { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DCount.php b/src/PhpSpreadsheet/Calculation/Database/DCount.php index 66e1987e19..82795d84b7 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DCount.php +++ b/src/PhpSpreadsheet/Calculation/Database/DCount.php @@ -30,10 +30,8 @@ class DCount extends DatabaseAbstract * includes at least one column label and at least one cell below * the column label in which you specify a condition for the * column. - * - * @return int|string */ - public static function evaluate($database, $field, $criteria, bool $returnError = true) + public static function evaluate($database, $field, $criteria, bool $returnError = true): string|int { $field = self::fieldExtract($database, $field); if ($returnError && $field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DCountA.php b/src/PhpSpreadsheet/Calculation/Database/DCountA.php index 214c20b7b2..fee8e5a547 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DCountA.php +++ b/src/PhpSpreadsheet/Calculation/Database/DCountA.php @@ -19,7 +19,7 @@ class DCountA extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -29,10 +29,8 @@ class DCountA extends DatabaseAbstract * includes at least one column label and at least one cell below * the column label in which you specify a condition for the * column. - * - * @return int|string */ - public static function evaluate($database, $field, $criteria) + public static function evaluate($database, $field, $criteria): string|int { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DGet.php b/src/PhpSpreadsheet/Calculation/Database/DGet.php index 5647cba5cc..4a52f2e416 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DGet.php +++ b/src/PhpSpreadsheet/Calculation/Database/DGet.php @@ -19,7 +19,7 @@ class DGet extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for diff --git a/src/PhpSpreadsheet/Calculation/Database/DMax.php b/src/PhpSpreadsheet/Calculation/Database/DMax.php index 748fd2fc84..512557ccc2 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DMax.php +++ b/src/PhpSpreadsheet/Calculation/Database/DMax.php @@ -20,7 +20,7 @@ class DMax extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for diff --git a/src/PhpSpreadsheet/Calculation/Database/DMin.php b/src/PhpSpreadsheet/Calculation/Database/DMin.php index 544cbffefb..ce01a0debc 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DMin.php +++ b/src/PhpSpreadsheet/Calculation/Database/DMin.php @@ -20,7 +20,7 @@ class DMin extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for diff --git a/src/PhpSpreadsheet/Calculation/Database/DProduct.php b/src/PhpSpreadsheet/Calculation/Database/DProduct.php index 351ee6fc22..c420ab6b55 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DProduct.php +++ b/src/PhpSpreadsheet/Calculation/Database/DProduct.php @@ -19,7 +19,7 @@ class DProduct extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -29,10 +29,8 @@ class DProduct extends DatabaseAbstract * includes at least one column label and at least one cell below * the column label in which you specify a condition for the * column. - * - * @return float|string */ - public static function evaluate($database, $field, $criteria) + public static function evaluate($database, $field, $criteria): string|float { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DStDev.php b/src/PhpSpreadsheet/Calculation/Database/DStDev.php index a1c56532fb..05418d490c 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DStDev.php +++ b/src/PhpSpreadsheet/Calculation/Database/DStDev.php @@ -20,7 +20,7 @@ class DStDev extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for diff --git a/src/PhpSpreadsheet/Calculation/Database/DStDevP.php b/src/PhpSpreadsheet/Calculation/Database/DStDevP.php index 5bca4e7232..927e29ceca 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DStDevP.php +++ b/src/PhpSpreadsheet/Calculation/Database/DStDevP.php @@ -20,7 +20,7 @@ class DStDevP extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for diff --git a/src/PhpSpreadsheet/Calculation/Database/DSum.php b/src/PhpSpreadsheet/Calculation/Database/DSum.php index ef4d10e809..aa8976bc8c 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DSum.php +++ b/src/PhpSpreadsheet/Calculation/Database/DSum.php @@ -19,7 +19,7 @@ class DSum extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for diff --git a/src/PhpSpreadsheet/Calculation/Database/DVar.php b/src/PhpSpreadsheet/Calculation/Database/DVar.php index 9cfa971482..d579ce357a 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DVar.php +++ b/src/PhpSpreadsheet/Calculation/Database/DVar.php @@ -20,7 +20,7 @@ class DVar extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -33,7 +33,7 @@ class DVar extends DatabaseAbstract * * @return float|string (string if result is an error) */ - public static function evaluate($database, $field, $criteria) + public static function evaluate($database, $field, $criteria): string|float { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DVarP.php b/src/PhpSpreadsheet/Calculation/Database/DVarP.php index 67dbd68415..8a990d77c8 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DVarP.php +++ b/src/PhpSpreadsheet/Calculation/Database/DVarP.php @@ -20,7 +20,7 @@ class DVarP extends DatabaseAbstract * A database is a list of related data in which rows of related * information are records, and columns of data are fields. The * first row of the list contains labels for each column. - * @param int|string $field Indicates which column is used in the function. Enter the + * @param null|int|string $field Indicates which column is used in the function. Enter the * column label enclosed between double quotation marks, such as * "Age" or "Yield," or a number (without quotation marks) that * represents the position of the column within the list: 1 for @@ -33,7 +33,7 @@ class DVarP extends DatabaseAbstract * * @return float|string (string if result is an error) */ - public static function evaluate($database, $field, $criteria) + public static function evaluate($database, $field, $criteria): string|float { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php b/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php index 0b8c36dabe..d8b0d2094d 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php +++ b/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php @@ -10,7 +10,7 @@ abstract class DatabaseAbstract { /** * @param array $database - * @param int|string $field + * @param null|int|string $field * @param array $criteria * * @return null|float|int|string @@ -115,7 +115,7 @@ private static function buildQuery(array $criteriaNames, array $criteria): strin } $rowQuery = array_map( - function ($rowValue) { + function ($rowValue): string { return (count($rowValue) > 1) ? 'AND(' . implode(',', $rowValue) . ')' : ($rowValue[0] ?? ''); }, $baseQuery diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 26b667ca46..86a2114a25 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -20,7 +20,7 @@ class DateTime * * @return bool TRUE if the year is a leap year, otherwise FALSE */ - public static function isLeapYear($year) + public static function isLeapYear($year): bool { return DateTimeExcel\Helpers::isLeapYear($year); } @@ -34,9 +34,9 @@ public static function isLeapYear($year) * * @param mixed $dateValue * - * @return mixed Excel date/time serial value, or string if error + * @return float|string Excel date/time serial value, or string if error */ - public static function getDateValue($dateValue) + public static function getDateValue($dateValue): float|string { try { return DateTimeExcel\Helpers::getDateValue($dateValue); @@ -183,10 +183,10 @@ public static function DATE($year = 0, $month = 1, $day = 1) * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 * or 12:33:20 AM * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, + * @return array|\DateTime|float|int|string Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag */ - public static function TIME($hour = 0, $minute = 0, $second = 0) + public static function TIME($hour = 0, $minute = 0, $second = 0): string|float|int|\DateTime|array { return DateTimeExcel\Time::fromHMS($hour, $minute, $second); } @@ -247,10 +247,10 @@ public static function DATEVALUE($dateValue) * within quotation marks that represent time. * Date information in time_text is ignored. * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, + * @return array|\Datetime|float|int|string Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag */ - public static function TIMEVALUE($timeValue) + public static function TIMEVALUE($timeValue): string|\Datetime|int|float|array { return DateTimeExcel\TimeValue::fromString($timeValue); } @@ -334,7 +334,7 @@ public static function DAYS($endDate = 0, $startDate = 0) * * @return array|int|string Number of days between start date and end date */ - public static function DAYS360($startDate = 0, $endDate = 0, $method = false) + public static function DAYS360($startDate = 0, $endDate = 0, $method = false): string|int|array { return DateTimeExcel\Days360::between($startDate, $endDate, $method); } @@ -370,7 +370,7 @@ public static function DAYS360($startDate = 0, $endDate = 0, $method = false) * * @return array|float|string fraction of the year, or a string containing an error */ - public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) + public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0): string|int|float|array { return DateTimeExcel\YearFrac::fraction($startDate, $endDate, $method); } @@ -398,7 +398,7 @@ public static function YEARFRAC($startDate = 0, $endDate = 0, $method = 0) * * @return array|int|string Interval between the dates */ - public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs) + public static function NETWORKDAYS($startDate, $endDate, ...$dateArgs): string|int|array { return DateTimeExcel\NetworkDays::count($startDate, $endDate, ...$dateArgs); } @@ -451,7 +451,7 @@ public static function WORKDAY($startDate, $endDays, ...$dateArgs) * * @return array|int|string Day of the month */ - public static function DAYOFMONTH($dateValue = 1) + public static function DAYOFMONTH($dateValue = 1): int|string|array { return DateTimeExcel\DateParts::day($dateValue); } @@ -478,7 +478,7 @@ public static function DAYOFMONTH($dateValue = 1) * * @return array|int|string Day of the week value */ - public static function WEEKDAY($dateValue = 1, $style = 1) + public static function WEEKDAY($dateValue = 1, $style = 1): string|int|array { return DateTimeExcel\Week::day($dateValue, $style); } @@ -689,7 +689,7 @@ public static function WEEKDAY($dateValue = 1, $style = 1) * * @return array|int|string Week Number */ - public static function WEEKNUM($dateValue = 1, $method = /** @scrutinizer ignore-deprecated */ self::STARTWEEK_SUNDAY) + public static function WEEKNUM($dateValue = 1, $method = /** @scrutinizer ignore-deprecated */ self::STARTWEEK_SUNDAY): int|string|array { return DateTimeExcel\Week::number($dateValue, $method); } @@ -711,7 +711,7 @@ public static function WEEKNUM($dateValue = 1, $method = /** @scrutinizer ignore * * @return array|int|string Week Number */ - public static function ISOWEEKNUM($dateValue = 1) + public static function ISOWEEKNUM($dateValue = 1): int|string|array { return DateTimeExcel\Week::isoWeekNumber($dateValue); } @@ -734,7 +734,7 @@ public static function ISOWEEKNUM($dateValue = 1) * * @return array|int|string Month of the year */ - public static function MONTHOFYEAR($dateValue = 1) + public static function MONTHOFYEAR($dateValue = 1): string|int|array { return DateTimeExcel\DateParts::month($dateValue); } @@ -757,7 +757,7 @@ public static function MONTHOFYEAR($dateValue = 1) * * @return array|int|string Year */ - public static function YEAR($dateValue = 1) + public static function YEAR($dateValue = 1): string|int|array { return DateTimeExcel\DateParts::year($dateValue); } @@ -780,7 +780,7 @@ public static function YEAR($dateValue = 1) * * @return array|int|string Hour */ - public static function HOUROFDAY($timeValue = 0) + public static function HOUROFDAY($timeValue = 0): string|int|array { return DateTimeExcel\TimeParts::hour($timeValue); } @@ -803,7 +803,7 @@ public static function HOUROFDAY($timeValue = 0) * * @return array|int|string Minute */ - public static function MINUTE($timeValue = 0) + public static function MINUTE($timeValue = 0): string|int|array { return DateTimeExcel\TimeParts::minute($timeValue); } @@ -826,7 +826,7 @@ public static function MINUTE($timeValue = 0) * * @return array|int|string Second */ - public static function SECOND($timeValue = 0) + public static function SECOND($timeValue = 0): string|int|array { return DateTimeExcel\TimeParts::second($timeValue); } diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateParts.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateParts.php index 7bb03c9da8..c05174fa8c 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateParts.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateParts.php @@ -28,7 +28,7 @@ class DateParts * 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 day($dateValue) + public static function day($dateValue): array|int|string { if (is_array($dateValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $dateValue); @@ -69,7 +69,7 @@ public static function day($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 month($dateValue) + public static function month($dateValue): array|string|int { if (is_array($dateValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $dateValue); @@ -108,7 +108,7 @@ public static function month($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 year($dateValue) + public static function year($dateValue): array|string|int { if (is_array($dateValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $dateValue); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php index 6f71621eaa..9ac9ccb664 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php @@ -44,7 +44,7 @@ class Days360 * If an array of values is passed for the $startDate or $endDays,arguments, then the returned result * will also be an array with matching dimensions */ - public static function between($startDate = 0, $endDate = 0, $method = false) + public static function between($startDate = 0, $endDate = 0, $method = false): array|string|int { if (is_array($startDate) || is_array($endDate) || is_array($method)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $startDate, $endDate, $method); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index 238451534a..07bebe9246 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -133,10 +133,8 @@ public static function adjustYear(string $testVal1, string $testVal2, string &$t /** * Return result in one of three formats. - * - * @return mixed */ - public static function returnIn3FormatsArray(array $dateArray, bool $noFrac = false) + public static function returnIn3FormatsArray(array $dateArray, bool $noFrac = false): DateTime|float|int { $retType = Functions::getReturnDateType(); if ($retType === Functions::RETURNDATE_PHP_DATETIME_OBJECT) { @@ -159,11 +157,11 @@ public static function returnIn3FormatsArray(array $dateArray, bool $noFrac = fa $dateArray['second'] ); if ($retType === Functions::RETURNDATE_EXCEL) { - return $noFrac ? floor($excelDateValue) : (float) $excelDateValue; + return $noFrac ? floor($excelDateValue) : $excelDateValue; } // RETURNDATE_UNIX_TIMESTAMP) - return (int) SharedDateHelper::excelToTimestamp($excelDateValue); + return SharedDateHelper::excelToTimestamp($excelDateValue); } /** @@ -187,10 +185,8 @@ public static function returnIn3FormatsFloat(float $excelDateValue) /** * Return result in one of three formats. - * - * @return mixed */ - public static function returnIn3FormatsObject(DateTime $PHPDateObject) + public static function returnIn3FormatsObject(DateTime $PHPDateObject): DateTime|float|int { $retType = Functions::getReturnDateType(); if ($retType === Functions::RETURNDATE_PHP_DATETIME_OBJECT) { @@ -203,7 +199,7 @@ public static function returnIn3FormatsObject(DateTime $PHPDateObject) $stamp = SharedDateHelper::PHPToExcel($PHPDateObject); $stamp = is_bool($stamp) ? ((int) $stamp) : $stamp; - return (int) SharedDateHelper::excelToTimestamp($stamp); + return SharedDateHelper::excelToTimestamp($stamp); } private static function baseDate(): int @@ -238,10 +234,8 @@ public static function nullFalseTrueToNumber(&$number, bool $allowBool = true): * Many functions accept null argument treated as 0. * * @param mixed $number - * - * @return float|int */ - public static function validateNumericNull($number) + public static function validateNumericNull($number): int|float { $number = Functions::flattenSingleValue($number); if ($number === null) { diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php index 3b8942bafb..a487f2a3f7 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php @@ -33,7 +33,7 @@ class NetworkDays * If an array of values is passed for the $startDate or $endDate arguments, then the returned result * will also be an array with matching dimensions */ - public static function count($startDate, $endDate, ...$dateArgs) + public static function count($startDate, $endDate, ...$dateArgs): array|string|int { if (is_array($startDate) || is_array($endDate)) { return self::evaluateArrayArgumentsSubset( diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php index 4ff71983f4..44d863006c 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php @@ -38,12 +38,12 @@ class Time * If an array of numbers is passed as the argument, then the returned result will also be an array * with the same dimensions * - * @return array|mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, + * @return array|DateTime|float|int|string Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag * 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 fromHMS($hour, $minute, $second) + public static function fromHMS($hour, $minute, $second): array|string|float|int|DateTime { if (is_array($hour) || is_array($minute) || is_array($second)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $hour, $minute, $second); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php index e1331b0109..1c65a6edb8 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php @@ -27,7 +27,7 @@ class TimeParts * 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 hour($timeValue) + public static function hour($timeValue): array|string|int { if (is_array($timeValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $timeValue); @@ -68,7 +68,7 @@ public static function hour($timeValue) * 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 minute($timeValue) + public static function minute($timeValue): array|string|int { if (is_array($timeValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $timeValue); @@ -109,7 +109,7 @@ public static function minute($timeValue) * 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 second($timeValue) + public static function second($timeValue): array|string|int { if (is_array($timeValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $timeValue); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php index 78d67b837d..b5024d1731 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php @@ -31,12 +31,12 @@ class TimeValue * Date information in time_text is ignored. * Or can be an array of date/time values * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, + * @return array|Datetime|float|int|string Excel date/time serial value, PHP date/time serial value or PHP date/time object, * depending on the value of the ReturnDateType flag * 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($timeValue) + public static function fromString($timeValue): array|string|Datetime|int|float { if (is_array($timeValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $timeValue); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php index 2f69007d13..e023726d2a 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php @@ -45,7 +45,7 @@ class Week * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function number($dateValue, $method = Constants::STARTWEEK_SUNDAY) + public static function number($dateValue, $method = Constants::STARTWEEK_SUNDAY): array|int|string { if (is_array($dateValue) || is_array($method)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $method); @@ -105,7 +105,7 @@ public static function number($dateValue, $method = Constants::STARTWEEK_SUNDAY) * 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 isoWeekNumber($dateValue) + public static function isoWeekNumber($dateValue): array|int|string { if (is_array($dateValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $dateValue); @@ -150,7 +150,7 @@ public static function isoWeekNumber($dateValue) * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function day($dateValue, $style = 1) + public static function day($dateValue, $style = 1): array|string|int { if (is_array($dateValue) || is_array($style)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $style); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php index 394c6b7320..d6f66a53e8 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php @@ -43,7 +43,7 @@ class YearFrac * If an array of values is passed for the $startDate or $endDays,arguments, then the returned result * will also be an array with matching dimensions */ - public static function fraction($startDate, $endDate, $method = 0) + public static function fraction($startDate, $endDate, $method = 0): array|string|int|float { if (is_array($startDate) || is_array($endDate) || is_array($method)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $startDate, $endDate, $method); diff --git a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php index fae9d90097..1d8b329981 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php +++ b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php @@ -152,7 +152,7 @@ public function columnCount(int $argument): int private function rows(array $arguments): array { return array_map( - function ($argument) { + function ($argument): int { return is_countable($argument) ? count($argument) : 1; }, $arguments @@ -162,7 +162,7 @@ function ($argument) { private function columns(array $arguments): array { return array_map( - function ($argument) { + function ($argument): int { return is_array($argument) && is_array($argument[array_keys($argument)[0]]) ? count($argument[array_keys($argument)[0]]) : 1; @@ -201,7 +201,7 @@ private function filterArray(array $array): array { return array_filter( $array, - function ($value) { + function ($value): bool { return $value > 1; } ); diff --git a/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php b/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php index 9cd767e6a6..09a1a251d0 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php +++ b/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php @@ -6,10 +6,7 @@ class BranchPruner { - /** - * @var bool - */ - protected $branchPruningEnabled = true; + protected bool $branchPruningEnabled; /** * Used to generate unique store keys. @@ -50,20 +47,11 @@ class BranchPruner */ protected $braceDepthMap = []; - /** - * @var null|string - */ - protected $currentCondition; + protected ?string $currentCondition = null; - /** - * @var null|string - */ - protected $currentOnlyIf; + protected ?string $currentOnlyIf = null; - /** - * @var null|string - */ - protected $currentOnlyIfNot; + protected ?string $currentOnlyIfNot = null; /** * @var null|string diff --git a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php index b688e05634..6c4d23ad4c 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php +++ b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php @@ -13,10 +13,8 @@ class CyclicReferenceStack /** * Return the number of entries on the stack. - * - * @return int */ - public function count() + public function count(): int { return count($this->stack); } @@ -45,10 +43,8 @@ public function pop() * Test to see if a specified entry exists on the stack. * * @param mixed $value The value to test - * - * @return bool */ - public function onStack($value) + public function onStack($value): bool { return isset($this->stack[$value]); } diff --git a/src/PhpSpreadsheet/Calculation/Engine/Logger.php b/src/PhpSpreadsheet/Calculation/Engine/Logger.php index 256c3effb1..d65bd49f7e 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/Logger.php +++ b/src/PhpSpreadsheet/Calculation/Engine/Logger.php @@ -32,10 +32,8 @@ class Logger /** * The calculation engine cell reference stack. - * - * @var CyclicReferenceStack */ - private $cellStack; + private CyclicReferenceStack $cellStack; /** * Instantiate a Calculation engine logger. diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 2fcee2e02c..bf9f2f0c3a 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -240,10 +240,8 @@ public static function BINTOOCT($x, $places = null) * If places is not an integer, it is truncated. * If places is nonnumeric, DEC2BIN returns the #VALUE! error value. * If places is zero or negative, DEC2BIN returns the #NUM! error value. - * - * @return array|string */ - public static function DECTOBIN($x, $places = null) + public static function DECTOBIN($x, $places = null): string|array { return Engineering\ConvertDecimal::toBinary($x, $places); } @@ -276,10 +274,8 @@ public static function DECTOBIN($x, $places = null) * If places is not an integer, it is truncated. * If places is nonnumeric, DEC2HEX returns the #VALUE! error value. * If places is zero or negative, DEC2HEX returns the #NUM! error value. - * - * @return array|string */ - public static function DECTOHEX($x, $places = null) + public static function DECTOHEX($x, $places = null): string|array { return Engineering\ConvertDecimal::toHex($x, $places); } @@ -312,10 +308,8 @@ public static function DECTOHEX($x, $places = null) * If places is not an integer, it is truncated. * If places is nonnumeric, DEC2OCT returns the #VALUE! error value. * If places is zero or negative, DEC2OCT returns the #NUM! error value. - * - * @return array|string */ - public static function DECTOOCT($x, $places = null) + public static function DECTOOCT($x, $places = null): string|array { return Engineering\ConvertDecimal::toOctal($x, $places); } @@ -521,10 +515,8 @@ public static function OCTTODEC($x) * If places is not an integer, it is truncated. * If places is nonnumeric, OCT2HEX returns the #VALUE! error value. * If places is negative, OCT2HEX returns the #NUM! error value. - * - * @return array|string */ - public static function OCTTOHEX($x, $places = null) + public static function OCTTOHEX($x, $places = null): string|array { return Engineering\ConvertOctal::toHex($x, $places); } @@ -567,10 +559,8 @@ public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i * * @param string $complexNumber the complex number for which you want the imaginary * coefficient - * - * @return array|float|string */ - public static function IMAGINARY($complexNumber) + public static function IMAGINARY($complexNumber): string|float|array { return Engineering\Complex::IMAGINARY($complexNumber); } @@ -588,10 +578,8 @@ public static function IMAGINARY($complexNumber) * @see Engineering\Complex::IMREAL() * * @param string $complexNumber the complex number for which you want the real coefficient - * - * @return array|float|string */ - public static function IMREAL($complexNumber) + public static function IMREAL($complexNumber): string|float|array { return Engineering\Complex::IMREAL($complexNumber); } @@ -1054,10 +1042,8 @@ public static function IMSUB($complexNumber1, $complexNumber2) * @see ComplexOperations::IMSUM() * * @param string ...$complexNumbers Series of complex numbers to add - * - * @return string */ - public static function IMSUM(...$complexNumbers) + public static function IMSUM(...$complexNumbers): string { return ComplexOperations::IMSUM(...$complexNumbers); } @@ -1075,10 +1061,8 @@ public static function IMSUM(...$complexNumbers) * @see ComplexOperations::IMPRODUCT() * * @param string ...$complexNumbers Series of complex numbers to multiply - * - * @return string */ - public static function IMPRODUCT(...$complexNumbers) + public static function IMPRODUCT(...$complexNumbers): string { return ComplexOperations::IMPRODUCT(...$complexNumbers); } @@ -1262,10 +1246,8 @@ public static function BITRSHIFT($number, $shiftAmount) * @param float $lower lower bound for integrating ERF * @param float $upper upper bound for integrating ERF. * If omitted, ERF integrates between zero and lower_limit - * - * @return array|float|string */ - public static function ERF($lower, $upper = null) + public static function ERF($lower, $upper = null): float|string|array { return Engineering\Erf::ERF($lower, $upper); } @@ -1324,10 +1306,8 @@ public static function ERFC($x) * @deprecated 1.16.0 * Use the getConversionCategories() method in the Engineering\ConvertUOM class instead * @see Engineering\ConvertUOM::getConversionCategories() - * - * @return array */ - public static function getConversionGroups() + public static function getConversionGroups(): array { return Engineering\ConvertUOM::getConversionCategories(); } @@ -1341,10 +1321,8 @@ public static function getConversionGroups() * @see Engineering\ConvertUOM::getConversionCategoryUnits() * * @param null|mixed $category - * - * @return array */ - public static function getConversionGroupUnits($category = null) + public static function getConversionGroupUnits($category = null): array { return Engineering\ConvertUOM::getConversionCategoryUnits($category); } @@ -1357,10 +1335,8 @@ public static function getConversionGroupUnits($category = null) * @see Engineering\ConvertUOM::getConversionCategoryUnitDetails() * * @param null|mixed $category - * - * @return array */ - public static function getConversionGroupUnitDetails($category = null) + public static function getConversionGroupUnitDetails($category = null): array { return Engineering\ConvertUOM::getConversionCategoryUnitDetails($category); } diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php b/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php index 1134574e4f..c95e46e96f 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BesselI.php @@ -35,7 +35,7 @@ class BesselI * 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 BESSELI($x, $ord) + public static function BESSELI($x, $ord): array|string|float { if (is_array($x) || is_array($ord)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $ord); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php b/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php index 457c74d6ad..e49a1b4388 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php @@ -34,7 +34,7 @@ class BesselJ * 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 BESSELJ($x, $ord) + public static function BESSELJ($x, $ord): array|string|float { if (is_array($x) || is_array($ord)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $ord); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php b/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php index 9829f95245..9ae4aceb3e 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BesselK.php @@ -32,7 +32,7 @@ class BesselK * 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 BESSELK($x, $ord) + public static function BESSELK($x, $ord): array|string|float { if (is_array($x) || is_array($ord)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $ord); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php b/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php index 31d9694a70..52dc279313 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BesselY.php @@ -31,7 +31,7 @@ class BesselY * 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 BESSELY($x, $ord) + public static function BESSELY($x, $ord): array|string|float { if (is_array($x) || is_array($ord)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $ord); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php index fbf574dba8..db2013a12a 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php @@ -41,7 +41,7 @@ private static function splitNumber($number): array * 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 BITAND($number1, $number2) + public static function BITAND($number1, $number2): array|string|int { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -76,7 +76,7 @@ public static function BITAND($number1, $number2) * 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 BITOR($number1, $number2) + public static function BITOR($number1, $number2): array|string|int { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -112,7 +112,7 @@ public static function BITOR($number1, $number2) * 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 BITXOR($number1, $number2) + public static function BITXOR($number1, $number2): array|string|int { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -144,11 +144,11 @@ public static function BITXOR($number1, $number2) * @param array|int $shiftAmount * Or can be an array of values * - * @return array|float|int|string + * @return array|float|string * 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 BITLSHIFT($number, $shiftAmount) + public static function BITLSHIFT($number, $shiftAmount): array|string|float { if (is_array($number) || is_array($shiftAmount)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $shiftAmount); @@ -182,11 +182,11 @@ public static function BITLSHIFT($number, $shiftAmount) * @param array|int $shiftAmount * Or can be an array of values * - * @return array|float|int|string + * @return array|float|string * 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 BITRSHIFT($number, $shiftAmount) + public static function BITRSHIFT($number, $shiftAmount): array|string|float { if (is_array($number) || is_array($shiftAmount)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $shiftAmount); @@ -211,10 +211,8 @@ public static function BITRSHIFT($number, $shiftAmount) * Validate arguments passed to the bitwise functions. * * @param mixed $value - * - * @return float */ - private static function validateBitwiseArgument($value) + private static function validateBitwiseArgument($value): float { $value = self::nullFalseTrueToNumber($value); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Compare.php b/src/PhpSpreadsheet/Calculation/Engineering/Compare.php index 6aaf1faa5b..0a8c1f3b44 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Compare.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Compare.php @@ -29,7 +29,7 @@ class Compare * 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($a, $b = 0.0) + public static function DELTA($a, $b = 0.0): array|string|int { if (is_array($a) || is_array($b)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $a, $b); @@ -64,7 +64,7 @@ public static function DELTA($a, $b = 0.0) * 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($number, $step = 0.0) + public static function GESTEP($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/Complex.php b/src/PhpSpreadsheet/Calculation/Engineering/Complex.php index f7ec02d43c..58b4119445 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Complex.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Complex.php @@ -32,7 +32,7 @@ class Complex * 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 COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') + public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i'): array|string { if (is_array($realNumber) || is_array($imaginary) || is_array($suffix)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $realNumber, $imaginary, $suffix); @@ -74,7 +74,7 @@ public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i * 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 IMAGINARY($complexNumber) + public static function IMAGINARY($complexNumber): array|string|float { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -104,7 +104,7 @@ public static function IMAGINARY($complexNumber) * 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 IMREAL($complexNumber) + public static function IMREAL($complexNumber): array|string|float { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php b/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php index 28a27a0317..a7caa6b0b6 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php @@ -91,7 +91,7 @@ public static function IMARGUMENT($complexNumber) * 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 IMCONJUGATE($complexNumber) + public static function IMCONJUGATE($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -117,11 +117,11 @@ public static function IMCONJUGATE($complexNumber) * @param array|string $complexNumber the complex number for which you want the cosine * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMCOS($complexNumber) + public static function IMCOS($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -147,11 +147,11 @@ public static function IMCOS($complexNumber) * @param array|string $complexNumber the complex number for which you want the hyperbolic cosine * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMCOSH($complexNumber) + public static function IMCOSH($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -177,11 +177,11 @@ public static function IMCOSH($complexNumber) * @param array|string $complexNumber the complex number for which you want the cotangent * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMCOT($complexNumber) + public static function IMCOT($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -207,11 +207,11 @@ public static function IMCOT($complexNumber) * @param array|string $complexNumber the complex number for which you want the cosecant * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMCSC($complexNumber) + public static function IMCSC($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -237,11 +237,11 @@ public static function IMCSC($complexNumber) * @param array|string $complexNumber the complex number for which you want the hyperbolic cosecant * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMCSCH($complexNumber) + public static function IMCSCH($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -267,11 +267,11 @@ public static function IMCSCH($complexNumber) * @param array|string $complexNumber the complex number for which you want the sine * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMSIN($complexNumber) + public static function IMSIN($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -297,11 +297,11 @@ public static function IMSIN($complexNumber) * @param array|string $complexNumber the complex number for which you want the hyperbolic sine * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMSINH($complexNumber) + public static function IMSINH($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -327,11 +327,11 @@ public static function IMSINH($complexNumber) * @param array|string $complexNumber the complex number for which you want the secant * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMSEC($complexNumber) + public static function IMSEC($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -357,11 +357,11 @@ public static function IMSEC($complexNumber) * @param array|string $complexNumber the complex number for which you want the hyperbolic secant * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMSECH($complexNumber) + public static function IMSECH($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -387,11 +387,11 @@ public static function IMSECH($complexNumber) * @param array|string $complexNumber the complex number for which you want the tangent * Or can be an array of values * - * @return array|float|string + * @return array|string * 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 IMTAN($complexNumber) + public static function IMTAN($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -421,7 +421,7 @@ public static function IMTAN($complexNumber) * 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 IMSQRT($complexNumber) + public static function IMSQRT($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -456,7 +456,7 @@ public static function IMSQRT($complexNumber) * 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 IMLN($complexNumber) + public static function IMLN($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -490,7 +490,7 @@ public static function IMLN($complexNumber) * 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 IMLOG10($complexNumber) + public static function IMLOG10($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -524,7 +524,7 @@ public static function IMLOG10($complexNumber) * 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 IMLOG2($complexNumber) + public static function IMLOG2($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -558,7 +558,7 @@ public static function IMLOG2($complexNumber) * 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 IMEXP($complexNumber) + public static function IMEXP($complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -590,7 +590,7 @@ public static function IMEXP($complexNumber) * 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 IMPOWER($complexNumber, $realNumber) + public static function IMPOWER($complexNumber, $realNumber): array|string { if (is_array($complexNumber) || is_array($realNumber)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexNumber, $realNumber); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php b/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php index e525b4b9aa..79c62d0966 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php @@ -29,7 +29,7 @@ class ComplexOperations * 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 IMDIV($complexDividend, $complexDivisor) + public static function IMDIV($complexDividend, $complexDivisor): array|string { if (is_array($complexDividend) || is_array($complexDivisor)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexDividend, $complexDivisor); @@ -59,7 +59,7 @@ public static function IMDIV($complexDividend, $complexDivisor) * 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 IMSUB($complexNumber1, $complexNumber2) + public static function IMSUB($complexNumber1, $complexNumber2): array|string { if (is_array($complexNumber1) || is_array($complexNumber2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexNumber1, $complexNumber2); @@ -81,10 +81,8 @@ public static function IMSUB($complexNumber1, $complexNumber2) * IMSUM(complexNumber[,complexNumber[,...]]) * * @param string ...$complexNumbers Series of complex numbers to add - * - * @return string */ - public static function IMSUM(...$complexNumbers) + public static function IMSUM(...$complexNumbers): string { // Return value $returnValue = new ComplexObject(0.0); @@ -111,10 +109,8 @@ public static function IMSUM(...$complexNumbers) * IMPRODUCT(complexNumber[,complexNumber[,...]]) * * @param string ...$complexNumbers Series of complex numbers to multiply - * - * @return string */ - public static function IMPRODUCT(...$complexNumbers) + public static function IMPRODUCT(...$complexNumbers): string { // Return value $returnValue = new ComplexObject(1.0); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php index 04bf3e5060..f21b4d5a3e 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertBinary.php @@ -77,7 +77,7 @@ public static function toDecimal($value) * 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 toHex($value, $places = null) + public static function toHex($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); @@ -130,7 +130,7 @@ public static function toHex($value, $places = null) * 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 toOctal($value, $places = null) + public static function toOctal($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php index 9b59d3995f..14ee68795f 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertDecimal.php @@ -45,7 +45,7 @@ class ConvertDecimal extends ConvertBase * 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 toBinary($value, $places = null) + public static function toBinary($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); @@ -102,7 +102,7 @@ public static function toBinary($value, $places = null) * 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 toHex($value, $places = null) + public static function toHex($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); @@ -178,7 +178,7 @@ public static function hex32bit(float $value, string $hexstr, bool $force = fals * 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 toOctal($value, $places = null) + public static function toOctal($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php index 55ce209ecd..9d39acfbce 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertHex.php @@ -38,7 +38,7 @@ class ConvertHex extends ConvertBase * 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 toBinary($value, $places = null) + public static function toBinary($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); @@ -145,7 +145,7 @@ public static function toDecimal($value) * 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 toOctal($value, $places = null) + public static function toOctal($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php index add7aba01b..8436a63ef6 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertOctal.php @@ -44,7 +44,7 @@ class ConvertOctal extends ConvertBase * 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 toBinary($value, $places = null) + public static function toBinary($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); @@ -142,7 +142,7 @@ public static function toDecimal($value) * 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 toHex($value, $places = null) + public static function toHex($value, $places = null): array|string { if (is_array($value) || is_array($places)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $places); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php index 32ef9d3c77..87ea44881d 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php @@ -435,10 +435,8 @@ class ConvertUOM /** * getConversionGroups * Returns a list of the different conversion groups for UOM conversions. - * - * @return array */ - public static function getConversionCategories() + public static function getConversionCategories(): array { $conversionGroups = []; foreach (self::$conversionUnits as $conversionUnit) { @@ -453,10 +451,8 @@ public static function getConversionCategories() * Returns an array of units of measure, for a specified conversion group, or for all groups. * * @param string $category The group whose units of measure you want to retrieve - * - * @return array */ - public static function getConversionCategoryUnits($category = null) + public static function getConversionCategoryUnits($category = null): array { $conversionGroups = []; foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) { @@ -472,10 +468,8 @@ public static function getConversionCategoryUnits($category = null) * getConversionGroupUnitDetails. * * @param string $category The group whose units of measure you want to retrieve - * - * @return array */ - public static function getConversionCategoryUnitDetails($category = null) + public static function getConversionCategoryUnitDetails($category = null): array { $conversionGroups = []; foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) { diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Erf.php b/src/PhpSpreadsheet/Calculation/Engineering/Erf.php index dfd473db03..7df276b241 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Erf.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Erf.php @@ -35,7 +35,7 @@ class Erf * 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 ERF($lower, $upper = null) + public static function ERF($lower, $upper = null): array|float|string { if (is_array($lower) || is_array($upper)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $lower, $upper); @@ -87,10 +87,8 @@ private static function makeFloat($value): float * Method to calculate the erf value. * * @param float|int|string $value - * - * @return float */ - public static function erfValue($value) + public static function erfValue($value): float { $value = (float) $value; if (abs($value) > 2.2) { diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php b/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php index 0350c9c640..4c2d461eef 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php @@ -52,7 +52,7 @@ public static function ERFC($value) * * @return float */ - private static function erfcValue($value) + private static function erfcValue($value): float|int { $value = (float) $value; if (abs($value) < 2.2) { diff --git a/src/PhpSpreadsheet/Calculation/Exception.php b/src/PhpSpreadsheet/Calculation/Exception.php index a95a452d07..ea893d6986 100644 --- a/src/PhpSpreadsheet/Calculation/Exception.php +++ b/src/PhpSpreadsheet/Calculation/Exception.php @@ -10,14 +10,8 @@ class Exception extends PhpSpreadsheetException /** * Error handler callback. - * - * @param mixed $code - * @param mixed $string - * @param mixed $file - * @param mixed $line - * @param mixed $context */ - public static function errorHandlerCallback($code, $string, $file, $line, /** @scrutinizer ignore-unused */ $context): void + public static function errorHandlerCallback(int $code, string $string, string $file, int $line): void { $e = new self($string, $code); $e->line = $line; diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index dcca5f8802..d447f84040 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -319,10 +319,9 @@ public static function COUPDAYSNC($settlement, $maturity, $frequency, $basis = 0 * 3 Actual/365 * 4 European 30/360 * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag + * @return float|string Excel date/time serial value or error message */ - public static function COUPNCD($settlement, $maturity, $frequency, $basis = 0) + public static function COUPNCD($settlement, $maturity, $frequency, $basis = 0): string|float { return Coupons::COUPNCD($settlement, $maturity, $frequency, $basis); } @@ -393,10 +392,9 @@ public static function COUPNUM($settlement, $maturity, $frequency, $basis = 0) * 3 Actual/365 * 4 European 30/360 * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag + * @return float|string Excel date/time serial value or error message */ - public static function COUPPCD($settlement, $maturity, $frequency, $basis = 0) + public static function COUPPCD($settlement, $maturity, $frequency, $basis = 0): string|float { return Coupons::COUPPCD($settlement, $maturity, $frequency, $basis); } @@ -573,10 +571,8 @@ public static function DISC($settlement, $maturity, $price, $redemption, $basis * * @param array|float $fractional_dollar Fractional Dollar * @param array|int $fraction Fraction - * - * @return array|float|string */ - public static function DOLLARDE($fractional_dollar = null, $fraction = 0) + public static function DOLLARDE($fractional_dollar = null, $fraction = 0): string|float|array { return Dollar::decimal($fractional_dollar, $fraction); } @@ -597,10 +593,8 @@ public static function DOLLARDE($fractional_dollar = null, $fraction = 0) * * @param array|float $decimal_dollar Decimal Dollar * @param array|int $fraction Fraction - * - * @return array|float|string */ - public static function DOLLARFR($decimal_dollar = null, $fraction = 0) + public static function DOLLARFR($decimal_dollar = null, $fraction = 0): string|float|array { return Dollar::fractional($decimal_dollar, $fraction); } @@ -620,10 +614,8 @@ public static function DOLLARFR($decimal_dollar = null, $fraction = 0) * * @param float $nominalRate Nominal interest rate * @param int $periodsPerYear Number of compounding payments per year - * - * @return float|string */ - public static function EFFECT($nominalRate = 0, $periodsPerYear = 0) + public static function EFFECT($nominalRate = 0, $periodsPerYear = 0): string|float { return Financial\InterestRate::effective($nominalRate, $periodsPerYear); } @@ -650,10 +642,8 @@ public static function EFFECT($nominalRate = 0, $periodsPerYear = 0) * @param int $type A number 0 or 1 and indicates when payments are due: * 0 or omitted At the end of the period. * 1 At the beginning of the period. - * - * @return float|string */ - public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0) + public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0): string|float { return Financial\CashFlow\Constant\Periodic::futureValue($rate, $nper, $pmt, $pv, $type); } @@ -733,10 +723,8 @@ public static function INTRATE($settlement, $maturity, $investment, $redemption, * @param float $pv Present Value * @param float $fv Future Value * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period - * - * @return float|string */ - public static function IPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) + public static function IPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0): string|float { return Financial\CashFlow\Constant\Periodic\Interest::payment($rate, $per, $nper, $pv, $fv, $type); } @@ -842,7 +830,7 @@ public static function MIRR($values, $finance_rate, $reinvestment_rate) * * @return float|string Result, or a string containing an error */ - public static function NOMINAL($effectiveRate = 0, $periodsPerYear = 0) + public static function NOMINAL($effectiveRate = 0, $periodsPerYear = 0): string|float { return InterestRate::nominal($effectiveRate, $periodsPerYear); } @@ -948,7 +936,7 @@ public static function PMT($rate = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0) * * @return float|string Result, or a string containing an error */ - public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) + public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0): string|float { return Financial\CashFlow\Constant\Periodic\Payments::interestPayment($rate, $per, $nper, $pv, $fv, $type); } @@ -983,7 +971,7 @@ public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0) * * @return float|string Result, or a string containing an error */ - public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis = 0) + public static function PRICE($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis = 0): string|float { return Securities\Price::price($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis); } @@ -1066,7 +1054,7 @@ public static function PRICEMAT($settlement, $maturity, $issue, $rate, $yield, $ * * @return float|string Result, or a string containing an error */ - public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0) + public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0): string|float { return Financial\CashFlow\Constant\Periodic::presentValue($rate, $nper, $pmt, $fv, $type); } @@ -1218,7 +1206,7 @@ public static function SYD($cost, $salvage, $life, $period) * * @return float|string Result, or a string containing an error */ - public static function TBILLEQ($settlement, $maturity, $discount) + public static function TBILLEQ($settlement, $maturity, $discount): string|float { return TreasuryBill::bondEquivalentYield($settlement, $maturity, $discount); } @@ -1241,7 +1229,7 @@ public static function TBILLEQ($settlement, $maturity, $discount) * * @return float|string Result, or a string containing an error */ - public static function TBILLPRICE($settlement, $maturity, $discount) + public static function TBILLPRICE($settlement, $maturity, $discount): string|float { return TreasuryBill::price($settlement, $maturity, $discount); } @@ -1261,10 +1249,8 @@ public static function TBILLPRICE($settlement, $maturity, $discount) * @param mixed $maturity The Treasury bill's maturity date. * The maturity date is the date when the Treasury bill expires. * @param mixed $price The Treasury bill's price per $100 face value - * - * @return float|mixed|string */ - public static function TBILLYIELD($settlement, $maturity, $price) + public static function TBILLYIELD($settlement, $maturity, $price): string|float { return TreasuryBill::yield($settlement, $maturity, $price); } @@ -1290,7 +1276,7 @@ public static function TBILLYIELD($settlement, $maturity, $price) * * @return float|mixed|string */ - public static function XIRR($values, $dates, $guess = 0.1) + public static function XIRR(array $values, array $dates, $guess = 0.1) { return Financial\CashFlow\Variable\NonPeriodic::rate($values, $dates, $guess); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Amortization.php b/src/PhpSpreadsheet/Calculation/Financial/Amortization.php index 72a71b295e..37a9746cb8 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Amortization.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Amortization.php @@ -47,7 +47,7 @@ public static function AMORDEGRC( $period, $rate, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|float { $cost = Functions::flattenSingleValue($cost); $purchased = Functions::flattenSingleValue($purchased); $firstPeriod = Functions::flattenSingleValue($firstPeriod); @@ -136,7 +136,7 @@ public static function AMORLINC( $period, $rate, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|float { $cost = Functions::flattenSingleValue($cost); $purchased = Functions::flattenSingleValue($purchased); $firstPeriod = Functions::flattenSingleValue($firstPeriod); diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php index a19c37f60f..746dd317ee 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic.php @@ -28,8 +28,6 @@ class Periodic * @param mixed $type A number 0 or 1 and indicates when payments are due: * 0 or omitted At the end of the period. * 1 At the beginning of the period. - * - * @return float|string */ public static function futureValue( $rate, @@ -37,7 +35,7 @@ public static function futureValue( $payment = 0.0, $presentValue = 0.0, $type = FinancialConstants::PAYMENT_END_OF_PERIOD - ) { + ): string|float { $rate = Functions::flattenSingleValue($rate); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $payment = ($payment === null) ? 0.0 : Functions::flattenSingleValue($payment); @@ -76,7 +74,7 @@ public static function presentValue( $payment = 0.0, $futureValue = 0.0, $type = FinancialConstants::PAYMENT_END_OF_PERIOD - ) { + ): string|float { $rate = Functions::flattenSingleValue($rate); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $payment = ($payment === null) ? 0.0 : Functions::flattenSingleValue($payment); @@ -176,16 +174,13 @@ private static function calculatePresentValue( return -$futureValue - $payment * $numberOfPeriods; } - /** - * @return float|string - */ private static function calculatePeriods( float $rate, float $payment, float $presentValue, float $futureValue, int $type - ) { + ): string|float { if ($rate != 0.0) { if ($presentValue == 0.0) { return ExcelError::NAN(); diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php index b7aaffd82c..e8b9435a4c 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php @@ -37,7 +37,7 @@ public static function interest( $start, $end, $type = FinancialConstants::PAYMENT_END_OF_PERIOD - ) { + ): string|float|int { $rate = Functions::flattenSingleValue($rate); $periods = Functions::flattenSingleValue($periods); $presentValue = Functions::flattenSingleValue($presentValue); @@ -102,7 +102,7 @@ public static function principal( $start, $end, $type = FinancialConstants::PAYMENT_END_OF_PERIOD - ) { + ): string|float|int { $rate = Functions::flattenSingleValue($rate); $periods = Functions::flattenSingleValue($periods); $presentValue = Functions::flattenSingleValue($presentValue); diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php index caec74fc51..17173169cc 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Interest.php @@ -29,8 +29,6 @@ class Interest * @param mixed $presentValue Present Value * @param mixed $futureValue Future Value * @param mixed $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period - * - * @return float|string */ public static function payment( $interestRate, @@ -39,7 +37,7 @@ public static function payment( $presentValue, $futureValue = 0, $type = FinancialConstants::PAYMENT_END_OF_PERIOD - ) { + ): string|float { $interestRate = Functions::flattenSingleValue($interestRate); $period = Functions::flattenSingleValue($period); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); @@ -88,10 +86,8 @@ public static function payment( * @param mixed $period is the period to calculate the interest rate. It must be betweeen 1 and number_payments. * @param mixed $numberOfPeriods is the number of payments for the annuity * @param mixed $principleRemaining is the loan amount or present value of the payments - * - * @return float|string */ - public static function schedulePayment($interestRate, $period, $numberOfPeriods, $principleRemaining) + public static function schedulePayment($interestRate, $period, $numberOfPeriods, $principleRemaining): string|float { $interestRate = Functions::flattenSingleValue($interestRate); $period = Functions::flattenSingleValue($period); @@ -152,8 +148,6 @@ public static function schedulePayment($interestRate, $period, $numberOfPeriods, * 1 At the beginning of the period. * @param mixed $guess Your guess for what the rate will be. * If you omit guess, it is assumed to be 10 percent. - * - * @return float|string */ public static function rate( $numberOfPeriods, @@ -162,7 +156,7 @@ public static function rate( $futureValue = 0.0, $type = FinancialConstants::PAYMENT_END_OF_PERIOD, $guess = 0.1 - ) { + ): string|float { $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $payment = Functions::flattenSingleValue($payment); $presentValue = Functions::flattenSingleValue($presentValue); @@ -199,8 +193,7 @@ public static function rate( return $close ? $rate : ExcelError::NAN(); } - /** @return float|string */ - private static function rateNextGuess(float $rate, int $numberOfPeriods, float $payment, float $presentValue, float $futureValue, int $type) + private static function rateNextGuess(float $rate, int $numberOfPeriods, float $payment, float $presentValue, float $futureValue, int $type): string|float { if ($rate == 0.0) { return ExcelError::NAN(); diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php index 1408d465a9..ea9abb9828 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/InterestAndPrincipal.php @@ -6,11 +6,9 @@ class InterestAndPrincipal { - /** @var float */ - protected $interest; + protected float $interest; - /** @var float */ - protected $principal; + protected float $principal; public function __construct( float $rate = 0.0, diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php index 83965f9d3b..04284f4552 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Payments.php @@ -29,7 +29,7 @@ public static function annuity( $presentValue, $futureValue = 0, $type = FinancialConstants::PAYMENT_END_OF_PERIOD - ) { + ): string|float { $interestRate = Functions::flattenSingleValue($interestRate); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); $presentValue = Functions::flattenSingleValue($presentValue); @@ -77,7 +77,7 @@ public static function interestPayment( $presentValue, $futureValue = 0, $type = FinancialConstants::PAYMENT_END_OF_PERIOD - ) { + ): string|float { $interestRate = Functions::flattenSingleValue($interestRate); $period = Functions::flattenSingleValue($period); $numberOfPeriods = Functions::flattenSingleValue($numberOfPeriods); diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php index 058e89c64e..30a152208f 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php @@ -19,10 +19,8 @@ class Single * * @param mixed $principal the present value * @param float[] $schedule an array of interest rates to apply - * - * @return float|string */ - public static function futureValue($principal, $schedule) + public static function futureValue($principal, $schedule): string|float { $principal = Functions::flattenSingleValue($principal); $schedule = Functions::flattenArray($schedule); @@ -52,7 +50,7 @@ public static function futureValue($principal, $schedule) * * @return float|string Result, or a string containing an error */ - public static function periods($rate, $presentValue, $futureValue) + public static function periods($rate, $presentValue, $futureValue): string|float { $rate = Functions::flattenSingleValue($rate); $presentValue = Functions::flattenSingleValue($presentValue); @@ -85,7 +83,7 @@ public static function periods($rate, $presentValue, $futureValue) * * @return float|string Result, or a string containing an error */ - public static function interestRate($periods = 0.0, $presentValue = 0.0, $futureValue = 0.0) + public static function interestRate($periods = 0.0, $presentValue = 0.0, $futureValue = 0.0): string|float { $periods = Functions::flattenSingleValue($periods); $presentValue = Functions::flattenSingleValue($presentValue); diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php index b4247b704f..4d6819eb13 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php @@ -32,7 +32,7 @@ class NonPeriodic * * @return float|string */ - public static function rate($values, $dates, $guess = self::DEFAULT_GUESS) + public static function rate(array $values, array $dates, $guess = self::DEFAULT_GUESS) { $rslt = self::xirrPart1($values, $dates); if ($rslt !== '') { @@ -182,10 +182,7 @@ private static function xirrPart2(array &$values): string return ''; } - /** - * @return float|string - */ - private static function xirrPart3(array $values, array $dates, float $x1, float $x2) + private static function xirrPart3(array $values, array $dates, float $x1, float $x2): float|string { $f = self::xnpvOrdered($x1, $values, $dates, false); if ($f < 0.0) { @@ -214,10 +211,7 @@ private static function xirrPart3(array $values, array $dates, float $x1, float return $rslt; } - /** - * @return float|string - */ - private static function xirrBisection(array $values, array $dates, float $x1, float $x2) + private static function xirrBisection(array $values, array $dates, float $x1, float $x2): string|float { $rslt = ExcelError::NAN(); for ($i = 0; $i < self::FINANCIAL_MAX_ITERATIONS; ++$i) { diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php index d899e8441e..c4afaf5ead 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php @@ -28,10 +28,8 @@ class Periodic * Values must contain at least one positive value and one negative value to * calculate the internal rate of return. * @param mixed $guess A number that you guess is close to the result of IRR - * - * @return float|string */ - public static function rate($values, $guess = 0.1) + public static function rate($values, $guess = 0.1): string|float { if (!is_array($values)) { return ExcelError::VALUE(); @@ -99,7 +97,7 @@ public static function rate($values, $guess = 0.1) * * @return float|string Result, or a string containing an error */ - public static function modifiedRate($values, $financeRate, $reinvestmentRate) + public static function modifiedRate($values, $financeRate, $reinvestmentRate): string|float { if (!is_array($values)) { return ExcelError::DIV0(); @@ -148,7 +146,7 @@ public static function modifiedRate($values, $financeRate, $reinvestmentRate) * * @return float */ - public static function presentValue($rate, ...$args) + public static function presentValue($rate, ...$args): int|float { $returnValue = 0; diff --git a/src/PhpSpreadsheet/Calculation/Financial/Coupons.php b/src/PhpSpreadsheet/Calculation/Financial/Coupons.php index 4028cd4740..88b0429370 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Coupons.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Coupons.php @@ -47,7 +47,7 @@ public static function COUPDAYBS( $maturity, $frequency, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|int|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); @@ -110,7 +110,7 @@ public static function COUPDAYS( $maturity, $frequency, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|int|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); @@ -173,15 +173,13 @@ public static function COUPDAYS( * 2 Actual/360 * 3 Actual/365 * 4 European 30/360 - * - * @return float|string */ public static function COUPDAYSNC( $settlement, $maturity, $frequency, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); @@ -239,15 +237,14 @@ public static function COUPDAYSNC( * 3 Actual/365 * 4 European 30/360 * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag + * @return float|string Excel date/time serial value or error message */ public static function COUPNCD( $settlement, $maturity, $frequency, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); @@ -294,15 +291,13 @@ public static function COUPNCD( * 2 Actual/360 * 3 Actual/365 * 4 European 30/360 - * - * @return int|string */ public static function COUPNUM( $settlement, $maturity, $frequency, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|int { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); @@ -355,15 +350,14 @@ public static function COUPNUM( * 3 Actual/365 * 4 European 30/360 * - * @return mixed Excel date/time serial value, PHP date/time serial value or PHP date/time object, - * depending on the value of the ReturnDateType flag + * @return float|string Excel date/time serial value or error message */ public static function COUPPCD( $settlement, $maturity, $frequency, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $frequency = Functions::flattenSingleValue($frequency); diff --git a/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php b/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php index e542a869ed..f987563a33 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php @@ -36,7 +36,7 @@ class Depreciation * * @return float|string */ - public static function DB($cost, $salvage, $life, $period, $month = 12) + public static function DB($cost, $salvage, $life, $period, $month = 12): string|float|int { $cost = Functions::flattenSingleValue($cost); $salvage = Functions::flattenSingleValue($salvage); @@ -150,7 +150,7 @@ public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) * * @return float|string Result, or a string containing an error */ - public static function SLN($cost, $salvage, $life) + public static function SLN($cost, $salvage, $life): string|float { $cost = Functions::flattenSingleValue($cost); $salvage = Functions::flattenSingleValue($salvage); @@ -183,7 +183,7 @@ public static function SLN($cost, $salvage, $life) * * @return float|string Result, or a string containing an error */ - public static function SYD($cost, $salvage, $life, $period) + public static function SYD($cost, $salvage, $life, $period): string|float { $cost = Functions::flattenSingleValue($cost); $salvage = Functions::flattenSingleValue($salvage); diff --git a/src/PhpSpreadsheet/Calculation/Financial/Dollar.php b/src/PhpSpreadsheet/Calculation/Financial/Dollar.php index b1f0d25c7b..0ae9d9f231 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Dollar.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Dollar.php @@ -48,10 +48,8 @@ public static function format($number, $precision = 2) * Or can be an array of values * @param mixed $fraction Fraction * Or can be an array of values - * - * @return array|float|string */ - public static function decimal($fractionalDollar = null, $fraction = 0) + public static function decimal($fractionalDollar = null, $fraction = 0): array|string|float { if (is_array($fractionalDollar) || is_array($fraction)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $fractionalDollar, $fraction); @@ -96,10 +94,8 @@ public static function decimal($fractionalDollar = null, $fraction = 0) * Or can be an array of values * @param mixed $fraction Fraction * Or can be an array of values - * - * @return array|float|string */ - public static function fractional($decimalDollar = null, $fraction = 0) + public static function fractional($decimalDollar = null, $fraction = 0): array|string|float { if (is_array($decimalDollar) || is_array($fraction)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $decimalDollar, $fraction); diff --git a/src/PhpSpreadsheet/Calculation/Financial/Helpers.php b/src/PhpSpreadsheet/Calculation/Financial/Helpers.php index c7f1f46a27..aa2871295a 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Helpers.php @@ -24,7 +24,7 @@ class Helpers * * @return int|string Result, or a string containing an error */ - public static function daysPerYear($year, $basis = 0) + public static function daysPerYear($year, $basis = 0): string|int { if (!is_numeric($basis)) { return ExcelError::NAN(); diff --git a/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php b/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php index 1cbe2657b5..eb48059a33 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php +++ b/src/PhpSpreadsheet/Calculation/Financial/InterestRate.php @@ -19,10 +19,8 @@ class InterestRate * * @param mixed $nominalRate Nominal interest rate as a float * @param mixed $periodsPerYear Integer number of compounding payments per year - * - * @return float|string */ - public static function effective($nominalRate = 0, $periodsPerYear = 0) + public static function effective($nominalRate = 0, $periodsPerYear = 0): string|float { $nominalRate = Functions::flattenSingleValue($nominalRate); $periodsPerYear = Functions::flattenSingleValue($periodsPerYear); @@ -51,7 +49,7 @@ public static function effective($nominalRate = 0, $periodsPerYear = 0) * * @return float|string Result, or a string containing an error */ - public static function nominal($effectiveRate = 0, $periodsPerYear = 0) + public static function nominal($effectiveRate = 0, $periodsPerYear = 0): string|float { $effectiveRate = Functions::flattenSingleValue($effectiveRate); $periodsPerYear = Functions::flattenSingleValue($periodsPerYear); diff --git a/src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php b/src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php index 22c93c0e22..7490da141c 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Securities/Price.php @@ -46,7 +46,7 @@ public static function price( $redemption, $frequency, $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): string|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $rate = Functions::flattenSingleValue($rate); diff --git a/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php b/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php index 7ee34f7324..c90b5225d6 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php +++ b/src/PhpSpreadsheet/Calculation/Financial/TreasuryBill.php @@ -24,7 +24,7 @@ class TreasuryBill * * @return float|string Result, or a string containing an error */ - public static function bondEquivalentYield($settlement, $maturity, $discount) + public static function bondEquivalentYield($settlement, $maturity, $discount): string|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); @@ -69,7 +69,7 @@ public static function bondEquivalentYield($settlement, $maturity, $discount) * * @return float|string Result, or a string containing an error */ - public static function price($settlement, $maturity, $discount) + public static function price($settlement, $maturity, $discount): string|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); @@ -115,11 +115,9 @@ public static function price($settlement, $maturity, $discount) * the Treasury bill is traded to the buyer. * @param mixed $maturity The Treasury bill's maturity date. * The maturity date is the date when the Treasury bill expires. - * @param mixed $price The Treasury bill's price per $100 face value - * - * @return float|string + * @param float|string $price The Treasury bill's price per $100 face value */ - public static function yield($settlement, $maturity, $price) + public static function yield($settlement, $maturity, $price): string|float { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index 14c5ae50a6..4cb4d44c36 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -46,10 +46,8 @@ class FormulaParser /** * Formula. - * - * @var string */ - private $formula; + private string $formula; /** * Tokens. @@ -102,10 +100,8 @@ public function getToken(int $id = 0): FormulaToken /** * Get Token count. - * - * @return int */ - public function getTokenCount() + public function getTokenCount(): int { return count($this->tokens); } diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index a645d790a4..5a57d7bed3 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -51,7 +51,7 @@ class Functions * * @return bool (Success or Failure) */ - public static function setCompatibilityMode($compatibilityMode) + public static function setCompatibilityMode($compatibilityMode): bool { if ( ($compatibilityMode == self::COMPATIBILITY_EXCEL) || @@ -91,7 +91,7 @@ public static function getCompatibilityMode() * * @return bool Success or failure */ - public static function setReturnDateType($returnDateType) + public static function setReturnDateType($returnDateType): bool { if ( ($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) || @@ -125,7 +125,7 @@ public static function getReturnDateType() * * @return string #Not Yet Implemented */ - public static function DUMMY() + public static function DUMMY(): string { return '#Not Yet Implemented'; } @@ -220,7 +220,7 @@ private static function operandSpecialHandling($operand) * * @return string #NULL! */ - public static function null() + public static function null(): string { return Information\ExcelError::null(); } @@ -235,7 +235,7 @@ public static function null() * * @return string #NUM! */ - public static function NAN() + public static function NAN(): string { return Information\ExcelError::NAN(); } @@ -250,7 +250,7 @@ public static function NAN() * * @return string #REF! */ - public static function REF() + public static function REF(): string { return Information\ExcelError::REF(); } @@ -269,7 +269,7 @@ public static function REF() * * @return string #N/A! */ - public static function NA() + public static function NA(): string { return Information\ExcelError::NA(); } @@ -284,7 +284,7 @@ public static function NA() * * @return string #VALUE! */ - public static function VALUE() + public static function VALUE(): string { return Information\ExcelError::VALUE(); } @@ -299,7 +299,7 @@ public static function VALUE() * * @return string #NAME? */ - public static function NAME() + public static function NAME(): string { return Information\ExcelError::NAME(); } @@ -312,7 +312,7 @@ public static function NAME() * * @return string #Not Yet Implemented */ - public static function DIV0() + public static function DIV0(): string { return Information\ExcelError::DIV0(); } @@ -444,10 +444,8 @@ public static function isNumber($value = null) * * @deprecated 1.23.0 Use the isLogical() method in the Information\Value class instead * @see Information\Value::isLogical() - * - * @return array|bool */ - public static function isLogical($value = null) + public static function isLogical($value = null): bool|array { return Information\Value::isLogical($value); } @@ -516,7 +514,7 @@ public static function n($value = null) * * @param null|mixed $value The value you want tested * - * @return number N converts values listed in the following table + * @return int N converts values listed in the following table * If value is or refers to N returns * A number 1 * Text 2 @@ -524,7 +522,7 @@ public static function n($value = null) * An error value 16 * Array or Matrix 64 */ - public static function TYPE($value = null) + public static function TYPE($value = null): int { return Information\Value::type($value); } @@ -536,7 +534,7 @@ public static function TYPE($value = null) * * @return array Flattened array */ - public static function flattenArray($array) + public static function flattenArray($array): array { if (!is_array($array)) { return (array) $array; diff --git a/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php b/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php index 4b9f818fe5..c247edc86c 100644 --- a/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php +++ b/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php @@ -18,7 +18,7 @@ class ErrorValue * 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 isErr($value = '') + public static function isErr($value = ''): array|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -37,7 +37,7 @@ public static function isErr($value = '') * 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 isError($value = '') + public static function isError($value = ''): array|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -60,7 +60,7 @@ public static function isError($value = '') * 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 isNa($value = '') + public static function isNa($value = ''): array|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); diff --git a/src/PhpSpreadsheet/Calculation/Information/ExcelError.php b/src/PhpSpreadsheet/Calculation/Information/ExcelError.php index 06f386635c..22ae025c7d 100644 --- a/src/PhpSpreadsheet/Calculation/Information/ExcelError.php +++ b/src/PhpSpreadsheet/Calculation/Information/ExcelError.php @@ -53,10 +53,8 @@ public static function throwError($value): string * ERROR_TYPE. * * @param mixed $value Value to check - * - * @return array|int|string */ - public static function type($value = '') + public static function type($value = ''): array|int|string { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); diff --git a/src/PhpSpreadsheet/Calculation/Information/Value.php b/src/PhpSpreadsheet/Calculation/Information/Value.php index 341d93b984..5c35849b07 100644 --- a/src/PhpSpreadsheet/Calculation/Information/Value.php +++ b/src/PhpSpreadsheet/Calculation/Information/Value.php @@ -24,7 +24,7 @@ class Value * 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 isBlank($value = null) + public static function isBlank($value = null): array|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -37,10 +37,8 @@ public static function isBlank($value = null) * IS_REF. * * @param mixed $value Value to check - * - * @return bool */ - public static function isRef($value, ?Cell $cell = null) + public static function isRef($value, ?Cell $cell = null): bool { if ($cell === null || $value === $cell->getCoordinate()) { return false; @@ -52,7 +50,7 @@ public static function isRef($value, ?Cell $cell = null) if (!empty($worksheet) && $cell->getWorksheet()->getParentOrThrow()->getSheetByName($worksheet) === null) { return false; } - [$column, $row] = Coordinate::indexesFromString($cellValue); + [$column, $row] = Coordinate::indexesFromString($cellValue ?? ''); if ($column > 16384 || $row > 1048576) { return false; } @@ -75,7 +73,7 @@ public static function isRef($value, ?Cell $cell = null) * 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 isEven($value = null) + public static function isEven($value = null): array|string|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -100,7 +98,7 @@ public static function isEven($value = null) * 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 isOdd($value = null) + public static function isOdd($value = null): array|string|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -125,7 +123,7 @@ public static function isOdd($value = null) * 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 isNumber($value = null) + public static function isNumber($value = null): array|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -148,7 +146,7 @@ public static function isNumber($value = null) * 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 isLogical($value = null) + public static function isLogical($value = null): array|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -167,7 +165,7 @@ public static function isLogical($value = null) * 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 isText($value = null) + public static function isText($value = null): array|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -186,7 +184,7 @@ public static function isText($value = null) * 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 isNonText($value = null) + public static function isNonText($value = null): array|bool { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -281,7 +279,7 @@ public static function asNumber($value = null) * * @param null|mixed $value The value you want tested * - * @return number N converts values listed in the following table + * @return int N converts values listed in the following table * If value is or refers to N returns * A number 1 * Text 2 @@ -289,7 +287,7 @@ public static function asNumber($value = null) * An error value 16 * Array or Matrix 64 */ - public static function type($value = null) + public static function type($value = null): int { $value = Functions::flattenArrayIndexed($value); if (is_array($value) && (count($value) > 1)) { diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php index 92e779e06f..e640307a67 100644 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ b/src/PhpSpreadsheet/Calculation/Logical.php @@ -159,7 +159,7 @@ public static function logicalXor(...$args) * * @return array|bool|string the boolean inverse of the argument */ - public static function NOT($logical = false) + public static function NOT($logical = false): bool|string|array { return Logical\Operations::NOT($logical); } diff --git a/src/PhpSpreadsheet/Calculation/Logical/Operations.php b/src/PhpSpreadsheet/Calculation/Logical/Operations.php index f09785919c..3c9f459aa2 100644 --- a/src/PhpSpreadsheet/Calculation/Logical/Operations.php +++ b/src/PhpSpreadsheet/Calculation/Logical/Operations.php @@ -116,7 +116,7 @@ public static function logicalXor(...$args) * If an array of values is passed as an argument, then the returned result will also be an array * with the same dimensions */ - public static function NOT($logical = false) + public static function NOT($logical = false): array|bool|string { if (is_array($logical)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $logical); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index ce4db4d7ca..e61aefdcc3 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -40,10 +40,8 @@ class LookupRef * TRUE or omitted CELL_ADDRESS returns an A1-style reference * FALSE CELL_ADDRESS returns an R1C1-style reference * @param array|string $sheetText Optional Name of worksheet to use - * - * @return array|string */ - public static function cellAddress($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = '') + public static function cellAddress($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = ''): string|array { return Address::cell($row, $column, $relativity, $referenceStyle, $sheetText); } @@ -268,9 +266,9 @@ public static function CHOOSE(...$chooseArgs) * @param mixed $matchType The number -1, 0, or 1. -1 means above, 0 means exact match, 1 means below. * If match_type is 1 or -1, the list has to be ordered. * - * @return array|int|string The relative position of the found item + * @return array|float|int|string The relative position of the found item */ - public static function MATCH($lookupValue, $lookupArray, $matchType = 1) + public static function MATCH($lookupValue, $lookupArray, $matchType = 1): array|float|int|string { return LookupRef\ExcelMatch::MATCH($lookupValue, $lookupArray, $matchType); } @@ -314,7 +312,7 @@ public static function INDEX($matrix, $rowNum = 0, $columnNum = 0) * Unlike the Excel TRANSPOSE function, which will only work on a single row or column, * this function will transpose a full matrix */ - public static function TRANSPOSE($matrixData) + public static function TRANSPOSE($matrixData): array { return Matrix::transpose($matrixData); } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Address.php b/src/PhpSpreadsheet/Calculation/LookupRef/Address.php index 1a0035d59b..28811f7e69 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Address.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Address.php @@ -48,7 +48,7 @@ class Address * If an array of values is passed as the $testValue argument, then the returned result will also be * an array with the same dimensions */ - public static function cell($row, $column, $relativity = 1, $referenceStyle = true, $sheetName = '') + public static function cell($row, $column, $relativity = 1, $referenceStyle = true, $sheetName = ''): array|string { if ( is_array($row) || is_array($column) || diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php b/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php index e09477c3fa..0ecca4b19b 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php @@ -32,7 +32,7 @@ class ExcelMatch * * @return array|int|string The relative position of the found item */ - public static function MATCH($lookupValue, $lookupArray, $matchType = self::MATCHTYPE_LARGEST_VALUE) + public static function MATCH($lookupValue, $lookupArray, $matchType = self::MATCHTYPE_LARGEST_VALUE): array|string|int|float { if (is_array($lookupValue)) { return self::evaluateArrayArgumentsIgnore([self::class, __FUNCTION__], 1, $lookupValue, $lookupArray, $matchType); @@ -88,10 +88,8 @@ public static function MATCH($lookupValue, $lookupArray, $matchType = self::MATC /** * @param mixed $lookupValue - * - * @return mixed */ - private static function matchFirstValue(array $lookupArray, $lookupValue) + private static function matchFirstValue(array $lookupArray, $lookupValue): int|string|null { if (is_string($lookupValue)) { $valueIsString = true; @@ -168,10 +166,8 @@ private static function matchLargestValue(array $lookupArray, $lookupValue, arra /** * @param mixed $lookupValue - * - * @return mixed */ - private static function matchSmallestValue(array $lookupArray, $lookupValue) + private static function matchSmallestValue(array $lookupArray, $lookupValue): int|string|null { $valueKey = null; if (is_string($lookupValue)) { diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php b/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php index bd76ce9306..97a9ff993e 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php @@ -63,7 +63,7 @@ private static function validateAddress($cellAddress): string * * @return array|string An array containing a cell or range of cells, or a string on error */ - public static function INDIRECT($cellAddress, $a1fmt, Cell $cell) + public static function INDIRECT($cellAddress, $a1fmt, Cell $cell): string|array { [$baseCol, $baseRow] = Coordinate::indexesFromString($cell->getCoordinate()); @@ -101,10 +101,10 @@ public static function INDIRECT($cellAddress, $a1fmt, Cell $cell) /** * Extract range values. * - * @return mixed Array of values in range if range contains more than one element. + * @return array Array of values in range if range contains more than one element. * Otherwise, a single value is returned. */ - private static function extractRequiredCells(?Worksheet $worksheet, string $cellAddress) + private static function extractRequiredCells(?Worksheet $worksheet, string $cellAddress): array { return Calculation::getInstance($worksheet !== null ? $worksheet->getParent() : null) ->extractCellRange($cellAddress, $worksheet, false); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php b/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php index 8ee759e87f..402a6bd345 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php @@ -31,10 +31,8 @@ public static function isRowVector(array $values): bool * TRANSPOSE. * * @param array|mixed $matrixData A matrix of values - * - * @return array */ - public static function transpose($matrixData) + public static function transpose($matrixData): array { $returnMatrix = []; if (!is_array($matrixData)) { @@ -114,7 +112,7 @@ public static function index($matrix, $rowNum = 0, $columnNum = null) $columnNum = $columnKeys[--$columnNum]; if ($rowNum === 0) { return array_map( - function ($value) { + function ($value): array { return [$value]; }, array_column($matrix, $columnNum) diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php b/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php index 562d753978..a8c008ddd5 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php @@ -39,9 +39,9 @@ class Offset * @param mixed $width The width, in number of columns, that you want the returned reference to be. * Width must be a positive number. * - * @return array|int|string An array containing a cell or range of cells, or a string on error + * @return array|string An array containing a cell or range of cells, or a string on error */ - public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $cell = null) + public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $height = null, $width = null, ?Cell $cell = null): string|array { $rows = Functions::flattenSingleValue($rows); $columns = Functions::flattenSingleValue($columns); @@ -91,8 +91,7 @@ public static function OFFSET($cellAddress = null, $rows = 0, $columns = 0, $hei return self::extractRequiredCells($worksheet, $cellAddress); } - /** @return mixed */ - private static function extractRequiredCells(?Worksheet $worksheet, string $cellAddress) + private static function extractRequiredCells(?Worksheet $worksheet, string $cellAddress): array { return Calculation::getInstance($worksheet !== null ? $worksheet->getParent() : null) ->extractCellRange($cellAddress, $worksheet, false); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php b/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php index a1da86c890..91200e0212 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php @@ -22,7 +22,7 @@ private static function cellAddressNullOrWhitespace($cellAddress): bool private static function cellColumn(?Cell $cell): int { - return ($cell !== null) ? (int) Coordinate::columnIndexFromString($cell->getColumn()) : 1; + return ($cell !== null) ? Coordinate::columnIndexFromString($cell->getColumn()) : 1; } /** @@ -42,7 +42,7 @@ private static function cellColumn(?Cell $cell): int * * @return int|int[] */ - public static function COLUMN($cellAddress = null, ?Cell $cell = null) + public static function COLUMN($cellAddress = null, ?Cell $cell = null): int|array { if (self::cellAddressNullOrWhitespace($cellAddress)) { return self::cellColumn($cell); @@ -52,7 +52,7 @@ public static function COLUMN($cellAddress = null, ?Cell $cell = null) foreach ($cellAddress as $columnKey => $value) { $columnKey = (string) preg_replace('/[^a-z]/i', '', $columnKey); - return (int) Coordinate::columnIndexFromString($columnKey); + return Coordinate::columnIndexFromString($columnKey); } return self::cellColumn($cell); @@ -64,20 +64,22 @@ public static function COLUMN($cellAddress = null, ?Cell $cell = null) [,, $cellAddress] = Helpers::extractCellAddresses($cellAddress, true, $cell->getWorksheet(), $sheetName); } [, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true); + $cellAddress ??= ''; + if (strpos($cellAddress, ':') !== false) { [$startAddress, $endAddress] = explode(':', $cellAddress); $startAddress = (string) preg_replace('/[^a-z]/i', '', $startAddress); $endAddress = (string) preg_replace('/[^a-z]/i', '', $endAddress); return range( - (int) Coordinate::columnIndexFromString($startAddress), - (int) Coordinate::columnIndexFromString($endAddress) + Coordinate::columnIndexFromString($startAddress), + Coordinate::columnIndexFromString($endAddress) ); } $cellAddress = (string) preg_replace('/[^a-z]/i', '', $cellAddress); - return (int) Coordinate::columnIndexFromString($cellAddress); + return Coordinate::columnIndexFromString($cellAddress); } /** @@ -133,9 +135,9 @@ private static function cellRow(?Cell $cell): int * * @param null|array|string $cellAddress A reference to a range of cells for which you want the row numbers * - * @return int|mixed[]|string + * @return int|mixed[] */ - public static function ROW($cellAddress = null, ?Cell $cell = null) + public static function ROW($cellAddress = null, ?Cell $cell = null): int|array { if (self::cellAddressNullOrWhitespace($cellAddress)) { return self::cellRow($cell); @@ -157,13 +159,14 @@ public static function ROW($cellAddress = null, ?Cell $cell = null) [,, $cellAddress] = Helpers::extractCellAddresses($cellAddress, true, $cell->getWorksheet(), $sheetName); } [, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true); + $cellAddress ??= ''; if (strpos($cellAddress, ':') !== false) { [$startAddress, $endAddress] = explode(':', $cellAddress); $startAddress = (int) (string) preg_replace('/\D/', '', $startAddress); $endAddress = (int) (string) preg_replace('/\D/', '', $endAddress); return array_map( - function ($value) { + function ($value): array { return [$value]; }, range($startAddress, $endAddress) diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php b/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php index 8f90f18ced..9828da8cb1 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php @@ -219,7 +219,7 @@ function ($value) { * @param array[] $sortIndex * @param int[] $sortOrder */ - private static function processSortBy(array $sortArray, array $sortIndex, $sortOrder): array + private static function processSortBy(array $sortArray, array $sortIndex, array $sortOrder): array { $sortArguments = []; $sortData = []; diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php b/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php index 2ba51281ea..4c8b88f250 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php @@ -104,7 +104,7 @@ private static function countValuesCaseInsensitive(array $caseSensitiveLookupVal { $caseInsensitiveCounts = array_count_values( array_map( - function (string $value) { + function (string $value): string { return StringHelper::strToUpper($value); }, $caseSensitiveLookupValues @@ -133,7 +133,7 @@ private static function exactlyOnceFilter(array $values): array { return array_filter( $values, - function ($value) { + function ($value): bool { return $value === 1; } ); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index a92e9c82e9..bf40ca43ef 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -53,7 +53,7 @@ public static function ARABIC($roman) * * @return array|float|string the inverse tangent of the specified x- and y-coordinates, or a string containing an error */ - public static function ATAN2($xCoordinate = null, $yCoordinate = null) + public static function ATAN2($xCoordinate = null, $yCoordinate = null): string|float|array { return MathTrig\Trig\Tangent::atan2($xCoordinate, $yCoordinate); } @@ -76,7 +76,7 @@ public static function ATAN2($xCoordinate = null, $yCoordinate = null) * * @return array|string the text representation with the given radix (base) */ - public static function BASE($number, $radix, $minLength = null) + public static function BASE($number, $radix, $minLength = null): string|array { return MathTrig\Base::evaluate($number, $radix, $minLength); } @@ -147,9 +147,9 @@ public static function COMBIN($numObjs, $numInSet) * * @param array|float $number Number to round * - * @return array|float|int|string Rounded Number, or a string containing an error + * @return array|float|string Rounded Number, or a string containing an error */ - public static function EVEN($number) + public static function EVEN($number): string|float|array { return MathTrig\Round::even($number); } @@ -361,7 +361,7 @@ public static function LCM(...$args) * * @return array|float|string The result, or a string containing an error */ - public static function logBase($number, $base = 10) + public static function logBase($number, $base = 10): string|float|array { return MathTrig\Logarithms::withBase($number, $base); } @@ -403,7 +403,7 @@ public static function MDETERM($matrixValues) * * @return array|string The result, or a string containing an error */ - public static function MINVERSE($matrixValues) + public static function MINVERSE($matrixValues): string|array { return MathTrig\MatrixFunctions::inverse($matrixValues); } @@ -420,7 +420,7 @@ public static function MINVERSE($matrixValues) * * @return array|string The result, or a string containing an error */ - public static function MMULT($matrixData1, $matrixData2) + public static function MMULT($matrixData1, $matrixData2): string|array { return MathTrig\MatrixFunctions::multiply($matrixData1, $matrixData2); } @@ -456,7 +456,7 @@ public static function MOD($a = 1, $b = 1) * * @return array|float|string Rounded Number, or a string containing an error */ - public static function MROUND($number, $multiple) + public static function MROUND($number, $multiple): string|int|float|array { return MathTrig\Round::multiple($number, $multiple); } @@ -492,7 +492,7 @@ public static function MULTINOMIAL(...$args) * * @return array|float|int|string Rounded Number, or a string containing an error */ - public static function ODD($number) + public static function ODD($number): string|int|float|array { return MathTrig\Round::odd($number); } @@ -570,9 +570,9 @@ public static function QUOTIENT($numerator, $denominator) * @param int $min Minimal value * @param int $max Maximal value * - * @return array|float|int|string Random number + * @return array|int|string Random number */ - public static function RAND($min = 0, $max = 0) + public static function RAND($min = 0, $max = 0): string|int|array { return MathTrig\Random::randBetween($min, $max); } @@ -591,7 +591,7 @@ public static function RAND($min = 0, $max = 0) * * @return array|string Roman numeral, or a string containing an error */ - public static function ROMAN($aValue, $style = 0) + public static function ROMAN($aValue, $style = 0): string|array { return MathTrig\Roman::evaluate($aValue, $style); } @@ -610,7 +610,7 @@ public static function ROMAN($aValue, $style = 0) * * @return array|float|string Rounded Number, or a string containing an error */ - public static function ROUNDUP($number, $digits) + public static function ROUNDUP($number, $digits): string|float|array { return MathTrig\Round::up($number, $digits); } @@ -629,7 +629,7 @@ public static function ROUNDUP($number, $digits) * * @return array|float|string Rounded Number, or a string containing an error */ - public static function ROUNDDOWN($number, $digits) + public static function ROUNDDOWN($number, $digits): string|float|array { return MathTrig\Round::down($number, $digits); } @@ -650,7 +650,7 @@ public static function ROUNDDOWN($number, $digits) * * @return array|float|string The result, or a string containing an error */ - public static function SERIESSUM($x, $n, $m, ...$args) + public static function SERIESSUM($x, $n, $m, ...$args): string|float|int|array { return MathTrig\SeriesSum::evaluate($x, $n, $m, ...$args); } @@ -669,7 +669,7 @@ public static function SERIESSUM($x, $n, $m, ...$args) * * @return array|int|string sign value, or a string containing an error */ - public static function SIGN($number) + public static function SIGN($number): string|int|array { return MathTrig\Sign::evaluate($number); } @@ -699,7 +699,7 @@ public static function returnSign(float $number): int * * @return array|float|string Square Root of Number * Pi, or a string containing an error */ - public static function SQRTPI($number) + public static function SQRTPI($number): string|float|array { return MathTrig\Sqrt::pi($number); } @@ -762,13 +762,12 @@ public static function SUM(...$args) * Use the SUMIF() method in the Statistical\Conditional class instead * @see Statistical\Conditional::SUMIF() * - * @param mixed $range Data values + * @param array $range Data values * @param string $criteria the criteria that defines which cells will be summed - * @param mixed $sumRange * * @return null|float|string */ - public static function SUMIF($range, $criteria, $sumRange = []) + public static function SUMIF(array $range, $criteria, array $sumRange = []) { return Statistical\Conditional::SUMIF($range, $criteria, $sumRange); } @@ -808,7 +807,7 @@ public static function SUMIFS(...$args) * * @return float|string The result, or a string containing an error */ - public static function SUMPRODUCT(...$args) + public static function SUMPRODUCT(...$args): string|int|float { return MathTrig\Sum::product(...$args); } @@ -1078,7 +1077,7 @@ public static function ACOTH($number) * * @return array|float|string Rounded number */ - public static function builtinROUND($number, $precision) + public static function builtinROUND($number, $precision): string|float|array { return MathTrig\Round::round($number, $precision); } @@ -1096,7 +1095,7 @@ public static function builtinROUND($number, $precision) * * @return array|float|int|string Rounded number */ - public static function builtinABS($number) + public static function builtinABS($number): string|int|float|array { return MathTrig\Absolute::evaluate($number); } @@ -1222,7 +1221,7 @@ public static function builtinATANH($number) * * @return array|float|string Rounded number */ - public static function builtinCOS($number) + public static function builtinCOS($number): string|float|array { return MathTrig\Trig\Cosine::cos($number); } @@ -1240,7 +1239,7 @@ public static function builtinCOS($number) * * @return array|float|string Rounded number */ - public static function builtinCOSH($number) + public static function builtinCOSH($number): string|float|array { return MathTrig\Trig\Cosine::cosh($number); } @@ -1258,7 +1257,7 @@ public static function builtinCOSH($number) * * @return array|float|string Rounded number */ - public static function builtinDEGREES($number) + public static function builtinDEGREES($number): string|float|array { return MathTrig\Angle::toDegrees($number); } @@ -1276,7 +1275,7 @@ public static function builtinDEGREES($number) * * @return array|float|string Rounded number */ - public static function builtinEXP($number) + public static function builtinEXP($number): string|float|array { return MathTrig\Exp::evaluate($number); } @@ -1294,7 +1293,7 @@ public static function builtinEXP($number) * * @return array|float|string Rounded number */ - public static function builtinLN($number) + public static function builtinLN($number): string|float|array { return MathTrig\Logarithms::natural($number); } @@ -1312,7 +1311,7 @@ public static function builtinLN($number) * * @return array|float|string Rounded number */ - public static function builtinLOG10($number) + public static function builtinLOG10($number): string|float|array { return MathTrig\Logarithms::base10($number); } @@ -1330,7 +1329,7 @@ public static function builtinLOG10($number) * * @return array|float|string Rounded number */ - public static function builtinRADIANS($number) + public static function builtinRADIANS($number): string|float|array { return MathTrig\Angle::toRadians($number); } @@ -1348,7 +1347,7 @@ public static function builtinRADIANS($number) * * @return array|float|string sine */ - public static function builtinSIN($number) + public static function builtinSIN($number): string|float|array { return MathTrig\Trig\Sine::sin($number); } @@ -1366,7 +1365,7 @@ public static function builtinSIN($number) * * @return array|float|string Rounded number */ - public static function builtinSINH($number) + public static function builtinSINH($number): string|float|array { return MathTrig\Trig\Sine::sinh($number); } @@ -1420,7 +1419,7 @@ public static function builtinTAN($number) * * @return array|float|string Rounded number */ - public static function builtinTANH($number) + public static function builtinTANH($number): string|float|array { return MathTrig\Trig\Tangent::tanh($number); } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Absolute.php b/src/PhpSpreadsheet/Calculation/MathTrig/Absolute.php index f21c6b73ca..f45eab9982 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Absolute.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Absolute.php @@ -20,7 +20,7 @@ class Absolute * 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 evaluate($number) + public static function evaluate($number): array|string|int|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Angle.php b/src/PhpSpreadsheet/Calculation/MathTrig/Angle.php index cbeec6f407..2ab984ed29 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Angle.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Angle.php @@ -20,7 +20,7 @@ class Angle * 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 toDegrees($number) + public static function toDegrees($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); @@ -46,7 +46,7 @@ public static function toDegrees($number) * 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 toRadians($number) + public static function toRadians($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Base.php b/src/PhpSpreadsheet/Calculation/MathTrig/Base.php index 2fec947326..da11b47bdb 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Base.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Base.php @@ -29,7 +29,7 @@ class Base * 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 evaluate($number, $radix, $minLength = null) + public static function evaluate($number, $radix, $minLength = null): array|string { if (is_array($number) || is_array($radix) || is_array($minLength)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $radix, $minLength); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Ceiling.php b/src/PhpSpreadsheet/Calculation/MathTrig/Ceiling.php index 635f1bbbb8..f33b63b874 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Ceiling.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Ceiling.php @@ -70,7 +70,7 @@ public static function ceiling($number, $significance = null) * 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 math($number, $significance = null, $mode = 0) + public static function math($number, $significance = null, $mode = 0): array|string|float { if (is_array($number) || is_array($significance) || is_array($mode)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $significance, $mode); @@ -111,7 +111,7 @@ public static function math($number, $significance = null, $mode = 0) * 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 precise($number, $significance = 1) + public static function precise($number, $significance = 1): array|string|float { if (is_array($number) || is_array($significance)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $significance); @@ -142,10 +142,8 @@ private static function ceilingMathTest(float $significance, float $number, int /** * Avoid Scrutinizer problems concerning complexity. - * - * @return float|string */ - private static function argumentsOk(float $number, float $significance) + private static function argumentsOk(float $number, float $significance): float|string { if (empty($number * $significance)) { return 0.0; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php b/src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php index f68c402ae4..d4e70de339 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php @@ -21,11 +21,11 @@ class Combinations * @param mixed $numObjs Number of different objects, or can be an array of numbers * @param mixed $numInSet Number of objects in each combination, or can be an array of numbers * - * @return array|float|int|string Number of combinations, or a string containing an error + * @return array|float|string Number of combinations, or a string containing an error * 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 withoutRepetition($numObjs, $numInSet) + public static function withoutRepetition($numObjs, $numInSet): array|string|float { if (is_array($numObjs) || is_array($numInSet)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $numObjs, $numInSet); @@ -59,7 +59,7 @@ public static function withoutRepetition($numObjs, $numInSet) * 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 withRepetition($numObjs, $numInSet) + public static function withRepetition($numObjs, $numInSet): array|int|string|float { if (is_array($numObjs) || is_array($numInSet)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $numObjs, $numInSet); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Exp.php b/src/PhpSpreadsheet/Calculation/MathTrig/Exp.php index f65c2c18bf..288cd84690 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Exp.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Exp.php @@ -20,7 +20,7 @@ class Exp * 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 evaluate($number) + public static function evaluate($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php b/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php index 8059eec8b7..02143b07c0 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php @@ -27,7 +27,7 @@ class Factorial * 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 fact($factVal) + public static function fact($factVal): array|string|float|int { if (is_array($factVal)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $factVal); @@ -69,7 +69,7 @@ public static function fact($factVal) * 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 factDouble($factVal) + public static function factDouble($factVal): array|string|float|int { if (is_array($factVal)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $factVal); @@ -101,7 +101,7 @@ public static function factDouble($factVal) * * @return float|string The result, or a string containing an error */ - public static function multinomial(...$args) + public static function multinomial(...$args): string|int|float { $summer = 0; $divisor = 1; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Floor.php b/src/PhpSpreadsheet/Calculation/MathTrig/Floor.php index 2199dda0c1..8f75cea0b1 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Floor.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Floor.php @@ -127,10 +127,8 @@ public static function precise($number, $significance = 1) /** * Avoid Scrutinizer problems concerning complexity. - * - * @return float|string */ - private static function argumentsOkPrecise(float $number, float $significance) + private static function argumentsOkPrecise(float $number, float $significance): string|float { if ($significance == 0.0) { return ExcelError::DIV0(); @@ -147,7 +145,7 @@ private static function argumentsOkPrecise(float $number, float $significance) * * @return float|string Rounded Number, or a string containing an error */ - private static function argsOk(float $number, float $significance, int $mode) + private static function argsOk(float $number, float $significance, int $mode): string|float { if (!$significance) { return ExcelError::DIV0(); @@ -172,10 +170,8 @@ private static function floorMathTest(float $number, float $significance, int $m /** * Avoid Scrutinizer problems concerning complexity. - * - * @return float|string */ - private static function argumentsOk(float $number, float $significance) + private static function argumentsOk(float $number, float $significance): string|float { if ($significance == 0.0) { return ExcelError::DIV0(); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php b/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php index f34f159b8f..0b85435064 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php @@ -13,7 +13,7 @@ class Helpers * * @return float|string quotient or DIV0 if denominator is too small */ - public static function verySmallDenominator(float $numerator, float $denominator) + public static function verySmallDenominator(float $numerator, float $denominator): string|float { return (abs($denominator) < 1.0E-12) ? ExcelError::DIV0() : ($numerator / $denominator); } @@ -22,10 +22,8 @@ public static function verySmallDenominator(float $numerator, float $denominator * Many functions accept null/false/true argument treated as 0/0/1. * * @param mixed $number - * - * @return float|int */ - public static function validateNumericNullBool($number) + public static function validateNumericNullBool($number): int|float { $number = Functions::flattenSingleValue($number); if ($number === null) { diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php b/src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php index 230f969a29..76bbced8d5 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php @@ -23,7 +23,7 @@ class IntClass * 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 evaluate($number) + public static function evaluate($number): array|string|int { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Lcm.php b/src/PhpSpreadsheet/Calculation/MathTrig/Lcm.php index 3b23c1da17..652f31c937 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Lcm.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Lcm.php @@ -49,7 +49,7 @@ private static function factors(float $value): array * * @return int|string Lowest Common Multiplier, or a string containing an error */ - public static function evaluate(...$args) + public static function evaluate(...$args): int|string { try { $arrayArgs = []; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Logarithms.php b/src/PhpSpreadsheet/Calculation/MathTrig/Logarithms.php index 7b07f09d51..464781e6f2 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Logarithms.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Logarithms.php @@ -26,7 +26,7 @@ class Logarithms * 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 withBase($number, $base = 10) + public static function withBase($number, $base = 10): array|string|float { if (is_array($number) || is_array($base)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $base); @@ -56,7 +56,7 @@ public static function withBase($number, $base = 10) * 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 base10($number) + public static function base10($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); @@ -84,7 +84,7 @@ public static function base10($number) * 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 natural($number) + public static function natural($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/MatrixFunctions.php b/src/PhpSpreadsheet/Calculation/MathTrig/MatrixFunctions.php index 5a5125a8c0..e1bd837f56 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/MatrixFunctions.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/MatrixFunctions.php @@ -57,7 +57,7 @@ private static function getMatrix($matrixValues): Matrix * * @return array|string The resulting array, or a string containing an error */ - public static function sequence($rows = 1, $columns = 1, $start = 1, $step = 1) + public static function sequence($rows = 1, $columns = 1, $start = 1, $step = 1): string|array { try { $rows = (int) Helpers::validateNumericNullSubstitution($rows, 1); @@ -120,7 +120,7 @@ public static function determinant($matrixValues) * * @return array|string The result, or a string containing an error */ - public static function inverse($matrixValues) + public static function inverse($matrixValues): array|string { try { $matrix = self::getMatrix($matrixValues); @@ -143,7 +143,7 @@ public static function inverse($matrixValues) * * @return array|string The result, or a string containing an error */ - public static function multiply($matrixData1, $matrixData2) + public static function multiply($matrixData1, $matrixData2): array|string { try { $matrixA = self::getMatrix($matrixData1); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php b/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php index 0625845105..f8857ec4b2 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php @@ -19,11 +19,11 @@ class Operations * @param mixed $divisor Divisor * Or can be an array of values * - * @return array|float|int|string Remainder, or a string containing an error + * @return array|float|string Remainder, or a string containing 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 mod($dividend, $divisor) + public static function mod($dividend, $divisor): array|string|float { if (is_array($dividend) || is_array($divisor)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $dividend, $divisor); @@ -97,14 +97,12 @@ public static function power($x, $y) * PRODUCT(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|string */ - public static function product(...$args) + public static function product(...$args): string|float { $args = array_filter( Functions::flattenArray($args), - function ($value) { + function ($value): bool { return $value !== null; } ); @@ -143,7 +141,7 @@ function ($value) { * 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 quotient($numerator, $denominator) + public static function quotient($numerator, $denominator): array|string|int { if (is_array($numerator) || is_array($denominator)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $numerator, $denominator); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Random.php b/src/PhpSpreadsheet/Calculation/MathTrig/Random.php index 22cad2cfd9..2c60e2b463 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Random.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Random.php @@ -15,7 +15,7 @@ class Random * * @return float Random number */ - public static function rand() + public static function rand(): int|float { return mt_rand(0, 10000000) / 10000000; } @@ -28,11 +28,11 @@ public static function rand() * @param mixed $max Maximal value * Or can be an array of values * - * @return array|float|int|string Random number + * @return array|int|string Random number * 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 randBetween($min, $max) + public static function randBetween($min, $max): array|string|int { if (is_array($min) || is_array($max)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $min, $max); @@ -67,7 +67,7 @@ public static function randBetween($min, $max) * * @return array|string The resulting array, or a string containing an error */ - public static function randArray($rows = 1, $columns = 1, $min = 0, $max = 1, $wholeNumber = false) + public static function randArray($rows = 1, $columns = 1, $min = 0, $max = 1, $wholeNumber = false): string|array { try { $rows = (int) Helpers::validateNumericNullSubstitution($rows, 1); @@ -86,7 +86,7 @@ public static function randArray($rows = 1, $columns = 1, $min = 0, $max = 1, $w return array_chunk( array_map( - function () use ($min, $max, $wholeNumber) { + function () use ($min, $max, $wholeNumber): int|float { return $wholeNumber ? mt_rand((int) $min, (int) $max) : (mt_rand() / mt_getrandmax()) * ($max - $min) + $min; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Roman.php b/src/PhpSpreadsheet/Calculation/MathTrig/Roman.php index 05415481c3..cd21202a71 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Roman.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Roman.php @@ -825,7 +825,7 @@ public static function calculateRoman(int $aValue, int $style): string * 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 evaluate($aValue, $style = 0) + public static function evaluate($aValue, $style = 0): array|string { if (is_array($aValue) || is_array($style)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $aValue, $style); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Round.php b/src/PhpSpreadsheet/Calculation/MathTrig/Round.php index 776f7eb902..882e6283f9 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Round.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Round.php @@ -22,7 +22,7 @@ class Round * 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 round($number, $precision) + public static function round($number, $precision): array|string|float { if (is_array($number) || is_array($precision)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $precision); @@ -50,7 +50,7 @@ public static function round($number, $precision) * 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 up($number, $digits) + public static function up($number, $digits): array|string|float { if (is_array($number) || is_array($digits)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $digits); @@ -86,7 +86,7 @@ public static function up($number, $digits) * 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 down($number, $digits) + public static function down($number, $digits): array|string|float { if (is_array($number) || is_array($digits)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $digits); @@ -122,7 +122,7 @@ public static function down($number, $digits) * 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 multiple($number, $multiple) + public static function multiple($number, $multiple): array|string|int|float { if (is_array($number) || is_array($multiple)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $multiple); @@ -165,7 +165,7 @@ public static function multiple($number, $multiple) * 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 even($number) + public static function even($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); @@ -191,7 +191,7 @@ public static function even($number) * 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 odd($number) + public static function odd($number): array|string|int|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php b/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php index ecce359fc6..b2745b0ce9 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php @@ -22,7 +22,7 @@ class SeriesSum * * @return array|float|string The result, or a string containing an error */ - public static function evaluate($x, $n, $m, ...$args) + public static function evaluate($x, $n, $m, ...$args): array|string|float|int { if (is_array($x) || is_array($n) || is_array($m)) { return self::evaluateArrayArgumentsSubset([self::class, __FUNCTION__], 3, $x, $n, $m, ...$args); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Sign.php b/src/PhpSpreadsheet/Calculation/MathTrig/Sign.php index e40e1f6d36..86a55092c7 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Sign.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Sign.php @@ -21,7 +21,7 @@ class Sign * 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 evaluate($number) + public static function evaluate($number): array|string|int { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Sqrt.php b/src/PhpSpreadsheet/Calculation/MathTrig/Sqrt.php index bb9f15fda5..37bef7bfae 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Sqrt.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Sqrt.php @@ -46,7 +46,7 @@ public static function sqrt($number) * 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 pi($number) + public static function pi($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php b/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php index 6d8f4723c1..9d343676b8 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php @@ -38,7 +38,7 @@ protected static function filterFormulaArgs($cellReference, $args): array { return array_filter( $args, - function ($index) use ($cellReference) { + function ($index) use ($cellReference): bool { $explodeArray = explode('.', $index); $row = $explodeArray[1] ?? ''; $column = $explodeArray[2] ?? ''; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php b/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php index 37070e2434..d6bf2d9d29 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php @@ -79,9 +79,9 @@ public static function sumErroringStrings(...$args) * * @param mixed ...$args Data values * - * @return float|string The result, or a string containing an error + * @return float|int|string The result, or a string containing an error */ - public static function product(...$args) + public static function product(...$args): string|int|float { $arrayList = $args; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php b/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php index 34b397cde2..30e7c5e87c 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php @@ -20,7 +20,7 @@ class SumSquares * * @return float|string */ - public static function sumSquare(...$args) + public static function sumSquare(...$args): string|int|float { try { $returnValue = 0; @@ -65,7 +65,7 @@ private static function numericNotString($item): bool * * @return float|string */ - public static function sumXSquaredMinusYSquared($matrixData1, $matrixData2) + public static function sumXSquaredMinusYSquared($matrixData1, $matrixData2): string|int|float { try { $array1 = Functions::flattenArray($matrixData1); @@ -93,7 +93,7 @@ public static function sumXSquaredMinusYSquared($matrixData1, $matrixData2) * * @return float|string */ - public static function sumXSquaredPlusYSquared($matrixData1, $matrixData2) + public static function sumXSquaredPlusYSquared($matrixData1, $matrixData2): string|int|float { try { $array1 = Functions::flattenArray($matrixData1); @@ -121,7 +121,7 @@ public static function sumXSquaredPlusYSquared($matrixData1, $matrixData2) * * @return float|string */ - public static function sumXMinusYSquared($matrixData1, $matrixData2) + public static function sumXMinusYSquared($matrixData1, $matrixData2): string|int|float { try { $array1 = Functions::flattenArray($matrixData1); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosine.php b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosine.php index c06f04dfc1..28e1220b3c 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosine.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosine.php @@ -21,7 +21,7 @@ class Cosine * 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 cos($number) + public static function cos($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); @@ -47,7 +47,7 @@ public static function cos($number) * 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 cosh($number) + public static function cosh($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cotangent.php b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cotangent.php index eeedef9bfc..861159a3bd 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cotangent.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cotangent.php @@ -73,7 +73,7 @@ public static function coth($angle) * 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 acot($number) + public static function acot($number): array|string|float { if (is_array($number)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $number); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Sine.php b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Sine.php index 6af568ce23..050e36e92e 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Sine.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Sine.php @@ -21,7 +21,7 @@ class Sine * 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 sin($angle) + public static function sin($angle): array|string|float { if (is_array($angle)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $angle); @@ -47,7 +47,7 @@ public static function sin($angle) * 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 sinh($angle) + public static function sinh($angle): array|string|float { if (is_array($angle)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $angle); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php index 9e77021028..8667e582ac 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php @@ -48,7 +48,7 @@ public static function tan($angle) * 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 tanh($angle) + public static function tanh($angle): array|string|float { if (is_array($angle)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $angle); @@ -139,7 +139,7 @@ public static function atanh($number) * If an array of numbers is passed as one of the arguments, then the returned result will also be an array * with the same dimensions */ - public static function atan2($xCoordinate, $yCoordinate) + public static function atan2($xCoordinate, $yCoordinate): array|string|float { if (is_array($xCoordinate) || is_array($yCoordinate)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $xCoordinate, $yCoordinate); diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 6310ef37cf..1c81631ad6 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -124,10 +124,8 @@ public static function AVERAGEIF($range, $condition, $averageRange = []) * @param float $beta Parameter to the distribution * @param mixed $rMin * @param mixed $rMax - * - * @return array|float|string */ - public static function BETADIST($value, $alpha, $beta, $rMin = 0, $rMax = 1) + public static function BETADIST($value, $alpha, $beta, $rMin = 0, $rMax = 1): string|float|array { return Statistical\Distributions\Beta::distribution($value, $alpha, $beta, $rMin, $rMax); } @@ -269,10 +267,8 @@ public static function CORREL($yValues, $xValues = null) * @see Statistical\Counts::COUNT() * * @param mixed ...$args Data values - * - * @return int */ - public static function COUNT(...$args) + public static function COUNT(...$args): int { return Counts::COUNT(...$args); } @@ -290,10 +286,8 @@ public static function COUNT(...$args) * @see Statistical\Counts::COUNTA() * * @param mixed ...$args Data values - * - * @return int */ - public static function COUNTA(...$args) + public static function COUNTA(...$args): int { return Counts::COUNTA(...$args); } @@ -311,10 +305,8 @@ public static function COUNTA(...$args) * @see Statistical\Counts::COUNTBLANK() * * @param mixed $range Data values - * - * @return int */ - public static function COUNTBLANK($range) + public static function COUNTBLANK($range): int { return Counts::COUNTBLANK($range); } @@ -371,12 +363,12 @@ public static function COUNTIFS(...$args) * Use the COVAR() method in the Statistical\Trends class instead * @see Statistical\Trends::COVAR() * - * @param mixed $yValues array of mixed Data Series Y - * @param mixed $xValues array of mixed Data Series X + * @param mixed[] $yValues array of mixed Data Series Y + * @param mixed[] $xValues array of mixed Data Series X * * @return float|string */ - public static function COVAR($yValues, $xValues) + public static function COVAR(array $yValues, array $xValues) { return Trends::COVAR($yValues, $xValues); } @@ -522,12 +514,12 @@ public static function FISHERINV($value) * @see Statistical\Trends::FORECAST() * * @param float $xValue Value of X for which we want to find Y - * @param mixed $yValues array of mixed Data Series Y - * @param mixed $xValues of mixed Data Series X + * @param mixed[] $yValues array of mixed Data Series Y + * @param mixed[] $xValues array of mixed Data Series X * * @return array|bool|float|string */ - public static function FORECAST($xValue, $yValues, $xValues) + public static function FORECAST($xValue, array $yValues, array $xValues) { return Trends::FORECAST($xValue, $yValues, $xValues); } @@ -545,7 +537,7 @@ public static function FORECAST($xValue, $yValues, $xValues) * * @return array|float|string The result, or a string containing an error */ - public static function GAMMAFunction($value) + public static function GAMMAFunction($value): string|float|array { return Statistical\Distributions\Gamma::gamma($value); } @@ -601,10 +593,8 @@ public static function GAMMAINV($probability, $alpha, $beta) * @see Statistical\Distributions\Gamma::ln() * * @param float $value - * - * @return array|float|string */ - public static function GAMMALN($value) + public static function GAMMALN($value): string|float|array { return Statistical\Distributions\Gamma::ln($value); } @@ -735,7 +725,7 @@ public static function HYPGEOMDIST($sampleSuccesses, $sampleNumber, $populationS * * @return float|string */ - public static function INTERCEPT($yValues, $xValues) + public static function INTERCEPT(array $yValues, array $xValues) { return Trends::INTERCEPT($yValues, $xValues); } @@ -798,9 +788,9 @@ public static function LARGE(...$args) * @param bool $const a logical value specifying whether to force the intersect to equal 0 * @param bool $stats a logical value specifying whether to return additional regression statistics * - * @return array|int|string The result, or a string containing an error + * @return array|string The result, or a string containing an error */ - public static function LINEST($yValues, $xValues = null, $const = true, $stats = false) + public static function LINEST(array $yValues, $xValues = null, $const = true, $stats = false): string|array { return Trends::LINEST($yValues, $xValues, $const, $stats); } @@ -820,9 +810,9 @@ public static function LINEST($yValues, $xValues = null, $const = true, $stats = * @param bool $const a logical value specifying whether to force the intersect to equal 0 * @param bool $stats a logical value specifying whether to return additional regression statistics * - * @return array|int|string The result, or a string containing an error + * @return array|string The result, or a string containing an error */ - public static function LOGEST($yValues, $xValues = null, $const = true, $stats = false) + public static function LOGEST(array $yValues, $xValues = null, $const = true, $stats = false): string|array { return Trends::LOGEST($yValues, $xValues, $const, $stats); } @@ -846,7 +836,7 @@ public static function LOGEST($yValues, $xValues = null, $const = true, $stats = * accuracy if I can get my head round the mathematics * (as described at) http://home.online.no/~pjacklam/notes/invnorm/ */ - public static function LOGINV($probability, $mean, $stdDev) + public static function LOGINV($probability, $mean, $stdDev): string|float|array { return Statistical\Distributions\LogNormal::inverse($probability, $mean, $stdDev); } @@ -1229,7 +1219,7 @@ public static function PERCENTILE(...$args) * * @return float|string (string if result is an error) */ - public static function PERCENTRANK($valueSet, $value, $significance = 3) + public static function PERCENTRANK($valueSet, $value, $significance = 3): string|float { return Statistical\Percentiles::PERCENTRANK($valueSet, $value, $significance); } @@ -1334,7 +1324,7 @@ public static function RANK($value, $valueSet, $order = 0) * * @return float|string The result, or a string containing an error */ - public static function RSQ($yValues, $xValues) + public static function RSQ(array $yValues, array $xValues) { return Trends::RSQ($yValues, $xValues); } @@ -1374,7 +1364,7 @@ public static function SKEW(...$args) * * @return float|string The result, or a string containing an error */ - public static function SLOPE($yValues, $xValues) + public static function SLOPE(array $yValues, array $xValues) { return Trends::SLOPE($yValues, $xValues); } @@ -1520,7 +1510,7 @@ public static function STDEVPA(...$args) * * @return float|string */ - public static function STEYX($yValues, $xValues) + public static function STEYX(array $yValues, array $xValues) { return Trends::STEYX($yValues, $xValues); } diff --git a/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php b/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php index 10933f488e..0002a5e4c1 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php @@ -44,10 +44,8 @@ protected static function testAcceptedBoolean($arg, $k) /** * @param mixed $arg * @param mixed $k - * - * @return bool */ - protected static function isAcceptedCountable($arg, $k, bool $countNull = false) + protected static function isAcceptedCountable($arg, $k, bool $countNull = false): bool { if ($countNull && $arg === null && !Functions::isCellValue($k) && Functions::getCompatibilityMode() !== Functions::COMPATIBILITY_GNUMERIC) { return true; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Averages.php b/src/PhpSpreadsheet/Calculation/Statistical/Averages.php index edb29847c6..304fe877f5 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Averages.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Averages.php @@ -20,7 +20,7 @@ class Averages extends AggregateBase * * @return float|string (string if result is an error) */ - public static function averageDeviations(...$args) + public static function averageDeviations(...$args): string|float { $aArgs = Functions::flattenArrayIndexed($args); @@ -69,7 +69,7 @@ public static function averageDeviations(...$args) * * @return float|string (string if result is an error) */ - public static function average(...$args) + public static function average(...$args): string|int|float { $returnValue = $aCount = 0; @@ -108,7 +108,7 @@ public static function average(...$args) * * @return float|string (string if result is an error) */ - public static function averageA(...$args) + public static function averageA(...$args): string|int|float { $returnValue = null; @@ -200,7 +200,7 @@ protected static function filterArguments(array $args): array { return array_filter( $args, - function ($value) { + function ($value): bool { // Is it a numeric value? return is_numeric($value) && (!is_string($value)); } diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php b/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php index 001c91eb32..23697d4738 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php @@ -25,7 +25,7 @@ class Mean * * @return float|string */ - public static function geometric(...$args) + public static function geometric(...$args): float|int|string { $aArgs = Functions::flattenArray($args); @@ -53,7 +53,7 @@ public static function geometric(...$args) * * @return float|string */ - public static function harmonic(...$args) + public static function harmonic(...$args): string|float|int { // Loop through arguments $aArgs = Functions::flattenArray($args); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php index 105db96317..9f4b7d631c 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php @@ -82,15 +82,13 @@ public static function AVERAGEIFS(...$args) * * @param mixed[] $range Data values * @param string $condition the criteria that defines which cells will be counted - * - * @return int|string */ - public static function COUNTIF($range, $condition) + public static function COUNTIF($range, $condition): string|int { // Filter out any empty values that shouldn't be included in a COUNT $range = array_filter( Functions::flattenArray($range), - function ($value) { + function ($value): bool { return $value !== null && $value !== ''; } ); @@ -183,13 +181,12 @@ public static function MINIFS(...$args) * Excel Function: * SUMIF(range, criteria, [sum_range]) * - * @param mixed $range Data values - * @param mixed $sumRange + * @param array $range Data values * @param mixed $condition * * @return null|float|string */ - public static function SUMIF($range, $condition, $sumRange = []) + public static function SUMIF(array $range, $condition, array $sumRange = []) { $database = self::databaseFromRangeAndValue($range, $sumRange); $condition = [[self::CONDITION_COLUMN_NAME, self::VALUE_COLUMN_NAME], [$condition, null]]; @@ -239,7 +236,7 @@ private static function buildConditionSetForValueRange(...$args): array if (count($conditions) === 1) { return array_map( - function ($value) { + function ($value): array { return [$value]; }, $conditions[0] diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Counts.php b/src/PhpSpreadsheet/Calculation/Statistical/Counts.php index 6792730387..80b15c43c4 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Counts.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Counts.php @@ -16,10 +16,8 @@ class Counts extends AggregateBase * COUNT(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return int */ - public static function COUNT(...$args) + public static function COUNT(...$args): int { $returnValue = 0; @@ -47,10 +45,8 @@ public static function COUNT(...$args) * COUNTA(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return int */ - public static function COUNTA(...$args) + public static function COUNTA(...$args): int { $returnValue = 0; @@ -75,10 +71,8 @@ public static function COUNTA(...$args) * COUNTBLANK(value1[,value2[, ...]]) * * @param mixed $range Data values - * - * @return int */ - public static function COUNTBLANK($range) + public static function COUNTBLANK($range): int { if ($range === null) { return 1; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php b/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php index 280ecfe0dc..1efb69c86a 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php @@ -16,10 +16,8 @@ class Deviations * DEVSQ(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|string */ - public static function sumSquares(...$args) + public static function sumSquares(...$args): string|float { $aArgs = Functions::flattenArrayIndexed($args); @@ -61,7 +59,7 @@ public static function sumSquares(...$args) * * @return float|string */ - public static function kurtosis(...$args) + public static function kurtosis(...$args): string|int|float { $aArgs = Functions::flattenArrayIndexed($args); $mean = Averages::average($aArgs); @@ -106,7 +104,7 @@ public static function kurtosis(...$args) * * @return float|int|string The result, or a string containing an error */ - public static function skew(...$args) + public static function skew(...$args): string|int|float { $aArgs = Functions::flattenArrayIndexed($args); $mean = Averages::average($aArgs); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php index a88c1054a6..e2faa6f207 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php @@ -37,7 +37,7 @@ class Beta * 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 distribution($value, $alpha, $beta, $rMin = 0.0, $rMax = 1.0) + public static function distribution($value, $alpha, $beta, $rMin = 0.0, $rMax = 1.0): array|string|float { if (is_array($value) || is_array($alpha) || is_array($beta) || is_array($rMin) || is_array($rMax)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $alpha, $beta, $rMin, $rMax); @@ -91,7 +91,7 @@ public static function distribution($value, $alpha, $beta, $rMin = 0.0, $rMax = * 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 inverse($probability, $alpha, $beta, $rMin = 0.0, $rMax = 1.0) + public static function inverse($probability, $alpha, $beta, $rMin = 0.0, $rMax = 1.0): array|string|float { if (is_array($probability) || is_array($alpha) || is_array($beta) || is_array($rMin) || is_array($rMax)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $probability, $alpha, $beta, $rMin, $rMax); @@ -122,10 +122,7 @@ public static function inverse($probability, $alpha, $beta, $rMin = 0.0, $rMax = return self::calculateInverse($probability, $alpha, $beta, $rMin, $rMax); } - /** - * @return float|string - */ - private static function calculateInverse(float $probability, float $alpha, float $beta, float $rMin, float $rMax) + private static function calculateInverse(float $probability, float $alpha, float $beta, float $rMin, float $rMax): string|float { $a = 0; $b = 2; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php index 02b53e888e..33d0d8ef12 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php @@ -83,7 +83,7 @@ public static function distribution($value, $trials, $probability, $cumulative) * 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 range($trials, $probability, $successes, $limit = null) + public static function range($trials, $probability, $successes, $limit = null): array|string|float|int { if (is_array($trials) || is_array($probability) || is_array($successes) || is_array($limit)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $trials, $probability, $successes, $limit); @@ -141,7 +141,7 @@ public static function range($trials, $probability, $successes, $limit = null) * TODO Add support for the cumulative flag not present for NEGBINOMDIST, but introduced for NEGBINOM.DIST * The cumulative default should be false to reflect the behaviour of NEGBINOMDIST */ - public static function negative($failures, $successes, $probability) + public static function negative($failures, $successes, $probability): array|string|float { if (is_array($failures) || is_array($successes) || is_array($probability)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $failures, $successes, $probability); @@ -187,7 +187,7 @@ public static function negative($failures, $successes, $probability) * 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 inverse($trials, $probability, $alpha) + public static function inverse($trials, $probability, $alpha): array|string|int { if (is_array($trials) || is_array($probability) || is_array($alpha)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $trials, $probability, $alpha); @@ -219,10 +219,7 @@ public static function inverse($trials, $probability, $alpha) return $successes; } - /** - * @return float|int - */ - private static function calculateCumulativeBinomial(int $value, int $trials, float $probability) + private static function calculateCumulativeBinomial(int $value, int $trials, float $probability): float|int { $summer = 0; for ($i = 0; $i <= $value; ++$i) { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php index 3538412850..56dea71fcf 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php @@ -27,7 +27,7 @@ class ChiSquared * 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 distributionRightTail($value, $degrees) + public static function distributionRightTail($value, $degrees): array|string|int|float { if (is_array($value) || is_array($degrees)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $degrees); @@ -70,7 +70,7 @@ public static function distributionRightTail($value, $degrees) * 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 distributionLeftTail($value, $degrees, $cumulative) + public static function distributionLeftTail($value, $degrees, $cumulative): array|string|int|float { if (is_array($value) || is_array($degrees) || is_array($cumulative)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $degrees, $cumulative); @@ -136,7 +136,7 @@ public static function inverseRightTail($probability, $degrees) return ExcelError::NAN(); } - $callback = function ($value) use ($degrees) { + $callback = function ($value) use ($degrees): float { return 1 - (Gamma::incompleteGamma($degrees / 2, $value / 2) / Gamma::gammaValue($degrees / 2)); }; @@ -160,7 +160,7 @@ public static function inverseRightTail($probability, $degrees) * 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 inverseLeftTail($probability, $degrees) + public static function inverseLeftTail($probability, $degrees): array|string|float { if (is_array($probability) || is_array($degrees)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $probability, $degrees); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php index a03671cccd..e8627c9f6d 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php @@ -28,7 +28,7 @@ class Exponential * 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 distribution($value, $lambda, $cumulative) + public static function distribution($value, $lambda, $cumulative): array|string|float { if (is_array($value) || is_array($lambda) || is_array($cumulative)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $lambda, $cumulative); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php index ff413b6b82..7186239b22 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php @@ -31,7 +31,7 @@ class F * 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 distribution($value, $u, $v, $cumulative) + public static function distribution($value, $u, $v, $cumulative): array|string|float { if (is_array($value) || is_array($u) || is_array($v) || is_array($cumulative)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $u, $v, $cumulative); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php index df9906ea9f..d7bdc6ff1b 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php @@ -24,7 +24,7 @@ class Fisher * 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 distribution($value) + public static function distribution($value): array|string|float { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -57,7 +57,7 @@ public static function distribution($value) * 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 inverse($probability) + public static function inverse($probability): array|string|float { if (is_array($probability)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $probability); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php index 216f234c1e..e278007982 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php @@ -22,7 +22,7 @@ class Gamma extends GammaBase * 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 gamma($value) + public static function gamma($value): array|string|float { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -130,7 +130,7 @@ public static function inverse($probability, $alpha, $beta) * 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 ln($value) + public static function ln($value): array|string|float { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php index b3ad69d1af..d8012b87e7 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php @@ -30,7 +30,7 @@ class HyperGeometric * 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 distribution($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber) + public static function distribution($sampleSuccesses, $sampleNumber, $populationSuccesses, $populationNumber): array|string|float { if ( is_array($sampleSuccesses) || is_array($sampleNumber) || diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php index d572d234f3..b051a8ddac 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php @@ -114,7 +114,7 @@ public static function distribution($value, $mean, $stdDev, $cumulative = false) * accuracy if I can get my head round the mathematics * (as described at) http://home.online.no/~pjacklam/notes/invnorm/ */ - public static function inverse($probability, $mean, $stdDev) + public static function inverse($probability, $mean, $stdDev): array|string|float { if (is_array($probability) || is_array($mean) || is_array($stdDev)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $probability, $mean, $stdDev); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php index d301407289..d1727f49d6 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php @@ -18,7 +18,7 @@ public function __construct(callable $callback) } /** @return float|string */ - public function execute(float $probability) + public function execute(float $probability): string|int|float { $xLo = 100; $xHi = 0; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php index 5715dacfaf..5fae0cb94c 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php @@ -33,7 +33,7 @@ class Normal * 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 distribution($value, $mean, $stdDev, $cumulative) + public static function distribution($value, $mean, $stdDev, $cumulative): array|string|float { if (is_array($value) || is_array($mean) || is_array($stdDev) || is_array($cumulative)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $mean, $stdDev, $cumulative); @@ -75,7 +75,7 @@ public static function distribution($value, $mean, $stdDev, $cumulative) * 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 inverse($probability, $mean, $stdDev) + public static function inverse($probability, $mean, $stdDev): array|string|float { if (is_array($probability) || is_array($mean) || is_array($stdDev)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $probability, $mean, $stdDev); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php index 041c34a0fc..a8de2eb511 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php @@ -29,7 +29,7 @@ class Poisson * 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 distribution($value, $mean, $cumulative) + public static function distribution($value, $mean, $cumulative): array|string|float { if (is_array($value) || is_array($mean) || is_array($cumulative)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $mean, $cumulative); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php index 623146ca74..32d9dff9eb 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php @@ -94,7 +94,7 @@ public static function inverse($value) * 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 gauss($value) + public static function gauss($value): array|string|float { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StudentT.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StudentT.php index 9d89af6319..969901cefb 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StudentT.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StudentT.php @@ -88,10 +88,7 @@ public static function inverse($probability, $degrees) return $newtonRaphson->execute($probability); } - /** - * @return float - */ - private static function calculateDistribution(float $value, int $degrees, int $tails) + private static function calculateDistribution(float $value, int $degrees, int $tails): float { // tdist, which finds the probability that corresponds to a given value // of t with k degrees of freedom. This algorithm is translated from a diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Weibull.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Weibull.php index 51392c41f7..4de1155d8f 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Weibull.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Weibull.php @@ -29,7 +29,7 @@ class Weibull * 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 distribution($value, $alpha, $beta, $cumulative) + public static function distribution($value, $alpha, $beta, $cumulative): array|string|float { if (is_array($value) || is_array($alpha) || is_array($beta) || is_array($cumulative)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $alpha, $beta, $cumulative); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php b/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php index 4565ca442f..5f97d3947a 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Percentiles.php @@ -74,7 +74,7 @@ public static function PERCENTILE(...$args) * * @return float|string (string if result is an error) */ - public static function PERCENTRANK($valueSet, $value, $significance = 3) + public static function PERCENTRANK($valueSet, $value, $significance = 3): string|float { $valueSet = Functions::flattenArray($valueSet); $value = Functions::flattenSingleValue($value); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Standardize.php b/src/PhpSpreadsheet/Calculation/Statistical/Standardize.php index 51b0a51878..b8e73505c6 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Standardize.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Standardize.php @@ -26,7 +26,7 @@ class Standardize extends StatisticalValidations * 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 execute($value, $mean, $stdDev) + public static function execute($value, $mean, $stdDev): array|string|float { if (is_array($value) || is_array($mean) || is_array($stdDev)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $mean, $stdDev); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php index 705de17d80..c44a8e2921 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php @@ -90,12 +90,12 @@ public static function CORREL($yValues, $xValues = null) * * Returns covariance, the average of the products of deviations for each data point pair. * - * @param mixed $yValues array of mixed Data Series Y - * @param mixed $xValues array of mixed Data Series X + * @param mixed[] $yValues array of mixed Data Series Y + * @param mixed[] $xValues array of mixed Data Series X * * @return float|string */ - public static function COVAR($yValues, $xValues) + public static function COVAR(array $yValues, array $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -117,14 +117,14 @@ public static function COVAR($yValues, $xValues) * * @param mixed $xValue Float value of X for which we want to find Y * Or can be an array of values - * @param mixed $yValues array of mixed Data Series Y - * @param mixed $xValues of mixed Data Series X + * @param mixed[] $yValues array of mixed Data Series Y + * @param mixed[] $xValues array of mixed Data Series X * * @return array|bool|float|string * 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 FORECAST($xValue, $yValues, $xValues) + public static function FORECAST($xValue, array $yValues, array $xValues) { if (is_array($xValue)) { return self::evaluateArrayArgumentsSubset([self::class, __FUNCTION__], 1, $xValue, $yValues, $xValues); @@ -185,7 +185,7 @@ public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = * * @return float|string */ - public static function INTERCEPT($yValues, $xValues) + public static function INTERCEPT(array $yValues, array $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -210,9 +210,9 @@ public static function INTERCEPT($yValues, $xValues) * @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not * @param mixed $stats A logical (boolean) value specifying whether to return additional regression statistics * - * @return array|int|string The result, or a string containing an error + * @return array|string The result, or a string containing an error */ - public static function LINEST($yValues, $xValues = null, $const = true, $stats = false) + public static function LINEST(array $yValues, $xValues = null, $const = true, $stats = false): string|array { $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats); @@ -271,9 +271,9 @@ public static function LINEST($yValues, $xValues = null, $const = true, $stats = * @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not * @param mixed $stats A logical (boolean) value specifying whether to return additional regression statistics * - * @return array|int|string The result, or a string containing an error + * @return array|string The result, or a string containing an error */ - public static function LOGEST($yValues, $xValues = null, $const = true, $stats = false) + public static function LOGEST(array $yValues, $xValues = null, $const = true, $stats = false): string|array { $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats); @@ -338,7 +338,7 @@ public static function LOGEST($yValues, $xValues = null, $const = true, $stats = * * @return float|string The result, or a string containing an error */ - public static function RSQ($yValues, $xValues) + public static function RSQ(array $yValues, array $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -362,7 +362,7 @@ public static function RSQ($yValues, $xValues) * * @return float|string The result, or a string containing an error */ - public static function SLOPE($yValues, $xValues) + public static function SLOPE(array $yValues, array $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -386,7 +386,7 @@ public static function SLOPE($yValues, $xValues) * * @return float|string */ - public static function STEYX($yValues, $xValues) + public static function STEYX(array $yValues, array $xValues) { try { self::checkTrendArrays($yValues, $xValues); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Variances.php b/src/PhpSpreadsheet/Calculation/Statistical/Variances.php index 938e671bfb..2204623eed 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Variances.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Variances.php @@ -19,7 +19,7 @@ class Variances extends VarianceBase * * @return float|string (string if result is an error) */ - public static function VAR(...$args) + public static function VAR(...$args): float|string { $returnValue = ExcelError::DIV0(); @@ -61,7 +61,7 @@ public static function VAR(...$args) * * @return float|string (string if result is an error) */ - public static function VARA(...$args) + public static function VARA(...$args): string|float { $returnValue = ExcelError::DIV0(); @@ -107,7 +107,7 @@ public static function VARA(...$args) * * @return float|string (string if result is an error) */ - public static function VARP(...$args) + public static function VARP(...$args): float|string { // Return value $returnValue = ExcelError::DIV0(); @@ -150,7 +150,7 @@ public static function VARP(...$args) * * @return float|string (string if result is an error) */ - public static function VARPA(...$args) + public static function VARPA(...$args): string|float { $returnValue = ExcelError::DIV0(); diff --git a/src/PhpSpreadsheet/Calculation/TextData.php b/src/PhpSpreadsheet/Calculation/TextData.php index 7cc1c70daf..61df9494d1 100644 --- a/src/PhpSpreadsheet/Calculation/TextData.php +++ b/src/PhpSpreadsheet/Calculation/TextData.php @@ -49,10 +49,8 @@ public static function TRIMNONPRINTABLE($stringValue = '') * @see TextData\Trim::spaces() * * @param mixed $stringValue Value to check - * - * @return array|string */ - public static function TRIMSPACES($stringValue = '') + public static function TRIMSPACES($stringValue = ''): string|array { return TextData\Trim::spaces($stringValue); } @@ -68,7 +66,7 @@ public static function TRIMSPACES($stringValue = '') * * @return array|int|string A string if arguments are invalid */ - public static function ASCIICODE($characters) + public static function ASCIICODE($characters): string|int|array { return TextData\CharacterConvert::code($characters); } @@ -81,10 +79,8 @@ public static function ASCIICODE($characters) * @see TextData\Concatenate::CONCATENATE() * * @param array $args - * - * @return string */ - public static function CONCATENATE(...$args) + public static function CONCATENATE(...$args): string { return TextData\Concatenate::CONCATENATE(...$args); } @@ -174,10 +170,8 @@ public static function FIXEDFORMAT($value, $decimals = 2, $no_commas = false) * * @param array|string $value Value * @param array|int $chars Number of characters - * - * @return array|string */ - public static function LEFT($value = '', $chars = 1) + public static function LEFT($value = '', $chars = 1): string|array { return TextData\Extract::left($value, $chars); } @@ -192,10 +186,8 @@ public static function LEFT($value = '', $chars = 1) * @param array|string $value Value * @param array|int $start Start character * @param array|int $chars Number of characters - * - * @return array|string */ - public static function MID($value = '', $start = 1, $chars = null) + public static function MID($value = '', $start = 1, $chars = null): string|array { return TextData\Extract::mid($value, $start, $chars); } @@ -209,10 +201,8 @@ public static function MID($value = '', $start = 1, $chars = null) * * @param array|string $value Value * @param array|int $chars Number of characters - * - * @return array|string */ - public static function RIGHT($value = '', $chars = 1) + public static function RIGHT($value = '', $chars = 1): string|array { return TextData\Extract::right($value, $chars); } @@ -225,10 +215,8 @@ public static function RIGHT($value = '', $chars = 1) * @see TextData\Text::length() * * @param string $value Value - * - * @return array|int */ - public static function STRINGLENGTH($value = '') + public static function STRINGLENGTH($value = ''): int|array { return TextData\Text::length($value); } @@ -243,10 +231,8 @@ public static function STRINGLENGTH($value = '') * @see TextData\CaseConvert::lower() * * @param array|string $mixedCaseString - * - * @return array|string */ - public static function LOWERCASE($mixedCaseString) + public static function LOWERCASE($mixedCaseString): string|array { return TextData\CaseConvert::lower($mixedCaseString); } @@ -261,10 +247,8 @@ public static function LOWERCASE($mixedCaseString) * @see TextData\CaseConvert::upper() * * @param string $mixedCaseString - * - * @return array|string */ - public static function UPPERCASE($mixedCaseString) + public static function UPPERCASE($mixedCaseString): string|array { return TextData\CaseConvert::upper($mixedCaseString); } @@ -279,10 +263,8 @@ public static function UPPERCASE($mixedCaseString) * @see TextData\CaseConvert::proper() * * @param array|string $mixedCaseString - * - * @return array|string */ - public static function PROPERCASE($mixedCaseString) + public static function PROPERCASE($mixedCaseString): string|array { return TextData\CaseConvert::proper($mixedCaseString); } @@ -333,10 +315,8 @@ public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $ins * @see TextData\Text::test() * * @param mixed $testValue Value to check - * - * @return null|array|string */ - public static function RETURNSTRING($testValue = '') + public static function RETURNSTRING($testValue = ''): string|array { return TextData\Text::test($testValue); } @@ -403,10 +383,8 @@ public static function NUMBERVALUE($value = '', $decimalSeparator = null, $group * * @param mixed $value1 * @param mixed $value2 - * - * @return array|bool */ - public static function EXACT($value1, $value2) + public static function EXACT($value1, $value2): bool|array { return TextData\Text::exact($value1, $value2); } diff --git a/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php b/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php index f1aea16940..a80c5dd60e 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php +++ b/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php @@ -21,7 +21,7 @@ class CaseConvert * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function lower($mixedCaseValue) + public static function lower($mixedCaseValue): array|string { if (is_array($mixedCaseValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $mixedCaseValue); @@ -44,7 +44,7 @@ public static function lower($mixedCaseValue) * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function upper($mixedCaseValue) + public static function upper($mixedCaseValue): array|string { if (is_array($mixedCaseValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $mixedCaseValue); @@ -67,7 +67,7 @@ public static function upper($mixedCaseValue) * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function proper($mixedCaseValue) + public static function proper($mixedCaseValue): array|string { if (is_array($mixedCaseValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $mixedCaseValue); diff --git a/src/PhpSpreadsheet/Calculation/TextData/CharacterConvert.php b/src/PhpSpreadsheet/Calculation/TextData/CharacterConvert.php index 83af499bbf..4b8ab6e29c 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/CharacterConvert.php +++ b/src/PhpSpreadsheet/Calculation/TextData/CharacterConvert.php @@ -20,7 +20,7 @@ class CharacterConvert * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function character($character) + public static function character($character): array|string { if (is_array($character)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $character); @@ -46,7 +46,7 @@ public static function character($character) * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function code($characters) + public static function code($characters): array|string|int { if (is_array($characters)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $characters); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Concatenate.php b/src/PhpSpreadsheet/Calculation/TextData/Concatenate.php index 37c135df2f..df5167de21 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Concatenate.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Concatenate.php @@ -56,7 +56,7 @@ public static function CONCATENATE(...$args): string * If an array of values is passed for the $delimiter or $ignoreEmpty arguments, then the returned result * will also be an array with matching dimensions */ - public static function TEXTJOIN($delimiter = '', $ignoreEmpty = true, ...$args) + public static function TEXTJOIN($delimiter = '', $ignoreEmpty = true, ...$args): array|string { if (is_array($delimiter) || is_array($ignoreEmpty)) { return self::evaluateArrayArgumentsSubset( @@ -113,7 +113,7 @@ private static function evaluateTextJoinArray(bool $ignoreEmpty, array &$aArgs): * If an array of values is passed for the $stringValue or $repeatCount arguments, then the returned result * will also be an array with matching dimensions */ - public static function builtinREPT($stringValue, $repeatCount) + public static function builtinREPT($stringValue, $repeatCount): array|string { if (is_array($stringValue) || is_array($repeatCount)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $stringValue, $repeatCount); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Extract.php b/src/PhpSpreadsheet/Calculation/TextData/Extract.php index 24ddff2ec5..2dc46b02a7 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Extract.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Extract.php @@ -24,7 +24,7 @@ class Extract * If an array of values is passed for the $value or $chars arguments, then the returned result * will also be an array with matching dimensions */ - public static function left($value, $chars = 1) + public static function left($value, $chars = 1): array|string { if (is_array($value) || is_array($chars)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $chars); @@ -54,7 +54,7 @@ public static function left($value, $chars = 1) * If an array of values is passed for the $value, $start or $chars arguments, then the returned result * will also be an array with matching dimensions */ - public static function mid($value, $start, $chars) + public static function mid($value, $start, $chars): array|string { if (is_array($value) || is_array($start) || is_array($chars)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $start, $chars); @@ -83,7 +83,7 @@ public static function mid($value, $start, $chars) * If an array of values is passed for the $value or $chars arguments, then the returned result * will also be an array with matching dimensions */ - public static function right($value, $chars = 1) + public static function right($value, $chars = 1): array|string { if (is_array($value) || is_array($chars)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $chars); @@ -122,11 +122,11 @@ public static function right($value, $chars = 1) * The default is a #N/A Error * Or can be an array of values * - * @return mixed|mixed[] the string extracted from text before the delimiter; or the $ifNotFound value + * @return array|string the string extracted from text before the delimiter; or the $ifNotFound value * If an array of values is passed for any of the arguments, then the returned result * will also be an array with matching dimensions */ - public static function before($text, $delimiter, $instance = 1, $matchMode = 0, $matchEnd = 0, $ifNotFound = '#N/A') + public static function before($text, $delimiter, $instance = 1, $matchMode = 0, $matchEnd = 0, $ifNotFound = '#N/A'): array|string { if (is_array($text) || is_array($instance) || is_array($matchMode) || is_array($matchEnd) || is_array($ifNotFound)) { return self::evaluateArrayArgumentsIgnore([self::class, __FUNCTION__], 1, $text, $delimiter, $instance, $matchMode, $matchEnd, $ifNotFound); @@ -180,11 +180,11 @@ public static function before($text, $delimiter, $instance = 1, $matchMode = 0, * The default is a #N/A Error * Or can be an array of values * - * @return mixed|mixed[] the string extracted from text before the delimiter; or the $ifNotFound value + * @return array|string the string extracted from text before the delimiter; or the $ifNotFound value * If an array of values is passed for any of the arguments, then the returned result * will also be an array with matching dimensions */ - public static function after($text, $delimiter, $instance = 1, $matchMode = 0, $matchEnd = 0, $ifNotFound = '#N/A') + public static function after($text, $delimiter, $instance = 1, $matchMode = 0, $matchEnd = 0, $ifNotFound = '#N/A'): array|string { if (is_array($text) || is_array($instance) || is_array($matchMode) || is_array($matchEnd) || is_array($ifNotFound)) { return self::evaluateArrayArgumentsIgnore([self::class, __FUNCTION__], 1, $text, $delimiter, $instance, $matchMode, $matchEnd, $ifNotFound); @@ -218,13 +218,12 @@ public static function after($text, $delimiter, $instance = 1, $matchMode = 0, $ /** * @param null|array|string $delimiter - * @param int $matchMode * @param int $matchEnd * @param mixed $ifNotFound * * @return array|string */ - private static function validateTextBeforeAfter(string $text, $delimiter, int $instance, $matchMode, $matchEnd, $ifNotFound) + private static function validateTextBeforeAfter(string $text, $delimiter, int $instance, int $matchMode, $matchEnd, $ifNotFound) { $flags = self::matchFlags($matchMode); $delimiter = self::buildDelimiter($delimiter); @@ -260,7 +259,7 @@ private static function buildDelimiter($delimiter): string if (is_array($delimiter)) { $delimiter = Functions::flattenArray($delimiter); $quotedDelimiters = array_map( - function ($delimiter) { + function ($delimiter): string { return preg_quote($delimiter ?? '', '/'); }, $delimiter diff --git a/src/PhpSpreadsheet/Calculation/TextData/Format.php b/src/PhpSpreadsheet/Calculation/TextData/Format.php index 57d3316637..55e0a4710f 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Format.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Format.php @@ -78,7 +78,7 @@ public static function DOLLAR($value = 0, $decimals = 2) * If an array of values is passed for either of the arguments, then the returned result * will also be an array with matching dimensions */ - public static function FIXEDFORMAT($value, $decimals = 2, $noCommas = false) + public static function FIXEDFORMAT($value, $decimals = 2, $noCommas = false): array|string { if (is_array($value) || is_array($decimals) || is_array($noCommas)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $decimals, $noCommas); @@ -119,7 +119,7 @@ public static function FIXEDFORMAT($value, $decimals = 2, $noCommas = false) * If an array of values is passed for either of the arguments, then the returned result * will also be an array with matching dimensions */ - public static function TEXTFORMAT($value, $format) + public static function TEXTFORMAT($value, $format): array|string { if (is_array($value) || is_array($format)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $format); @@ -230,7 +230,7 @@ public static function VALUE($value = '') * If an array of values is passed for either of the arguments, then the returned result * will also be an array with matching dimensions */ - public static function valueToText($value, $format = false) + public static function valueToText($value, $format = false): array|string { if (is_array($value) || is_array($format)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $format); @@ -276,10 +276,8 @@ private static function getGroupSeparator($groupSeparator): string * Or can be an array of values * @param mixed $groupSeparator A string with the group/thousands separator to use, defaults to locale defined value * Or can be an array of values - * - * @return array|float|string */ - public static function NUMBERVALUE($value = '', $decimalSeparator = null, $groupSeparator = null) + public static function NUMBERVALUE($value = '', $decimalSeparator = null, $groupSeparator = null): array|string|float { if (is_array($value) || is_array($decimalSeparator) || is_array($groupSeparator)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $decimalSeparator, $groupSeparator); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Replace.php b/src/PhpSpreadsheet/Calculation/TextData/Replace.php index 124f001703..e10f5b8bb6 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Replace.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Replace.php @@ -29,7 +29,7 @@ class Replace * If an array of values is passed for either of the arguments, then the returned result * will also be an array with matching dimensions */ - public static function replace($oldText, $start, $chars, $newText) + public static function replace($oldText, $start, $chars, $newText): array|string { if (is_array($oldText) || is_array($start) || is_array($chars) || is_array($newText)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $oldText, $start, $chars, $newText); @@ -70,7 +70,7 @@ public static function replace($oldText, $start, $chars, $newText) * If an array of values is passed for either of the arguments, then the returned result * will also be an array with matching dimensions */ - public static function substitute($text = '', $fromText = '', $toText = '', $instance = null) + public static function substitute($text = '', $fromText = '', $toText = '', $instance = null): array|string { if (is_array($text) || is_array($fromText) || is_array($toText) || is_array($instance)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $text, $fromText, $toText, $instance); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Search.php b/src/PhpSpreadsheet/Calculation/TextData/Search.php index 10b6a1aadf..8eecf1679b 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Search.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Search.php @@ -25,7 +25,7 @@ class Search * If an array of values is passed for the $value or $chars arguments, then the returned result * will also be an array with matching dimensions */ - public static function sensitive($needle, $haystack, $offset = 1) + public static function sensitive($needle, $haystack, $offset = 1): array|string|int { if (is_array($needle) || is_array($haystack) || is_array($offset)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $needle, $haystack, $offset); @@ -67,7 +67,7 @@ public static function sensitive($needle, $haystack, $offset = 1) * If an array of values is passed for the $value or $chars arguments, then the returned result * will also be an array with matching dimensions */ - public static function insensitive($needle, $haystack, $offset = 1) + public static function insensitive($needle, $haystack, $offset = 1): array|string|int { if (is_array($needle) || is_array($haystack) || is_array($offset)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $needle, $haystack, $offset); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Text.php b/src/PhpSpreadsheet/Calculation/TextData/Text.php index b8a730767c..2d49c00976 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Text.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Text.php @@ -21,7 +21,7 @@ class Text * If an array of values is passed for the argument, then the returned result * will also be an array with matching dimensions */ - public static function length($value = '') + public static function length($value = ''): array|int { if (is_array($value)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $value); @@ -46,7 +46,7 @@ public static function length($value = '') * If an array of values is passed for either of the arguments, then the returned result * will also be an array with matching dimensions */ - public static function exact($value1, $value2) + public static function exact($value1, $value2): array|bool { if (is_array($value1) || is_array($value2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value1, $value2); @@ -68,7 +68,7 @@ public static function exact($value1, $value2) * If an array of values is passed for the argument, then the returned result * will also be an array with matching dimensions */ - public static function test($testValue = '') + public static function test($testValue = ''): array|string { if (is_array($testValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $testValue); @@ -102,7 +102,7 @@ public static function test($testValue = '') * * @return array the array built from the text, split by the row and column delimiters */ - public static function split($text, $columnDelimiter = null, $rowDelimiter = null, bool $ignoreEmpty = false, bool $matchMode = true, $padding = '#N/A') + public static function split($text, $columnDelimiter = null, $rowDelimiter = null, bool $ignoreEmpty = false, bool $matchMode = true, $padding = '#N/A'): array { $text = Functions::flattenSingleValue($text); @@ -121,7 +121,7 @@ public static function split($text, $columnDelimiter = null, $rowDelimiter = nul if ($ignoreEmpty === true) { $rows = array_values(array_filter( $rows, - function ($row) { + function ($row): bool { return $row !== ''; } )); @@ -139,7 +139,7 @@ function (&$row) use ($delimiter, $flags, $ignoreEmpty): void { if ($ignoreEmpty === true) { $row = array_values(array_filter( $row, - function ($value) { + function ($value): bool { return $value !== ''; } )); @@ -149,7 +149,7 @@ function ($value) { if ($ignoreEmpty === true) { $rows = array_values(array_filter( $rows, - function ($row) { + function ($row): bool { return $row !== [] && $row !== ['']; } )); @@ -192,7 +192,7 @@ private static function buildDelimiter($delimiter): string if (is_array($delimiter) && count($valueSet) > 1) { $quotedDelimiters = array_map( - function ($delimiter) { + function ($delimiter): string { return preg_quote($delimiter ?? '', '/'); }, $valueSet @@ -239,10 +239,7 @@ private static function formatValueMode0($cellValue): string return (string) $cellValue; } - /** - * @param mixed $cellValue - */ - private static function formatValueMode1($cellValue): string + private static function formatValueMode1(mixed $cellValue): string { if (is_string($cellValue) && ErrorValue::isError($cellValue) === false) { return Calculation::FORMULA_STRING_QUOTE . $cellValue . Calculation::FORMULA_STRING_QUOTE; diff --git a/src/PhpSpreadsheet/Calculation/TextData/Trim.php b/src/PhpSpreadsheet/Calculation/TextData/Trim.php index 27eceb9388..96c29d1d49 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Trim.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Trim.php @@ -39,7 +39,7 @@ public static function nonPrintable($stringValue = '') * If an array of values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function spaces($stringValue = '') + public static function spaces($stringValue = ''): array|string { if (is_array($stringValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $stringValue); diff --git a/src/PhpSpreadsheet/Calculation/Token/Stack.php b/src/PhpSpreadsheet/Calculation/Token/Stack.php index e8289e3fb6..ae3ab2fe96 100644 --- a/src/PhpSpreadsheet/Calculation/Token/Stack.php +++ b/src/PhpSpreadsheet/Calculation/Token/Stack.php @@ -7,10 +7,7 @@ class Stack { - /** - * @var BranchPruner - */ - private $branchPruner; + private BranchPruner $branchPruner; /** * The parser stack for formulae. diff --git a/src/PhpSpreadsheet/Calculation/Web/Service.php b/src/PhpSpreadsheet/Calculation/Web/Service.php index 697d3a6143..3b1bea945e 100644 --- a/src/PhpSpreadsheet/Calculation/Web/Service.php +++ b/src/PhpSpreadsheet/Calculation/Web/Service.php @@ -64,7 +64,7 @@ public static function webService(string $url) * * @return string the url encoded output */ - public static function urlEncode($text) + public static function urlEncode($text): string|array { if (!is_string($text)) { return ExcelError::VALUE(); diff --git a/src/PhpSpreadsheet/Cell/AddressHelper.php b/src/PhpSpreadsheet/Cell/AddressHelper.php index ed765aa594..98b8e27c43 100644 --- a/src/PhpSpreadsheet/Cell/AddressHelper.php +++ b/src/PhpSpreadsheet/Cell/AddressHelper.php @@ -11,7 +11,7 @@ class AddressHelper public const R1C1_COORDINATE_REGEX = '/(R((?:\[-?\d*\])|(?:\d*))?)(C((?:\[-?\d*\])|(?:\d*))?)/i'; /** @return string[] */ - public static function getRowAndColumnChars() + public static function getRowAndColumnChars(): array { $rowChar = 'R'; $colChar = 'C'; diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index 36f27a27ae..6a532892b5 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -45,17 +45,15 @@ class Cell /** * Type of the cell data. - * - * @var string */ - private $dataType; + private string $dataType; /** * The collection of cells that this cell belongs to (i.e. The Cell Collection for the parent Worksheet). * * @var ?Cells */ - private $parent; + private ?Cells $parent; /** * Index to the cellXf reference for the styling of this cell. @@ -71,8 +69,7 @@ class Cell */ private $formulaAttributes; - /** @var IgnoredErrors */ - private $ignoredErrors; + private IgnoredErrors $ignoredErrors; /** * Update the cell into the cell collection. @@ -127,10 +124,8 @@ public function __construct($value, ?string $dataType, Worksheet $worksheet) /** * Get cell coordinate column. - * - * @return string */ - public function getColumn() + public function getColumn(): string { $parent = $this->parent; if ($parent === null) { @@ -142,10 +137,8 @@ public function getColumn() /** * Get cell coordinate row. - * - * @return int */ - public function getRow() + public function getRow(): int { $parent = $this->parent; if ($parent === null) { @@ -790,10 +783,8 @@ public function getFormulaAttributes() /** * Convert to string. - * - * @return string */ - public function __toString() + public function __toString(): string { return (string) $this->getValue(); } diff --git a/src/PhpSpreadsheet/Cell/CellAddress.php b/src/PhpSpreadsheet/Cell/CellAddress.php index a0c544f284..a5db0c2177 100644 --- a/src/PhpSpreadsheet/Cell/CellAddress.php +++ b/src/PhpSpreadsheet/Cell/CellAddress.php @@ -7,30 +7,15 @@ class CellAddress { - /** - * @var ?Worksheet - */ - protected $worksheet; + protected ?Worksheet $worksheet; - /** - * @var string - */ - protected $cellAddress; + protected string $cellAddress; - /** - * @var string - */ - protected $columnName; + protected string $columnName = ''; - /** - * @var int - */ - protected $columnId; + protected int $columnId; - /** - * @var int - */ - protected $rowId; + protected int $rowId; public function __construct(string $cellAddress, ?Worksheet $worksheet = null) { @@ -159,7 +144,7 @@ public function previousColumn(int $offset = 1): self * (ie. if a Worksheet was provided to the constructor). * e.g. "'Mark''s Worksheet'!C5". */ - public function __toString() + public function __toString(): string { return $this->fullCellAddress(); } diff --git a/src/PhpSpreadsheet/Cell/ColumnRange.php b/src/PhpSpreadsheet/Cell/ColumnRange.php index 1e521a1319..a5e256f974 100644 --- a/src/PhpSpreadsheet/Cell/ColumnRange.php +++ b/src/PhpSpreadsheet/Cell/ColumnRange.php @@ -6,20 +6,11 @@ class ColumnRange implements AddressRange { - /** - * @var ?Worksheet - */ - protected $worksheet; + protected ?Worksheet $worksheet; - /** - * @var int - */ - protected $from; + protected int $from; - /** - * @var int - */ - protected $to; + protected int $to; public function __construct(string $from, ?string $to = null, ?Worksheet $worksheet = null) { diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index a89de85bd1..9f4df6d7e0 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -29,7 +29,7 @@ abstract class Coordinate * * @return array{0: string, 1: string} Array containing column and row (indexes 0 and 1) */ - public static function coordinateFromString($cellAddress): array + public static function coordinateFromString(string $cellAddress): array { if (preg_match(self::A1_COORDINATE_REGEX, $cellAddress, $matches)) { return [$matches['col'], $matches['row']]; @@ -68,7 +68,7 @@ public static function indexesFromString(string $coordinates): array * * @return bool Whether the coordinate represents a range of cells */ - public static function coordinateIsRange($cellAddress) + public static function coordinateIsRange($cellAddress): bool { return (strpos($cellAddress, ':') !== false) || (strpos($cellAddress, ',') !== false); } @@ -111,7 +111,7 @@ public static function absoluteReference($cellAddress) * * @return string Absolute coordinate e.g. '$A$1' */ - public static function absoluteCoordinate($cellAddress) + public static function absoluteCoordinate(string $cellAddress) { if (self::coordinateIsRange($cellAddress)) { throw new Exception('Cell coordinate string can not be a range of cells'); @@ -124,7 +124,7 @@ public static function absoluteCoordinate($cellAddress) } // Create absolute coordinate - [$column, $row] = self::coordinateFromString($cellAddress); + [$column, $row] = self::coordinateFromString($cellAddress); // @phpstan-ignore-line $column = ltrim($column, '$'); $row = ltrim($row, '$'); @@ -233,7 +233,7 @@ public static function rangeBoundaries(string $range): array * * @return array Range dimension (width, height) */ - public static function rangeDimension($range) + public static function rangeDimension(string $range) { // Calculate range outer borders [$rangeStart, $rangeEnd] = self::rangeBoundaries($range); @@ -249,7 +249,7 @@ public static function rangeDimension($range) * @return array Range coordinates [Start Cell, End Cell] * where Start Cell and End Cell are arrays [Column ID, Row Number] */ - public static function getRangeBoundaries($range) + public static function getRangeBoundaries(string $range) { [$rangeA, $rangeB] = self::rangeBoundaries($range); @@ -266,7 +266,7 @@ public static function getRangeBoundaries($range) * * @return int Column index (A = 1) */ - public static function columnIndexFromString($columnAddress) + public static function columnIndexFromString(?string $columnAddress): int { // Using a lookup cache adds a slight memory overhead, but boosts speed // caching using a static within the method is faster than a class static, @@ -356,14 +356,14 @@ public static function extractAllCellReferencesInRange($cellRange): array [$worksheet, $cellRange] = Worksheet::extractSheetTitle($cellRange, true); $quoted = ''; - if ($worksheet > '') { + if ($worksheet) { $quoted = Worksheet::nameRequiresQuotes($worksheet) ? "'" : ''; if (substr($worksheet, 0, 1) === "'" && substr($worksheet, -1, 1) === "'") { $worksheet = substr($worksheet, 1, -1); } $worksheet = str_replace("'", "''", $worksheet); } - [$ranges, $operators] = self::getCellBlocksFromRangeString($cellRange); + [$ranges, $operators] = self::getCellBlocksFromRangeString($cellRange); // @phpstan-ignore-line $cells = []; foreach ($ranges as $range) { @@ -594,7 +594,7 @@ private static function getCellBlocksFromRangeString($rangeString) * @param int $currentRow * @param int $endRow */ - private static function validateRange($cellBlock, $startColumnIndex, $endColumnIndex, $currentRow, $endRow): void + private static function validateRange(string $cellBlock, $startColumnIndex, $endColumnIndex, $currentRow, $endRow): void { if ($startColumnIndex >= $endColumnIndex || $currentRow > $endRow) { throw new Exception('Invalid range: "' . $cellBlock . '"'); diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php index f19984db6a..501475441a 100644 --- a/src/PhpSpreadsheet/Cell/DataType.php +++ b/src/PhpSpreadsheet/Cell/DataType.php @@ -53,7 +53,7 @@ public static function getErrorCodes() * * @return RichText|string Sanitized value */ - public static function checkString($textValue) + public static function checkString($textValue): RichText|string|array { if ($textValue instanceof RichText) { // TODO: Sanitize Rich-Text string (max. character count is 32,767) @@ -76,7 +76,7 @@ public static function checkString($textValue) * * @return string Sanitized value */ - public static function checkErrorCode($value) + public static function checkErrorCode($value): string { $value = (string) $value; diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php index 7ee53eae07..21d41c8dc3 100644 --- a/src/PhpSpreadsheet/Cell/DataValidation.php +++ b/src/PhpSpreadsheet/Cell/DataValidation.php @@ -144,7 +144,7 @@ public function getFormula1() * * @return $this */ - public function setFormula1($formula) + public function setFormula1($formula): static { $this->formula1 = $formula; @@ -168,7 +168,7 @@ public function getFormula2() * * @return $this */ - public function setFormula2($formula) + public function setFormula2($formula): static { $this->formula2 = $formula; @@ -192,7 +192,7 @@ public function getType() * * @return $this */ - public function setType($type) + public function setType($type): static { $this->type = $type; @@ -216,7 +216,7 @@ public function getErrorStyle() * * @return $this */ - public function setErrorStyle($errorStyle) + public function setErrorStyle($errorStyle): static { $this->errorStyle = $errorStyle; @@ -240,7 +240,7 @@ public function getOperator() * * @return $this */ - public function setOperator($operator) + public function setOperator($operator): static { $this->operator = $operator; @@ -264,7 +264,7 @@ public function getAllowBlank() * * @return $this */ - public function setAllowBlank($allowBlank) + public function setAllowBlank($allowBlank): static { $this->allowBlank = $allowBlank; @@ -288,7 +288,7 @@ public function getShowDropDown() * * @return $this */ - public function setShowDropDown($showDropDown) + public function setShowDropDown($showDropDown): static { $this->showDropDown = $showDropDown; @@ -312,7 +312,7 @@ public function getShowInputMessage() * * @return $this */ - public function setShowInputMessage($showInputMessage) + public function setShowInputMessage($showInputMessage): static { $this->showInputMessage = $showInputMessage; @@ -336,7 +336,7 @@ public function getShowErrorMessage() * * @return $this */ - public function setShowErrorMessage($showErrorMessage) + public function setShowErrorMessage($showErrorMessage): static { $this->showErrorMessage = $showErrorMessage; @@ -360,7 +360,7 @@ public function getErrorTitle() * * @return $this */ - public function setErrorTitle($errorTitle) + public function setErrorTitle($errorTitle): static { $this->errorTitle = $errorTitle; @@ -384,7 +384,7 @@ public function getError() * * @return $this */ - public function setError($error) + public function setError($error): static { $this->error = $error; @@ -408,7 +408,7 @@ public function getPromptTitle() * * @return $this */ - public function setPromptTitle($promptTitle) + public function setPromptTitle($promptTitle): static { $this->promptTitle = $promptTitle; @@ -432,7 +432,7 @@ public function getPrompt() * * @return $this */ - public function setPrompt($prompt) + public function setPrompt($prompt): static { $this->prompt = $prompt; @@ -444,7 +444,7 @@ public function setPrompt($prompt) * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->formula1 . @@ -480,8 +480,7 @@ public function __clone() } } - /** @var ?string */ - private $sqref; + private ?string $sqref = null; public function getSqref(): ?string { diff --git a/src/PhpSpreadsheet/Cell/DataValidator.php b/src/PhpSpreadsheet/Cell/DataValidator.php index 692f316ec0..90f0fce61b 100644 --- a/src/PhpSpreadsheet/Cell/DataValidator.php +++ b/src/PhpSpreadsheet/Cell/DataValidator.php @@ -15,10 +15,8 @@ class DataValidator * Does this cell contain valid value? * * @param Cell $cell Cell to check the value - * - * @return bool */ - public function isValid(Cell $cell) + public function isValid(Cell $cell): bool { if (!$cell->hasDataValidation() || $cell->getDataValidation()->getType() === DataValidation::TYPE_NONE) { return true; @@ -54,8 +52,7 @@ public function isValid(Cell $cell) return $returnValue; } - /** @param float|int $cellValue */ - private function numericOperator(DataValidation $dataValidation, $cellValue): bool + private function numericOperator(DataValidation $dataValidation, int|float $cellValue): bool { $operator = $dataValidation->getOperator(); $formula1 = $dataValidation->getFormula1(); @@ -86,10 +83,8 @@ private function numericOperator(DataValidation $dataValidation, $cellValue): bo * Does this cell contain valid value, based on list? * * @param Cell $cell Cell to check the value - * - * @return bool */ - private function isValueInList(Cell $cell) + private function isValueInList(Cell $cell): bool { $cellValue = $cell->getValue(); $dataValidation = $cell->getDataValidation(); diff --git a/src/PhpSpreadsheet/Cell/Hyperlink.php b/src/PhpSpreadsheet/Cell/Hyperlink.php index ffdcbacd27..14f3644611 100644 --- a/src/PhpSpreadsheet/Cell/Hyperlink.php +++ b/src/PhpSpreadsheet/Cell/Hyperlink.php @@ -48,7 +48,7 @@ public function getUrl() * * @return $this */ - public function setUrl($url) + public function setUrl($url): static { $this->url = $url; @@ -72,7 +72,7 @@ public function getTooltip() * * @return $this */ - public function setTooltip($tooltip) + public function setTooltip($tooltip): static { $this->tooltip = $tooltip; @@ -81,18 +81,13 @@ public function setTooltip($tooltip) /** * Is this hyperlink internal? (to another worksheet). - * - * @return bool */ - public function isInternal() + public function isInternal(): bool { return strpos($this->url, 'sheet://') !== false; } - /** - * @return string - */ - public function getTypeHyperlink() + public function getTypeHyperlink(): string { return $this->isInternal() ? '' : 'External'; } @@ -102,7 +97,7 @@ public function getTypeHyperlink() * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->url . diff --git a/src/PhpSpreadsheet/Cell/RowRange.php b/src/PhpSpreadsheet/Cell/RowRange.php index 38e6c1415b..61c82dd250 100644 --- a/src/PhpSpreadsheet/Cell/RowRange.php +++ b/src/PhpSpreadsheet/Cell/RowRange.php @@ -6,20 +6,11 @@ class RowRange implements AddressRange { - /** - * @var ?Worksheet - */ - protected $worksheet; - - /** - * @var int - */ - protected $from; - - /** - * @var int - */ - protected $to; + protected ?Worksheet $worksheet; + + protected int $from; + + protected int $to; public function __construct(int $from, ?int $to = null, ?Worksheet $worksheet = null) { diff --git a/src/PhpSpreadsheet/Cell/StringValueBinder.php b/src/PhpSpreadsheet/Cell/StringValueBinder.php index 1dcb6129c7..5250213753 100644 --- a/src/PhpSpreadsheet/Cell/StringValueBinder.php +++ b/src/PhpSpreadsheet/Cell/StringValueBinder.php @@ -77,7 +77,7 @@ public function setConversionForAllValueTypes(bool $suppressConversion = false): * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell */ - public function bindValue(Cell $cell, $value) + public function bindValue(Cell $cell, $value): bool { if (is_object($value)) { return $this->bindObjectValue($cell, $value); diff --git a/src/PhpSpreadsheet/CellReferenceHelper.php b/src/PhpSpreadsheet/CellReferenceHelper.php index 6e036354f0..2bb0c8a2df 100644 --- a/src/PhpSpreadsheet/CellReferenceHelper.php +++ b/src/PhpSpreadsheet/CellReferenceHelper.php @@ -7,30 +7,15 @@ class CellReferenceHelper { - /** - * @var string - */ - protected $beforeCellAddress; - - /** - * @var int - */ - protected $beforeColumn; - - /** - * @var int - */ - protected $beforeRow; - - /** - * @var int - */ - protected $numberOfColumns; - - /** - * @var int - */ - protected $numberOfRows; + protected string $beforeCellAddress; + + protected int $beforeColumn; + + protected int $beforeRow; + + protected int $numberOfColumns; + + protected int $numberOfRows; public function __construct(string $beforeCellAddress = 'A1', int $numberOfColumns = 0, int $numberOfRows = 0) { @@ -40,7 +25,7 @@ public function __construct(string $beforeCellAddress = 'A1', int $numberOfColum // Get coordinate of $beforeCellAddress [$beforeColumn, $beforeRow] = Coordinate::coordinateFromString($beforeCellAddress); - $this->beforeColumn = (int) Coordinate::columnIndexFromString($beforeColumn); + $this->beforeColumn = Coordinate::columnIndexFromString($beforeColumn); $this->beforeRow = (int) $beforeRow; } @@ -64,7 +49,7 @@ public function updateCellReference(string $cellReference = 'A1', bool $includeA // Get coordinate of $cellReference [$newColumn, $newRow] = Coordinate::coordinateFromString($cellReference); - $newColumnIndex = (int) Coordinate::columnIndexFromString(str_replace('$', '', $newColumn)); + $newColumnIndex = Coordinate::columnIndexFromString(str_replace('$', '', $newColumn)); $newRowIndex = (int) str_replace('$', '', $newRow); $absoluteColumn = $newColumn[0] === '$' ? '$' : ''; diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index 3d48134684..dd77dac967 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -26,17 +26,13 @@ public function __construct() /** * Chart Major Gridlines as. - * - * @var ?GridLines */ - private $majorGridlines; + private ?GridLines $majorGridlines = null; /** * Chart Minor Gridlines as. - * - * @var ?GridLines */ - private $minorGridlines; + private ?GridLines $minorGridlines = null; /** * Axis Number. @@ -49,11 +45,9 @@ public function __construct() 'numeric' => null, ]; - /** @var string */ - private $axisType = ''; + private string $axisType = ''; - /** @var ?AxisText */ - private $axisText; + private ?AxisText $axisText = null; /** * Axis Options. @@ -80,10 +74,8 @@ public function __construct() /** * Fill Properties. - * - * @var ChartColor */ - private $fillColor; + private ChartColor $fillColor; private const NUMERIC_FORMAT = [ Properties::FORMAT_CODE_NUMBER, @@ -123,10 +115,8 @@ public function getAxisNumberFormat() /** * Get Axis Number Source Linked. - * - * @return string */ - public function getAxisNumberSourceLinked() + public function getAxisNumberSourceLinked(): string { return (string) $this->axisNumber['source_linked']; } @@ -233,7 +223,7 @@ public function setAxisType(string $type): self * @param ?int $alpha * @param ?string $AlphaType */ - public function setFillParameters($color, $alpha = null, $AlphaType = ChartColor::EXCEL_COLOR_TYPE_RGB): void + public function setFillParameters(?string $color, $alpha = null, ?string $AlphaType = ChartColor::EXCEL_COLOR_TYPE_RGB): void { $this->fillColor->setColorProperties($color, $alpha, $AlphaType); } @@ -242,10 +232,8 @@ public function setFillParameters($color, $alpha = null, $AlphaType = ChartColor * Get Fill Property. * * @param string $property - * - * @return string */ - public function getFillProperty($property) + public function getFillProperty($property): string { return (string) $this->fillColor->getColorProperty($property); } @@ -271,8 +259,7 @@ public function getLineProperty($propertyName) return $this->getLineColorProperty($propertyName); } - /** @var string */ - private $crossBetween = ''; // 'between' or 'midCat' might be better + private string $crossBetween = ''; // 'between' or 'midCat' might be better public function setCrossBetween(string $crossBetween): self { diff --git a/src/PhpSpreadsheet/Chart/AxisText.php b/src/PhpSpreadsheet/Chart/AxisText.php index cd9ba2ce29..e06a2c88a8 100644 --- a/src/PhpSpreadsheet/Chart/AxisText.php +++ b/src/PhpSpreadsheet/Chart/AxisText.php @@ -6,11 +6,9 @@ class AxisText extends Properties { - /** @var ?int */ - private $rotation; + private ?int $rotation = null; - /** @var Font */ - private $font; + private Font $font; public function __construct() { diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index 38c69a4636..1cb6d6fe20 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -16,45 +16,33 @@ class Chart /** * Worksheet. - * - * @var ?Worksheet */ - private $worksheet; + private ?Worksheet $worksheet = null; /** * Chart Title. - * - * @var ?Title */ - private $title; + private ?Title $title; /** * Chart Legend. - * - * @var ?Legend */ - private $legend; + private ?Legend $legend; /** * X-Axis Label. - * - * @var ?Title */ - private $xAxisLabel; + private ?Title $xAxisLabel; /** * Y-Axis Label. - * - * @var ?Title */ - private $yAxisLabel; + private ?Title $yAxisLabel; /** * Chart Plot Area. - * - * @var ?PlotArea */ - private $plotArea; + private ?PlotArea $plotArea; /** * Plot Visible Only. @@ -72,17 +60,13 @@ class Chart /** * Chart Asix Y as. - * - * @var Axis */ - private $yAxis; + private Axis $yAxis; /** * Chart Asix X as. - * - * @var Axis */ - private $xAxis; + private Axis $xAxis; /** * Top-Left Cell Position. @@ -107,10 +91,8 @@ class Chart /** * Bottom-Right Cell Position. - * - * @var string */ - private $bottomRightCellRef = ''; + private string $bottomRightCellRef = ''; /** * Bottom-Right X-Offset. @@ -126,17 +108,13 @@ class Chart */ private $bottomRightYOffset = 10; - /** @var ?int */ - private $rotX; + private ?int $rotX = null; - /** @var ?int */ - private $rotY; + private ?int $rotY = null; - /** @var ?int */ - private $rAngAx; + private ?int $rAngAx = null; - /** @var ?int */ - private $perspective; + private ?int $perspective = null; /** @var bool */ private $oneCellAnchor = false; @@ -150,11 +128,9 @@ class Chart /** @var bool */ private $roundedCorners = false; - /** @var GridLines */ - private $borderLines; + private GridLines $borderLines; - /** @var ChartColor */ - private $fillColor; + private ChartColor $fillColor; /** * Create a new Chart. @@ -216,7 +192,7 @@ public function getWorksheet(): ?Worksheet * * @return $this */ - public function setWorksheet(?Worksheet $worksheet = null) + public function setWorksheet(?Worksheet $worksheet = null): static { $this->worksheet = $worksheet; @@ -233,7 +209,7 @@ public function getTitle(): ?Title * * @return $this */ - public function setTitle(Title $title) + public function setTitle(Title $title): static { $this->title = $title; @@ -250,7 +226,7 @@ public function getLegend(): ?Legend * * @return $this */ - public function setLegend(Legend $legend) + public function setLegend(Legend $legend): static { $this->legend = $legend; @@ -267,7 +243,7 @@ public function getXAxisLabel(): ?Title * * @return $this */ - public function setXAxisLabel(Title $label) + public function setXAxisLabel(Title $label): static { $this->xAxisLabel = $label; @@ -284,7 +260,7 @@ public function getYAxisLabel(): ?Title * * @return $this */ - public function setYAxisLabel(Title $label) + public function setYAxisLabel(Title $label): static { $this->yAxisLabel = $label; @@ -323,7 +299,7 @@ public function getPlotVisibleOnly() * * @return $this */ - public function setPlotVisibleOnly($plotVisibleOnly) + public function setPlotVisibleOnly($plotVisibleOnly): static { $this->plotVisibleOnly = $plotVisibleOnly; @@ -347,7 +323,7 @@ public function getDisplayBlanksAs() * * @return $this */ - public function setDisplayBlanksAs($displayBlanksAs) + public function setDisplayBlanksAs($displayBlanksAs): static { $this->displayBlanksAs = $displayBlanksAs; @@ -419,7 +395,7 @@ public function getMinorGridlines(): ?GridLines * * @return $this */ - public function setTopLeftPosition($cellAddress, $xOffset = null, $yOffset = null) + public function setTopLeftPosition($cellAddress, $xOffset = null, $yOffset = null): static { $this->topLeftCellRef = $cellAddress; if ($xOffset !== null) { @@ -465,7 +441,7 @@ public function getTopLeftCell() * * @return $this */ - public function setTopLeftCell($cellAddress) + public function setTopLeftCell($cellAddress): static { $this->topLeftCellRef = $cellAddress; @@ -480,7 +456,7 @@ public function setTopLeftCell($cellAddress) * * @return $this */ - public function setTopLeftOffset($xOffset, $yOffset) + public function setTopLeftOffset($xOffset, $yOffset): static { if ($xOffset !== null) { $this->setTopLeftXOffset($xOffset); @@ -498,7 +474,7 @@ public function setTopLeftOffset($xOffset, $yOffset) * * @return int[] */ - public function getTopLeftOffset() + public function getTopLeftOffset(): array { return [ 'X' => $this->topLeftXOffset, @@ -511,7 +487,7 @@ public function getTopLeftOffset() * * @return $this */ - public function setTopLeftXOffset($xOffset) + public function setTopLeftXOffset($xOffset): static { $this->topLeftXOffset = $xOffset; @@ -528,7 +504,7 @@ public function getTopLeftXOffset(): int * * @return $this */ - public function setTopLeftYOffset($yOffset) + public function setTopLeftYOffset($yOffset): static { $this->topLeftYOffset = $yOffset; @@ -549,7 +525,7 @@ public function getTopLeftYOffset(): int * * @return $this */ - public function setBottomRightPosition($cellAddress = '', $xOffset = null, $yOffset = null) + public function setBottomRightPosition($cellAddress = '', $xOffset = null, $yOffset = null): static { $this->bottomRightCellRef = $cellAddress; if ($xOffset !== null) { @@ -567,7 +543,7 @@ public function setBottomRightPosition($cellAddress = '', $xOffset = null, $yOff * * @return array an associative array containing the cell address, X-Offset and Y-Offset from the top left of that cell */ - public function getBottomRightPosition() + public function getBottomRightPosition(): array { return [ 'cell' => $this->bottomRightCellRef, @@ -581,7 +557,7 @@ public function getBottomRightPosition() * * @return $this */ - public function setBottomRightCell(string $cellAddress = '') + public function setBottomRightCell(string $cellAddress = ''): static { $this->bottomRightCellRef = $cellAddress; @@ -604,7 +580,7 @@ public function getBottomRightCell(): string * * @return $this */ - public function setBottomRightOffset($xOffset, $yOffset) + public function setBottomRightOffset($xOffset, $yOffset): static { if ($xOffset !== null) { $this->setBottomRightXOffset($xOffset); @@ -622,7 +598,7 @@ public function setBottomRightOffset($xOffset, $yOffset) * * @return int[] */ - public function getBottomRightOffset() + public function getBottomRightOffset(): array { return [ 'X' => $this->bottomRightXOffset, @@ -635,7 +611,7 @@ public function getBottomRightOffset() * * @return $this */ - public function setBottomRightXOffset($xOffset) + public function setBottomRightXOffset($xOffset): static { $this->bottomRightXOffset = $xOffset; @@ -652,7 +628,7 @@ public function getBottomRightXOffset(): int * * @return $this */ - public function setBottomRightYOffset($yOffset) + public function setBottomRightYOffset($yOffset): static { $this->bottomRightYOffset = $yOffset; diff --git a/src/PhpSpreadsheet/Chart/ChartColor.php b/src/PhpSpreadsheet/Chart/ChartColor.php index 87f3102009..df08adb5d2 100644 --- a/src/PhpSpreadsheet/Chart/ChartColor.php +++ b/src/PhpSpreadsheet/Chart/ChartColor.php @@ -15,17 +15,13 @@ class ChartColor self::EXCEL_COLOR_TYPE_STANDARD, ]; - /** @var string */ - private $value = ''; + private string $value = ''; - /** @var string */ - private $type = ''; + private string $type = ''; - /** @var ?int */ - private $alpha; + private ?int $alpha = null; - /** @var ?int */ - private $brightness; + private ?int $brightness = null; /** * @param string|string[] $value diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index 5d33e96d09..a290eff2f0 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -77,21 +77,21 @@ class DataSeries * * @var int[] */ - private $plotOrder = []; + private array $plotOrder; /** * Plot Label. * * @var DataSeriesValues[] */ - private $plotLabel = []; + private array $plotLabel; /** * Plot Category. * * @var DataSeriesValues[] */ - private $plotCategory = []; + private array $plotCategory; /** * Smooth Line. Must be specified for both DataSeries and DataSeriesValues. @@ -105,7 +105,7 @@ class DataSeries * * @var DataSeriesValues[] */ - private $plotValues = []; + private array $plotValues; /** * Plot Bubble Sizes. @@ -170,7 +170,7 @@ public function getPlotType() * * @return $this */ - public function setPlotType($plotType) + public function setPlotType($plotType): static { $this->plotType = $plotType; @@ -194,7 +194,7 @@ public function getPlotGrouping() * * @return $this */ - public function setPlotGrouping($groupingType) + public function setPlotGrouping($groupingType): static { $this->plotGrouping = $groupingType; @@ -218,7 +218,7 @@ public function getPlotDirection() * * @return $this */ - public function setPlotDirection($plotDirection) + public function setPlotDirection($plotDirection): static { $this->plotDirection = $plotDirection; @@ -308,7 +308,7 @@ public function getPlotStyle() * * @return $this */ - public function setPlotStyle($plotStyle) + public function setPlotStyle($plotStyle): static { $this->plotStyle = $plotStyle; @@ -366,10 +366,8 @@ public function setPlotBubbleSizes(array $plotBubbleSizes): self /** * Get Number of Plot Series. - * - * @return int */ - public function getPlotSeriesCount() + public function getPlotSeriesCount(): int { return count($this->plotValues); } @@ -391,7 +389,7 @@ public function getSmoothLine() * * @return $this */ - public function setSmoothLine($smoothLine) + public function setSmoothLine($smoothLine): static { $this->smoothLine = $smoothLine; diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index c86f5569b3..1a939bbd72 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -45,11 +45,9 @@ class DataSeriesValues extends Properties */ private $pointMarker; - /** @var ChartColor */ - private $markerFillColor; + private ChartColor $markerFillColor; - /** @var ChartColor */ - private $markerBorderColor; + private ChartColor $markerBorderColor; /** * Series Point Size. @@ -85,8 +83,7 @@ class DataSeriesValues extends Properties /** @var bool */ private $bubble3D = false; - /** @var ?Layout */ - private $labelLayout; + private ?Layout $labelLayout = null; /** @var TrendLine[] */ private $trendLines = []; @@ -144,7 +141,7 @@ public function getDataType() * * @return $this */ - public function setDataType($dataType) + public function setDataType($dataType): static { if (!in_array($dataType, self::DATA_TYPE_VALUES)) { throw new Exception('Invalid datatype for chart data series values'); @@ -171,7 +168,7 @@ public function getDataSource() * * @return $this */ - public function setDataSource($dataSource) + public function setDataSource($dataSource): static { $this->dataSource = $dataSource; @@ -195,7 +192,7 @@ public function getPointMarker() * * @return $this */ - public function setPointMarker($marker) + public function setPointMarker($marker): static { $this->pointMarker = $marker; @@ -225,7 +222,7 @@ public function getPointSize(): int * * @return $this */ - public function setPointSize(int $size = 3) + public function setPointSize(int $size = 3): static { $this->pointSize = $size; @@ -249,7 +246,7 @@ public function getFormatCode() * * @return $this */ - public function setFormatCode($formatCode) + public function setFormatCode($formatCode): static { $this->formatCode = $formatCode; @@ -316,7 +313,7 @@ private function chartColorToString(ChartColor $chartColor): string * * @return string|string[] HEX color or array with HEX colors */ - public function getFillColor() + public function getFillColor(): string|array { if ($this->fillColor === null) { return ''; @@ -338,9 +335,9 @@ public function getFillColor() * * @param ChartColor|ChartColor[]|string|string[] $color HEX color or array with HEX colors * - * @return DataSeriesValues + * @return $this */ - public function setFillColor($color) + public function setFillColor($color): static { if (is_array($color)) { $this->fillColor = []; @@ -367,7 +364,7 @@ public function setFillColor($color) * * @return bool true if validation was successful */ - private function validateColor($color) + private function validateColor(string $color): bool { if (!preg_match('/^[a-f0-9]{6}$/i', $color)) { throw new Exception(sprintf('Invalid hex color for chart series (color: "%s")', $color)); @@ -393,7 +390,7 @@ public function getLineWidth() * * @return $this */ - public function setLineWidth($width) + public function setLineWidth($width): static { $this->lineStyleProperties['width'] = $width; @@ -402,10 +399,8 @@ public function setLineWidth($width) /** * Identify if the Data Series is a multi-level or a simple series. - * - * @return null|bool */ - public function isMultiLevelSeries() + public function isMultiLevelSeries(): ?bool { if (!empty($this->dataValues)) { return is_array(array_values($this->dataValues)[0]); @@ -463,7 +458,7 @@ public function getDataValue() * * @return $this */ - public function setDataValues($dataValues) + public function setDataValues($dataValues): static { $this->dataValues = Functions::flattenArray($dataValues); $this->pointCount = count($dataValues); @@ -492,7 +487,7 @@ public function refresh(Worksheet $worksheet, bool $flatten = true): void unset($dataValue); } else { [$worksheet, $cellRange] = Worksheet::extractSheetTitle($this->dataSource, true); - $dimensions = Coordinate::rangeDimension(str_replace('$', '', $cellRange)); + $dimensions = Coordinate::rangeDimension(str_replace('$', '', $cellRange ?? '')); if (($dimensions[0] == 1) || ($dimensions[1] == 1)) { $this->dataValues = Functions::flattenArray($newDataValues); } else { @@ -562,7 +557,7 @@ public function getSmoothLine() * * @return $this */ - public function setSmoothLine($smoothLine) + public function setSmoothLine($smoothLine): static { $this->smoothLine = $smoothLine; diff --git a/src/PhpSpreadsheet/Chart/Layout.php b/src/PhpSpreadsheet/Chart/Layout.php index ac36c25c9f..e9830b30c3 100644 --- a/src/PhpSpreadsheet/Chart/Layout.php +++ b/src/PhpSpreadsheet/Chart/Layout.php @@ -8,132 +8,96 @@ class Layout { /** * layoutTarget. - * - * @var ?string */ - private $layoutTarget; + private ?string $layoutTarget = null; /** * X Mode. - * - * @var ?string */ - private $xMode; + private ?string $xMode = null; /** * Y Mode. - * - * @var ?string */ - private $yMode; + private ?string $yMode = null; /** * X-Position. - * - * @var ?float */ - private $xPos; + private ?float $xPos = null; /** * Y-Position. - * - * @var ?float */ - private $yPos; + private ?float $yPos = null; /** * width. - * - * @var ?float */ - private $width; + private ?float $width = null; /** * height. - * - * @var ?float */ - private $height; + private ?float $height = null; /** * Position - t=top. - * - * @var string */ - private $dLblPos = ''; + private string $dLblPos = ''; - /** @var string */ - private $numFmtCode = ''; + private string $numFmtCode = ''; - /** @var bool */ - private $numFmtLinked = false; + private bool $numFmtLinked = false; /** * show legend key * Specifies that legend keys should be shown in data labels. - * - * @var ?bool */ - private $showLegendKey; + private ?bool $showLegendKey = null; /** * show value * Specifies that the value should be shown in a data label. - * - * @var ?bool */ - private $showVal; + private ?bool $showVal = null; /** * show category name * Specifies that the category name should be shown in the data label. - * - * @var ?bool */ - private $showCatName; + private ?bool $showCatName = null; /** * show data series name * Specifies that the series name should be shown in the data label. - * - * @var ?bool */ - private $showSerName; + private ?bool $showSerName = null; /** * show percentage * Specifies that the percentage should be shown in the data label. - * - * @var ?bool */ - private $showPercent; + private ?bool $showPercent = null; /** * show bubble size. - * - * @var ?bool */ - private $showBubbleSize; + private ?bool $showBubbleSize = null; /** * show leader lines * Specifies that leader lines should be shown for the data label. - * - * @var ?bool */ - private $showLeaderLines; + private ?bool $showLeaderLines = null; - /** @var ?ChartColor */ - private $labelFillColor; + private ?ChartColor $labelFillColor = null; - /** @var ?ChartColor */ - private $labelBorderColor; + private ?ChartColor $labelBorderColor = null; - /** @var ?Font */ - private $labelFont; + private ?Font $labelFont = null; - /** @var Properties */ - private $labelEffects; + private ?Properties $labelEffects = null; /** * Create a new Layout. @@ -222,7 +186,7 @@ public function getLayoutTarget() * * @return $this */ - public function setLayoutTarget($target) + public function setLayoutTarget(?string $target): static { $this->layoutTarget = $target; @@ -246,7 +210,7 @@ public function getXMode() * * @return $this */ - public function setXMode($mode) + public function setXMode($mode): static { $this->xMode = (string) $mode; @@ -270,7 +234,7 @@ public function getYMode() * * @return $this */ - public function setYMode($mode) + public function setYMode($mode): static { $this->yMode = (string) $mode; @@ -290,13 +254,11 @@ public function getXPosition() /** * Set X-Position. * - * @param ?float $position - * * @return $this */ - public function setXPosition($position) + public function setXPosition(float $position): static { - $this->xPos = (float) $position; + $this->xPos = $position; return $this; } @@ -314,13 +276,11 @@ public function getYPosition() /** * Set Y-Position. * - * @param ?float $position - * * @return $this */ - public function setYPosition($position) + public function setYPosition(float $position): static { - $this->yPos = (float) $position; + $this->yPos = $position; return $this; } @@ -342,7 +302,7 @@ public function getWidth() * * @return $this */ - public function setWidth($width) + public function setWidth(?float $width): static { $this->width = $width; @@ -362,11 +322,9 @@ public function getHeight() /** * Set Height. * - * @param ?float $height - * * @return $this */ - public function setHeight($height) + public function setHeight(?float $height): static { $this->height = $height; diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index 04040aed6a..69ee8aa17f 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -43,19 +43,14 @@ class Legend /** * Legend Layout. - * - * @var ?Layout */ - private $layout; + private ?Layout $layout; - /** @var GridLines */ - private $borderLines; + private GridLines $borderLines; - /** @var ChartColor */ - private $fillColor; + private ChartColor $fillColor; - /** @var ?AxisText */ - private $legendText; + private ?AxisText $legendText = null; /** * Create a new Legend. @@ -92,10 +87,8 @@ public function getPosition() * Get legend position using an excel string value. * * @param string $position see self::POSITION_* - * - * @return bool */ - public function setPosition($position) + public function setPosition($position): bool { if (!in_array($position, self::POSITION_XLREF)) { return false; @@ -108,10 +101,8 @@ public function setPosition($position) /** * Get legend position as an Excel internal numeric value. - * - * @return false|int */ - public function getPositionXL() + public function getPositionXL(): false|int { // Scrutinizer thinks the following could return string. It is wrong. return array_search($this->position, self::POSITION_XLREF); @@ -121,10 +112,8 @@ public function getPositionXL() * Set legend position using an Excel internal numeric value. * * @param int $positionXL see self::XL_LEGEND_POSITION_* - * - * @return bool */ - public function setPositionXL($positionXL) + public function setPositionXL($positionXL): bool { if (!isset(self::POSITION_XLREF[$positionXL])) { return false; diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php index 2b78d9a4eb..89a2be7780 100644 --- a/src/PhpSpreadsheet/Chart/PlotArea.php +++ b/src/PhpSpreadsheet/Chart/PlotArea.php @@ -25,24 +25,20 @@ class PlotArea /** * PlotArea Gradient Angle. - * - * @var ?float */ - private $gradientFillAngle; + private ?float $gradientFillAngle = null; /** * PlotArea Layout. - * - * @var ?Layout */ - private $layout; + private ?Layout $layout; /** * Plot Series. * * @var DataSeries[] */ - private $plotSeries = []; + private array $plotSeries; /** * Create a new PlotArea. @@ -73,7 +69,7 @@ public function getPlotGroupCount(): int * * @return int */ - public function getPlotSeriesCount() + public function getPlotSeriesCount(): int|float { $seriesCount = 0; foreach ($this->plotSeries as $plot) { @@ -112,7 +108,7 @@ public function getPlotGroupByIndex($index) * * @return $this */ - public function setPlotSeries(array $plotSeries) + public function setPlotSeries(array $plotSeries): static { $this->plotSeries = $plotSeries; @@ -164,8 +160,7 @@ public function getGradientFillStops() return $this->gradientFillStops; } - /** @var ?int */ - private $gapWidth; + private ?int $gapWidth = null; /** @var bool */ private $useUpBars = false; diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index edb775456f..36b6eb76fd 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -125,8 +125,7 @@ abstract class Properties /** @var ?float */ protected $glowSize; - /** @var ChartColor */ - protected $glowColor; + protected ChartColor $glowColor; /** @var array */ protected $softEdges = [ @@ -136,8 +135,7 @@ abstract class Properties /** @var array */ protected $shadowProperties = self::PRESETS_OPTIONS[0]; - /** @var ChartColor */ - protected $shadowColor; + protected ChartColor $shadowColor; public function __construct() { @@ -611,11 +609,9 @@ public function setShadowProperties($presets, $colorValue = null, $colorType = n /** * Set Shadow Presets Properties. * - * @param int $presets - * * @return $this */ - protected function setShadowPresetsProperties($presets) + protected function setShadowPresetsProperties(int $presets) { $this->shadowProperties['presets'] = $presets; $this->setShadowPropertiesMapValues($this->getShadowPresetsMap($presets)); @@ -628,11 +624,9 @@ protected function setShadowPresetsProperties($presets) /** * Set Shadow Properties Values. * - * @param mixed $reference - * * @return $this */ - protected function setShadowPropertiesMapValues(array $propertiesMap, &$reference = null) + protected function setShadowPropertiesMapValues(array $propertiesMap, ?array &$reference = null) { $base_reference = $reference; foreach ($propertiesMap as $property_key => $property_val) { @@ -736,8 +730,7 @@ public function getShadowArray(): array return $array; } - /** @var ChartColor */ - protected $lineColor; + protected ChartColor $lineColor; /** @var array */ protected $lineStyleProperties = [ @@ -780,11 +773,10 @@ public function getLineColor(): ChartColor /** * Set Line Color Properties. * - * @param string $value * @param ?int $alpha * @param ?string $colorType */ - public function setLineColorProperties($value, $alpha = null, $colorType = null): void + public function setLineColorProperties(?string $value, $alpha = null, ?string $colorType = null): void { $this->activateObject(); $this->lineColor->setColorPropertiesArray( diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php index d676f1d33b..40ce338d93 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php @@ -38,9 +38,9 @@ abstract class JpGraphRendererBase implements IRenderer 'goldenrod2', ]; - private static $markSet; + private static array $markSet; - private $chart; + private Chart $chart; private $graph; @@ -102,7 +102,7 @@ private function formatPointMarker($seriesPlot, $markerID) return $seriesPlot; } - private function formatDataSetLabels($groupID, $datasetLabels, $rotation = '') + private function formatDataSetLabels(int $groupID, array $datasetLabels, $rotation = '') { $datasetLabelFormatCode = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex(0)->getFormatCode() ?? ''; // Retrieve any label formatting code @@ -129,7 +129,7 @@ private function formatDataSetLabels($groupID, $datasetLabels, $rotation = '') return $datasetLabels; } - private function percentageSumCalculation($groupID, $seriesCount) + private function percentageSumCalculation(int $groupID, $seriesCount) { $sumValues = []; // Adjust our values to a percentage value across all series in the group @@ -151,7 +151,7 @@ private function percentageSumCalculation($groupID, $seriesCount) return $sumValues; } - private function percentageAdjustValues($dataValues, $sumValues) + private function percentageAdjustValues(array $dataValues, array $sumValues) { foreach ($dataValues as $k => $dataValue) { $dataValues[$k] = $dataValue / $sumValues[$k] * 100; @@ -219,7 +219,7 @@ private function renderLegend(): void } } - private function renderCartesianPlotArea($type = 'textlin'): void + private function renderCartesianPlotArea(string $type = 'textlin'): void { $this->graph = new Graph(self::$width, self::$height); $this->graph->SetScale($type); @@ -271,7 +271,7 @@ private function renderRadarPlotArea(): void $this->renderTitle(); } - private function renderPlotLine($groupID, $filled = false, $combination = false): void + private function renderPlotLine(int $groupID, bool $filled = false, bool $combination = false): void { $grouping = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping(); @@ -338,7 +338,7 @@ private function renderPlotLine($groupID, $filled = false, $combination = false) $this->graph->Add($groupPlot); } - private function renderPlotBar($groupID, $dimensions = '2d'): void + private function renderPlotBar(int $groupID, ?string $dimensions = '2d'): void { $rotation = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotDirection(); // Rotate for bar rather than column chart @@ -426,7 +426,7 @@ private function renderPlotBar($groupID, $dimensions = '2d'): void $this->graph->Add($groupPlot); } - private function renderPlotScatter($groupID, $bubble): void + private function renderPlotScatter(int $groupID, bool $bubble): void { $scatterStyle = $bubbleSize = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); @@ -490,7 +490,7 @@ private function renderPlotScatter($groupID, $bubble): void } } - private function renderPlotRadar($groupID): void + private function renderPlotRadar(int $groupID): void { $radarStyle = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle(); @@ -527,7 +527,7 @@ private function renderPlotRadar($groupID): void } } - private function renderPlotContour($groupID): void + private function renderPlotContour(int $groupID): void { $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); @@ -543,7 +543,7 @@ private function renderPlotContour($groupID): void $this->graph->Add($seriesPlot); } - private function renderPlotStock($groupID): void + private function renderPlotStock(int $groupID): void { $seriesCount = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount(); $plotOrder = $this->chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotOrder(); @@ -605,7 +605,7 @@ private function renderLineChart($groupCount): void } } - private function renderBarChart($groupCount, $dimensions = '2d'): void + private function renderBarChart($groupCount, ?string $dimensions = '2d'): void { $this->renderCartesianPlotArea(); @@ -632,7 +632,7 @@ private function renderBubbleChart($groupCount): void } } - private function renderPieChart($groupCount, $dimensions = '2d', $doughnut = false, $multiplePlots = false): void + private function renderPieChart($groupCount, ?string $dimensions = '2d', bool $doughnut = false, bool $multiplePlots = false): void { $this->renderPiePlotArea(); @@ -729,7 +729,7 @@ private function renderContourChart($groupCount): void } } - private function renderCombinationChart($groupCount, $outputDestination) + private function renderCombinationChart($groupCount, $outputDestination): bool { $this->renderCartesianPlotArea(); diff --git a/src/PhpSpreadsheet/Chart/Renderer/MtJpGraphRenderer.php b/src/PhpSpreadsheet/Chart/Renderer/MtJpGraphRenderer.php index b5e70d3a19..9697920328 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/MtJpGraphRenderer.php +++ b/src/PhpSpreadsheet/Chart/Renderer/MtJpGraphRenderer.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Chart\Renderer; +use mitoteam\jpgraph\MtJpGraph; + /** * Jpgraph is not officially maintained by Composer at packagist.org. * @@ -19,7 +21,7 @@ protected static function init(): void return; } - \mitoteam\jpgraph\MtJpGraph::load([ + MtJpGraph::load([ 'bar', 'contour', 'line', diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index 9c99ccac19..787b96bcd4 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -22,10 +22,8 @@ class Title /** * Title Layout. - * - * @var ?Layout */ - private $layout; + private ?Layout $layout; /** * Create a new Title. @@ -81,7 +79,7 @@ public function getCaptionText(): string * * @return $this */ - public function setCaption($caption) + public function setCaption($caption): static { $this->caption = $caption; diff --git a/src/PhpSpreadsheet/Chart/TrendLine.php b/src/PhpSpreadsheet/Chart/TrendLine.php index 75a5896c93..7ea2bde815 100644 --- a/src/PhpSpreadsheet/Chart/TrendLine.php +++ b/src/PhpSpreadsheet/Chart/TrendLine.php @@ -19,8 +19,7 @@ class TrendLine extends Properties self::TRENDLINE_MOVING_AVG, ]; - /** @var string */ - private $trendLineType = 'linear'; // TRENDLINE_LINEAR + private string $trendLineType = 'linear'; // TRENDLINE_LINEAR /** @var int */ private $order = 2; @@ -34,8 +33,7 @@ class TrendLine extends Properties /** @var bool */ private $dispEq = false; - /** @var string */ - private $name = ''; + private string $name = ''; /** @var float */ private $backward = 0.0; diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index 9a9df227e6..e79a9df1f0 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -14,10 +14,7 @@ class Cells { protected const MAX_COLUMN_ID = 16384; - /** - * @var CacheInterface - */ - private $cache; + private CacheInterface $cache; /** * Parent worksheet. @@ -57,10 +54,8 @@ class Cells /** * Prefix used to uniquely identify cache data for this worksheet. - * - * @var string */ - private $cachePrefix; + private string $cachePrefix; /** * Initialise this new cell collection. @@ -112,7 +107,7 @@ public function update(Cell $cell): Cell * * @param string $cellCoordinate Coordinate of the cell to delete */ - public function delete($cellCoordinate): void + public function delete(string $cellCoordinate): void { if ($cellCoordinate === $this->currentCoordinate && $this->currentCell !== null) { $this->currentCell->detach(); @@ -132,7 +127,7 @@ public function delete($cellCoordinate): void * * @return string[] */ - public function getCoordinates() + public function getCoordinates(): array { return array_keys($this->index); } @@ -142,7 +137,7 @@ public function getCoordinates() * * @return string[] */ - public function getSortedCoordinates() + public function getSortedCoordinates(): array { asort($this->index); @@ -188,7 +183,7 @@ public function getCurrentRow(): int * * @return array Highest column name and highest row number */ - public function getHighestRowAndColumn() + public function getHighestRowAndColumn(): array { // Lookup highest column and highest row $maxRow = $maxColumn = 1; @@ -270,7 +265,7 @@ public function getHighestRow($column = null) * * @return string Unique Reference */ - private function getUniqueID() + private function getUniqueID(): string { $cacheType = Settings::getCache(); @@ -281,10 +276,8 @@ private function getUniqueID() /** * Clone the cell collection. - * - * @return self */ - public function cloneCellCollection(Worksheet $worksheet) + public function cloneCellCollection(Worksheet $worksheet): static { $this->storeCurrentCell(); $newCollection = clone $this; @@ -381,10 +374,8 @@ private function destructIfNeeded(self $cells, string $message): void * * @param string $cellCoordinate Coordinate of the cell to update * @param Cell $cell Cell to update - * - * @return Cell */ - public function add($cellCoordinate, Cell $cell) + public function add($cellCoordinate, Cell $cell): Cell { if ($cellCoordinate !== $this->currentCoordinate) { $this->storeCurrentCell(); @@ -408,7 +399,7 @@ public function add($cellCoordinate, Cell $cell) * * @return null|Cell Cell that was found, or null if not found */ - public function get($cellCoordinate) + public function get(string $cellCoordinate) { if ($cellCoordinate === $this->currentCoordinate) { return $this->currentCell; diff --git a/src/PhpSpreadsheet/Comment.php b/src/PhpSpreadsheet/Comment.php index abadc7dfb8..7696092af8 100644 --- a/src/PhpSpreadsheet/Comment.php +++ b/src/PhpSpreadsheet/Comment.php @@ -14,38 +14,28 @@ class Comment implements IComparable { /** * Author. - * - * @var string */ - private $author; + private string $author; /** * Rich text comment. - * - * @var RichText */ - private $text; + private RichText $text; /** * Comment width (CSS style, i.e. XXpx or YYpt). - * - * @var string */ - private $width = '96pt'; + private string $width = '96pt'; /** * Left margin (CSS style, i.e. XXpx or YYpt). - * - * @var string */ - private $marginLeft = '59.25pt'; + private string $marginLeft = '59.25pt'; /** * Top margin (CSS style, i.e. XXpx or YYpt). - * - * @var string */ - private $marginTop = '1.5pt'; + private string $marginTop = '1.5pt'; /** * Visible. @@ -56,31 +46,23 @@ class Comment implements IComparable /** * Comment height (CSS style, i.e. XXpx or YYpt). - * - * @var string */ - private $height = '55.5pt'; + private string $height = '55.5pt'; /** * Comment fill color. - * - * @var Color */ - private $fillColor; + private Color $fillColor; /** * Alignment. - * - * @var string */ - private $alignment; + private string $alignment; /** * Background image in comment. - * - * @var Drawing */ - private $backgroundImage; + private Drawing $backgroundImage; /** * Create a new Comment. diff --git a/src/PhpSpreadsheet/DefinedName.php b/src/PhpSpreadsheet/DefinedName.php index 07433b1007..5c021e5b67 100644 --- a/src/PhpSpreadsheet/DefinedName.php +++ b/src/PhpSpreadsheet/DefinedName.php @@ -10,45 +10,33 @@ abstract class DefinedName /** * Name. - * - * @var string */ - protected $name; + protected string $name; /** * Worksheet on which the defined name can be resolved. - * - * @var ?Worksheet */ - protected $worksheet; + protected ?Worksheet $worksheet; /** * Value of the named object. - * - * @var string */ - protected $value; + protected string $value; /** * Is the defined named local? (i.e. can only be used on $this->worksheet). - * - * @var bool */ - protected $localOnly; + protected bool $localOnly; /** * Scope. - * - * @var ?Worksheet */ - protected $scope; + protected ?Worksheet $scope; /** * Whether this is a named range or a named formula. - * - * @var bool */ - protected $isFormula; + protected bool $isFormula; /** * Create a new Defined Name. diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index 65b079b351..a1c29fedb5 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -25,80 +25,58 @@ class Properties /** * Creator. - * - * @var string */ - private $creator = 'Unknown Creator'; + private string $creator = 'Unknown Creator'; /** * LastModifiedBy. - * - * @var string */ - private $lastModifiedBy; + private string $lastModifiedBy; /** * Created. - * - * @var float|int */ - private $created; + private float|int $created; /** * Modified. - * - * @var float|int */ - private $modified; + private float|int $modified; /** * Title. - * - * @var string */ - private $title = 'Untitled Spreadsheet'; + private string $title = 'Untitled Spreadsheet'; /** * Description. - * - * @var string */ - private $description = ''; + private string $description = ''; /** * Subject. - * - * @var string */ - private $subject = ''; + private string $subject = ''; /** * Keywords. - * - * @var string */ - private $keywords = ''; + private string $keywords = ''; /** * Category. - * - * @var string */ - private $category = ''; + private string $category = ''; /** * Manager. - * - * @var string */ - private $manager = ''; + private string $manager = ''; /** * Company. - * - * @var string */ - private $company = ''; + private string $company = ''; /** * Custom Properties. diff --git a/src/PhpSpreadsheet/Document/Security.php b/src/PhpSpreadsheet/Document/Security.php index d94cf2a564..a97017b685 100644 --- a/src/PhpSpreadsheet/Document/Security.php +++ b/src/PhpSpreadsheet/Document/Security.php @@ -29,17 +29,13 @@ class Security /** * RevisionsPassword. - * - * @var string */ - private $revisionsPassword = ''; + private string $revisionsPassword = ''; /** * WorkbookPassword. - * - * @var string */ - private $workbookPassword = ''; + private string $workbookPassword = ''; /** * Create a new Document Security instance. @@ -112,7 +108,7 @@ public function getRevisionsPassword(): string * * @return $this */ - public function setRevisionsPassword(?string $password, bool $alreadyHashed = false) + public function setRevisionsPassword(?string $password, bool $alreadyHashed = false): static { if ($password !== null) { if (!$alreadyHashed) { @@ -136,7 +132,7 @@ public function getWorkbookPassword(): string * * @return $this */ - public function setWorkbookPassword(?string $password, bool $alreadyHashed = false) + public function setWorkbookPassword(?string $password, bool $alreadyHashed = false): static { if ($password !== null) { if (!$alreadyHashed) { diff --git a/src/PhpSpreadsheet/HashTable.php b/src/PhpSpreadsheet/HashTable.php index 6de7d03058..a66c9af562 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -101,20 +101,16 @@ public function clear(): void /** * Count. - * - * @return int */ - public function count() + public function count(): int { return count($this->items); } /** * Get index for hash code. - * - * @return false|int Index */ - public function getIndexForHashCode(string $hashCode) + public function getIndexForHashCode(string $hashCode): false|int { // Scrutinizer thinks the following could return string. It is wrong. return array_search($hashCode, $this->keyMap, true); diff --git a/src/PhpSpreadsheet/Helper/Dimension.php b/src/PhpSpreadsheet/Helper/Dimension.php index ff07ce5b8f..21dd4c5bb6 100644 --- a/src/PhpSpreadsheet/Helper/Dimension.php +++ b/src/PhpSpreadsheet/Helper/Dimension.php @@ -48,7 +48,7 @@ class Dimension * If this is a height, then size is measured in pixels () * or in points () if $unit is null. */ - protected $size; + protected float|int $size; /** * @var null|string diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index 89c28dffa2..cbb55b9757 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -617,11 +617,9 @@ private function initialise(): void /** * Parse HTML formatting and return the resulting RichText. * - * @param string $html - * * @return RichText */ - public function toRichTextObject($html) + public function toRichTextObject(string $html) { $this->initialise(); @@ -818,10 +816,7 @@ private function parseTextNode(DOMText $textNode): void $this->buildTextRun(); } - /** - * @param string $callbackTag - */ - private function handleCallback(DOMElement $element, $callbackTag, array $callbacks): void + private function handleCallback(DOMElement $element, string $callbackTag, array $callbacks): void { if (isset($callbacks[$callbackTag])) { $elementHandler = $callbacks[$callbackTag]; diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index 6244375fe3..5deb9e202d 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -3,6 +3,7 @@ namespace PhpOffice\PhpSpreadsheet\Helper; use PhpOffice\PhpSpreadsheet\Chart\Chart; +use PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Settings; use PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -23,50 +24,40 @@ class Sample { /** * Returns whether we run on CLI or browser. - * - * @return bool */ - public function isCli() + public function isCli(): bool { return PHP_SAPI === 'cli'; } /** * Return the filename currently being executed. - * - * @return string */ - public function getScriptFilename() + public function getScriptFilename(): string { return basename($_SERVER['SCRIPT_FILENAME'], '.php'); } /** * Whether we are executing the index page. - * - * @return bool */ - public function isIndex() + public function isIndex(): bool { return $this->getScriptFilename() === 'index'; } /** * Return the page title. - * - * @return string */ - public function getPageTitle() + public function getPageTitle(): string { return $this->isIndex() ? 'PHPSpreadsheet' : $this->getScriptFilename(); } /** * Return the page heading. - * - * @return string */ - public function getPageHeading() + public function getPageHeading(): string { return $this->isIndex() ? '' : '

' . str_replace('_', ' ', $this->getScriptFilename()) . '

'; } @@ -76,7 +67,7 @@ public function getPageHeading() * * @return string[][] [$name => $path] */ - public function getSamples() + public function getSamples(): array { // Populate samples $baseDir = realpath(__DIR__ . '/../../../samples'); @@ -154,10 +145,8 @@ protected function isDirOrMkdir(string $folder): bool /** * Returns the temporary directory and make sure it exists. - * - * @return string */ - public function getTemporaryFolder() + public function getTemporaryFolder(): string { $tempFolder = sys_get_temp_dir() . '/phpspreadsheet'; if (!$this->isDirOrMkdir($tempFolder)) { @@ -171,9 +160,8 @@ public function getTemporaryFolder() * Returns the filename that should be used for sample output. * * @param string $filename - * @param string $extension */ - public function getFilename($filename, $extension = 'xlsx'): string + public function getFilename($filename, string $extension = 'xlsx'): string { $originalExtension = pathinfo($filename, PATHINFO_EXTENSION); @@ -182,12 +170,8 @@ public function getFilename($filename, $extension = 'xlsx'): string /** * Return a random temporary file name. - * - * @param string $extension - * - * @return string */ - public function getTemporaryFilename($extension = 'xlsx') + public function getTemporaryFilename(string $extension = 'xlsx'): string { $temporaryFilename = tempnam($this->getTemporaryFolder(), 'phpspreadsheet-'); if ($temporaryFilename === false) { @@ -212,7 +196,7 @@ public function renderChart(Chart $chart, string $fileName): void return; } - Settings::setChartRenderer(\PhpOffice\PhpSpreadsheet\Chart\Renderer\MtJpGraphRenderer::class); + Settings::setChartRenderer(MtJpGraphRenderer::class); $fileName = $this->getFilename($fileName, 'png'); diff --git a/src/PhpSpreadsheet/Helper/Size.php b/src/PhpSpreadsheet/Helper/Size.php index 12ba4ef732..3659485ede 100644 --- a/src/PhpSpreadsheet/Helper/Size.php +++ b/src/PhpSpreadsheet/Helper/Size.php @@ -6,20 +6,11 @@ class Size { const REGEXP_SIZE_VALIDATION = '/^(?P\d*\.?\d+)(?Ppt|px|em)?$/i'; - /** - * @var bool - */ - protected $valid; + protected bool $valid; - /** - * @var string - */ - protected $size = ''; + protected string $size = ''; - /** - * @var string - */ - protected $unit = ''; + protected string $unit = ''; public function __construct(string $size) { @@ -45,7 +36,7 @@ public function unit(): string return $this->unit; } - public function __toString() + public function __toString(): string { return $this->size . $this->unit; } diff --git a/src/PhpSpreadsheet/Helper/TextGrid.php b/src/PhpSpreadsheet/Helper/TextGrid.php index 3a4a98f022..8088560d02 100644 --- a/src/PhpSpreadsheet/Helper/TextGrid.php +++ b/src/PhpSpreadsheet/Helper/TextGrid.php @@ -4,25 +4,13 @@ class TextGrid { - /** - * @var bool - */ - private $isCli = true; + private bool $isCli; - /** - * @var array - */ - protected $matrix; + protected array $matrix; - /** - * @var array - */ - protected $rows; + protected array $rows; - /** - * @var array - */ - protected $columns; + protected array $columns; /** * @var string diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php index c088397d81..a133f1c46e 100644 --- a/src/PhpSpreadsheet/IOFactory.php +++ b/src/PhpSpreadsheet/IOFactory.php @@ -139,7 +139,7 @@ public static function createReaderForFile(string $filename, ?array $readers = n $readers = array_map('strtoupper', $readers); $testReaders = array_filter( self::$readers, - function (string $readerType) use ($readers) { + function (string $readerType) use ($readers): bool { return in_array(strtoupper($readerType), $readers, true); }, ARRAY_FILTER_USE_KEY diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index d395f8f3a2..b8e6a81a9b 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -55,10 +55,7 @@ abstract class BaseReader implements IReader /** @var resource */ protected $fileHandle; - /** - * @var ?XmlScanner - */ - protected $securityScanner; + protected ?XmlScanner $securityScanner = null; public function __construct() { @@ -207,12 +204,8 @@ protected function openFile(string $filename): void /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { throw new PhpSpreadsheetException('Reader classes must implement their own listWorksheetInfo() method'); } @@ -222,12 +215,8 @@ public function listWorksheetInfo($filename) * possibly without parsing the whole file to a Spreadsheet object. * Readers will often have a more efficient method with which * they can override this method. - * - * @param string $filename - * - * @return array */ - public function listWorksheetNames($filename) + public function listWorksheetNames(string $filename): array { $returnArray = []; $info = $this->listWorksheetInfo($filename); diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index 10107e237c..bf6d0ab1d6 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -33,10 +33,8 @@ class Csv extends BaseReader /** * Input encoding. - * - * @var string */ - private $inputEncoding = 'UTF-8'; + private string $inputEncoding = 'UTF-8'; /** * Fallback encoding if guess strikes out. @@ -47,17 +45,13 @@ class Csv extends BaseReader /** * Delimiter. - * - * @var ?string */ - private $delimiter; + private ?string $delimiter = null; /** * Enclosure. - * - * @var string */ - private $enclosure = '"'; + private string $enclosure = '"'; /** * Sheet index to read. @@ -75,10 +69,8 @@ class Csv extends BaseReader /** * The character that can escape the enclosure. - * - * @var string */ - private $escapeCharacter = '\\'; + private string $escapeCharacter = '\\'; /** * Callback for setting defaults in construction. @@ -224,12 +216,8 @@ protected function inferSeparator(): void /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { // Open file $this->openFileOrMemory($filename); diff --git a/src/PhpSpreadsheet/Reader/Csv/Delimiter.php b/src/PhpSpreadsheet/Reader/Csv/Delimiter.php index 029d4a186e..102259822a 100644 --- a/src/PhpSpreadsheet/Reader/Csv/Delimiter.php +++ b/src/PhpSpreadsheet/Reader/Csv/Delimiter.php @@ -9,11 +9,9 @@ class Delimiter /** @var resource */ protected $fileHandle; - /** @var string */ - protected $escapeCharacter; + protected string $escapeCharacter; - /** @var string */ - protected $enclosure; + protected string $enclosure; /** @var array */ protected $counts = []; @@ -92,7 +90,7 @@ public function infer(): ?string $meanSquareDeviations[$delimiter] = array_reduce( $series, - function ($sum, $value) use ($median) { + function ($sum, $value) use ($median): int|float { return $sum + ($value - $median) ** 2; } ) / count($series); diff --git a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php index 8fdb162b4c..bfabb07fa0 100644 --- a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php +++ b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php @@ -10,10 +10,8 @@ class DefaultReadFilter implements IReadFilter * @param string $columnAddress Column address (as a string value like "A", or "IV") * @param int $row Row number * @param string $worksheetName Optional worksheet name - * - * @return bool */ - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell($columnAddress, $row, $worksheetName = ''): bool { return true; } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 99e4d6ad6c..4915be75a6 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -48,8 +48,7 @@ class Gnumeric extends BaseReader */ private $spreadsheet; - /** @var ReferenceHelper */ - private $referenceHelper; + private ReferenceHelper $referenceHelper; /** @var array */ public static $mappings = [ @@ -100,12 +99,8 @@ private static function matchXml(XMLReader $xml, string $expectedLocalName): boo /** * Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object. - * - * @param string $filename - * - * @return array */ - public function listWorksheetNames($filename) + public function listWorksheetNames(string $filename): array { File::assertFile($filename); if (!$this->canRead($filename)) { @@ -133,12 +128,8 @@ public function listWorksheetNames($filename) /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { File::assertFile($filename); if (!$this->canRead($filename)) { @@ -186,10 +177,8 @@ public function listWorksheetInfo($filename) /** * @param string $filename - * - * @return string */ - private function gzfileGetContents($filename) + private function gzfileGetContents($filename): string { $data = ''; $contents = @file_get_contents($filename); @@ -533,7 +522,7 @@ private function processDefinedNames(?SimpleXMLElement $gnmXML): void foreach ($gnmXML->Names->Name as $definedName) { $name = (string) $definedName->name; $value = (string) $definedName->value; - if (stripos($value, '#REF!') !== false) { + if (stripos($value, '#REF!') !== false || empty($value)) { continue; } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric/PageSetup.php b/src/PhpSpreadsheet/Reader/Gnumeric/PageSetup.php index 0257fc9a4f..f12b742f35 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric/PageSetup.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric/PageSetup.php @@ -10,10 +10,7 @@ class PageSetup { - /** - * @var Spreadsheet - */ - private $spreadsheet; + private Spreadsheet $spreadsheet; public function __construct(Spreadsheet $spreadsheet) { diff --git a/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php b/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php index 23d4067b9d..a60b453482 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric/Properties.php @@ -8,10 +8,7 @@ class Properties { - /** - * @var Spreadsheet - */ - protected $spreadsheet; + protected Spreadsheet $spreadsheet; public function __construct(Spreadsheet $spreadsheet) { diff --git a/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php b/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php index dc44dcc23e..dd082b2764 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php @@ -14,15 +14,9 @@ class Styles { - /** - * @var Spreadsheet - */ - private $spreadsheet; - - /** - * @var bool - */ - protected $readDataOnly = false; + private Spreadsheet $spreadsheet; + + protected bool $readDataOnly; /** @var array */ public static $mappings = [ diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index fa49a79f01..ba6370b6ce 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -223,7 +223,7 @@ public function loadSpreadsheetFromFile(string $filename): Spreadsheet * * @deprecated no use is made of this property */ - public function setInputEncoding($inputEncoding) + public function setInputEncoding($inputEncoding): static { $this->inputEncoding = $inputEncoding; @@ -281,11 +281,10 @@ protected function releaseTableStartColumn(): string /** * Flush cell. * - * @param string $column * @param int|string $row * @param mixed $cellContent */ - protected function flushCell(Worksheet $sheet, $column, $row, &$cellContent, array $attributeArray): void + protected function flushCell(Worksheet $sheet, string $column, $row, &$cellContent, array $attributeArray): void { if (is_string($cellContent)) { // Simple String content @@ -663,12 +662,8 @@ protected function processDomElement(DOMNode $element, Worksheet $sheet, int &$r /** * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. - * - * @param string $filename - * - * @return Spreadsheet */ - public function loadIntoExisting($filename, Spreadsheet $spreadsheet) + public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Spreadsheet { // Validate if (!$this->canRead($filename)) { @@ -863,7 +858,7 @@ public function getSheetIndex() * * @return $this */ - public function setSheetIndex($sheetIndex) + public function setSheetIndex($sheetIndex): static { $this->sheetIndex = $sheetIndex; @@ -881,10 +876,8 @@ public function setSheetIndex($sheetIndex) * - Implement to other propertie, such as border * * @param int $row - * @param string $column - * @param array $attributeArray */ - private function applyInlineStyle(Worksheet &$sheet, $row, $column, $attributeArray): void + private function applyInlineStyle(Worksheet &$sheet, $row, string $column, array $attributeArray): void { if (!isset($attributeArray['style'])) { return; @@ -1062,10 +1055,8 @@ private function applyInlineStyle(Worksheet &$sheet, $row, $column, $attributeAr * Check if has #, so we can get clean hex. * * @param mixed $value - * - * @return null|string */ - public function getStyleColor($value) + public function getStyleColor($value): string { $value = (string) $value; if (strpos($value, '#') === 0) { @@ -1075,11 +1066,7 @@ public function getStyleColor($value) return \PhpOffice\PhpSpreadsheet\Helper\Html::colourNameLookup($value); } - /** - * @param string $column - * @param int $row - */ - private function insertImage(Worksheet $sheet, $column, $row, array $attributes): void + private function insertImage(Worksheet $sheet, string $column, int $row, array $attributes): void { if (!isset($attributes['src'])) { return; @@ -1145,19 +1132,13 @@ public static function getBorderMappings(): array * Map html border style to PhpSpreadsheet border style. * * @param string $style - * - * @return null|string */ - public function getBorderStyle($style) + public function getBorderStyle($style): ?string { return self::BORDER_MAPPINGS[$style] ?? null; } - /** - * @param string $styleValue - * @param string $type - */ - private function setBorderStyle(Style $cellStyle, $styleValue, $type): void + private function setBorderStyle(Style $cellStyle, string $styleValue, string $type): void { if (trim($styleValue) === Border::BORDER_NONE) { $borderStyle = Border::BORDER_NONE; @@ -1186,12 +1167,8 @@ private function setBorderStyle(Style $cellStyle, $styleValue, $type): void /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { $info = []; $spreadsheet = new Spreadsheet(); diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index 97afe3cb20..dadf36ff90 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\Reader; +use PhpOffice\PhpSpreadsheet\Spreadsheet; + interface IReader { public const LOAD_WITH_CHARTS = 1; @@ -137,7 +139,7 @@ public function setReadFilter(IReadFilter $readFilter); * self::SKIP_EMPTY_CELLS Don't read empty cells (cells that contain a null value, * empty string, or a string containing only whitespace characters) * - * @return \PhpOffice\PhpSpreadsheet\Spreadsheet + * @return Spreadsheet */ public function load(string $filename, int $flags = 0); } diff --git a/src/PhpSpreadsheet/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 30fc36d914..719dd67ac2 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -88,11 +88,9 @@ public function canRead(string $filename): bool /** * Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object. * - * @param string $filename - * * @return string[] */ - public function listWorksheetNames($filename) + public function listWorksheetNames(string $filename): array { File::assertFile($filename, self::INITIAL_FILE); @@ -138,12 +136,8 @@ public function listWorksheetNames($filename) /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { File::assertFile($filename, self::INITIAL_FILE); @@ -248,12 +242,8 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet /** * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. - * - * @param string $filename - * - * @return Spreadsheet */ - public function loadIntoExisting($filename, Spreadsheet $spreadsheet) + public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Spreadsheet { File::assertFile($filename, self::INITIAL_FILE); @@ -734,10 +724,8 @@ private function setSelected(Spreadsheet $spreadsheet, string $wsname, string $s /** * Recursively scan element. - * - * @return string */ - protected function scanElementForText(DOMNode $element) + protected function scanElementForText(DOMNode $element): string { $str = ''; foreach ($element->childNodes as $child) { @@ -774,12 +762,7 @@ private static function getMultiplier(?DOMAttr $cAttr): int return $multiplier; } - /** - * @param string $is - * - * @return RichText - */ - private function parseRichText($is) + private function parseRichText(string $is): RichText { $value = new RichText(); $value->createText($is); diff --git a/src/PhpSpreadsheet/Reader/Ods/BaseLoader.php b/src/PhpSpreadsheet/Reader/Ods/BaseLoader.php index b06691f42a..c280c4ec56 100644 --- a/src/PhpSpreadsheet/Reader/Ods/BaseLoader.php +++ b/src/PhpSpreadsheet/Reader/Ods/BaseLoader.php @@ -7,15 +7,9 @@ abstract class BaseLoader { - /** - * @var Spreadsheet - */ - protected $spreadsheet; + protected Spreadsheet $spreadsheet; - /** - * @var string - */ - protected $tableNs; + protected string $tableNs; public function __construct(Spreadsheet $spreadsheet, string $tableNs) { diff --git a/src/PhpSpreadsheet/Reader/Ods/DefinedNames.php b/src/PhpSpreadsheet/Reader/Ods/DefinedNames.php index e0ab8900aa..a99e3ea743 100644 --- a/src/PhpSpreadsheet/Reader/Ods/DefinedNames.php +++ b/src/PhpSpreadsheet/Reader/Ods/DefinedNames.php @@ -25,6 +25,7 @@ protected function readDefinedRanges(DOMElement $workbookData): void $baseAddress = $definedNameElement->getAttributeNS($this->tableNs, 'base-cell-address'); $range = $definedNameElement->getAttributeNS($this->tableNs, 'cell-range-address'); + /** @var non-empty-string $baseAddress */ $baseAddress = FormulaTranslator::convertToExcelAddressValue($baseAddress); $range = FormulaTranslator::convertToExcelAddressValue($range); @@ -43,6 +44,7 @@ protected function readDefinedExpressions(DOMElement $workbookData): void $baseAddress = $definedNameElement->getAttributeNS($this->tableNs, 'base-cell-address'); $expression = $definedNameElement->getAttributeNS($this->tableNs, 'expression'); + /** @var non-empty-string $baseAddress */ $baseAddress = FormulaTranslator::convertToExcelAddressValue($baseAddress); $expression = substr($expression, strpos($expression, ':=') + 1); $expression = FormulaTranslator::convertToExcelFormulaValue($expression); @@ -53,6 +55,8 @@ protected function readDefinedExpressions(DOMElement $workbookData): void /** * Assess scope and store the Defined Name. + * + * @param non-empty-string $baseAddress */ private function addDefinedName(string $baseAddress, string $definedName, string $value): void { diff --git a/src/PhpSpreadsheet/Reader/Ods/Properties.php b/src/PhpSpreadsheet/Reader/Ods/Properties.php index 33419356e2..46864d0af0 100644 --- a/src/PhpSpreadsheet/Reader/Ods/Properties.php +++ b/src/PhpSpreadsheet/Reader/Ods/Properties.php @@ -8,8 +8,7 @@ class Properties { - /** @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; public function __construct(Spreadsheet $spreadsheet) { @@ -106,9 +105,8 @@ private function setMetaProperties( /** * @param mixed $propertyValueAttributes - * @param mixed $propertyValue */ - private function setUserDefinedProperty($propertyValueAttributes, $propertyValue, DocumentProperties $docProps): void + private function setUserDefinedProperty($propertyValueAttributes, string $propertyValue, DocumentProperties $docProps): void { $propertyValueName = ''; $propertyValueType = DocumentProperties::PROPERTY_TYPE_STRING; diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 64c3bb8ee2..7170a2a914 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -8,6 +8,7 @@ use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Style\Border; +use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; class Slk extends BaseReader @@ -108,7 +109,7 @@ private function canReadOrBust(string $filename): void * * @codeCoverageIgnore */ - public function setInputEncoding($inputEncoding) + public function setInputEncoding($inputEncoding): static { $this->inputEncoding = $inputEncoding; @@ -131,12 +132,8 @@ public function getInputEncoding() /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { // Open file $this->canReadOrBust($filename); @@ -380,7 +377,7 @@ private function styleSettings(string $rowDatum, array &$styleData, string &$fon } elseif (array_key_exists($char, self::STYLE_SETTINGS_BORDER)) { $styleData['borders'][self::STYLE_SETTINGS_BORDER[$char]]['borderStyle'] = Border::BORDER_THIN; } elseif ($char == 'S') { - $styleData['fill']['fillType'] = \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_PATTERN_GRAY125; + $styleData['fill']['fillType'] = Fill::FILL_PATTERN_GRAY125; } elseif ($char == 'M') { if (preg_match('/M([1-9]\\d*)/', $styleSettings, $matches)) { $fontStyle = $matches[1]; @@ -504,11 +501,9 @@ private function processPFinal(Spreadsheet &$spreadsheet, array $formatArray): v /** * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. * - * @param string $filename - * * @return Spreadsheet */ - public function loadIntoExisting($filename, Spreadsheet $spreadsheet) + public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet) { // Open file $this->canReadOrBust($filename); @@ -585,7 +580,7 @@ public function getSheetIndex() * * @return $this */ - public function setSheetIndex($sheetIndex) + public function setSheetIndex($sheetIndex): static { $this->sheetIndex = $sheetIndex; diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 76eccfbffb..a1ab019ace 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -33,6 +33,7 @@ use PhpOffice\PhpSpreadsheet\Worksheet\MemoryDrawing; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; use PhpOffice\PhpSpreadsheet\Worksheet\SheetView; +use PhpOffice\PhpSpreadsheet\Worksheet\Table; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; // Original file header of ParseXL (used as the base for this class): @@ -218,10 +219,8 @@ class Xls extends BaseReader /** * Codepage set in the Excel file being read. Only important for BIFF5 (Excel 5.0 - Excel 95) * For BIFF8 (Excel 97 - Excel 2003) this will always have the value 'UTF-16LE'. - * - * @var string */ - private $codepage = ''; + private string $codepage = ''; /** * Shared formats. @@ -469,12 +468,8 @@ public function getCodepage(): string /** * Reads names of the worksheets from a file, without parsing the whole file to a PhpSpreadsheet object. - * - * @param string $filename - * - * @return array */ - public function listWorksheetNames($filename) + public function listWorksheetNames(string $filename): array { File::assertFile($filename); @@ -531,12 +526,8 @@ public function listWorksheetNames($filename) /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { File::assertFile($filename); @@ -1258,18 +1249,17 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $ranges = explode(',', $definedName['formula']); // FIXME: what if sheetname contains comma? $extractedRanges = []; + /** @var non-empty-string $range */ foreach ($ranges as $range) { // $range should look like one of these // Foo!$C$7:$J$66 // Bar!$A$1:$IV$2 $explodes = Worksheet::extractSheetTitle($range, true); $sheetName = trim($explodes[0], "'"); - if (count($explodes) == 2) { - if (strpos($explodes[1], ':') === false) { - $explodes[1] = $explodes[1] . ':' . $explodes[1]; - } - $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 + if (strpos($explodes[1], ':') === false) { + $explodes[1] = $explodes[1] . ':' . $explodes[1]; } + $extractedRanges[] = str_replace('$', '', $explodes[1]); // C7:J66 } if ($docSheet = $this->spreadsheet->getSheetByName($sheetName)) { $docSheet->getPageSetup()->setPrintArea(implode(',', $extractedRanges)); // C7:J66,A1:IV2 @@ -1319,8 +1309,10 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet } } else { // Extract range - if (strpos($definedName['formula'], '!') !== false) { - $explodes = Worksheet::extractSheetTitle($definedName['formula'], true); + /** @var non-empty-string $formula */ + $formula = $definedName['formula']; + if (strpos($formula, '!') !== false) { + $explodes = Worksheet::extractSheetTitle($formula, true); if ( ($docSheet = $this->spreadsheet->getSheetByName($explodes[0])) || ($docSheet = $this->spreadsheet->getSheetByName(trim($explodes[0], "'"))) @@ -1335,7 +1327,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet } } // Named Value - // TODO Provide support for named values + // TODO Provide support for named values } } $this->data = ''; @@ -1352,7 +1344,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet * * @return string Record data */ - private function readRecordData($data, $pos, $len) + private function readRecordData($data, int $pos, int $len): string { $data = substr($data, $pos, $len); @@ -1401,10 +1393,8 @@ private function readRecordData($data, $pos, $len) /** * Use OLE reader to extract the relevant data streams from the OLE file. - * - * @param string $filename */ - private function loadOLE($filename): void + private function loadOLE(string $filename): void { // OLE reader $ole = new OLERead(); @@ -1898,10 +1888,8 @@ private function readFilepass(): void * * @param int $block Block for which to create decrypto * @param string $valContext MD5 context state - * - * @return Xls\RC4 */ - private function makeKey($block, $valContext) + private function makeKey(int $block, $valContext): Xls\RC4 { $pwarray = str_repeat("\0", 64); @@ -1936,7 +1924,7 @@ private function makeKey($block, $valContext) * * @return bool Success */ - private function verifyPassword($password, $docid, $salt_data, $hashedsalt_data, &$valContext) + private function verifyPassword(string $password, string $docid, string $salt_data, string $hashedsalt_data, &$valContext): bool { $pwarray = str_repeat("\0", 64); @@ -3072,7 +3060,7 @@ private function readSst(): void $len = min($charsLeft, $limitpos - $pos); for ($j = 0; $j < $len; ++$j) { $retstr .= $recordData[$pos + $j] - . chr(0); + . chr(0); } $charsLeft -= $len; $isCompressed = false; @@ -5198,10 +5186,8 @@ private function readContinue(): void * records are found. Splices the record data pieces and returns the combined string as if record data * is in one piece. * Moves to next current position in data stream to start of next record different from a CONtINUE record. - * - * @return array */ - private function getSplicedRecordData() + private function getSplicedRecordData(): array { $data = ''; $spliceOffsets = []; @@ -5238,7 +5224,7 @@ private function getSplicedRecordData() * * @return string Human readable formula */ - private function getFormulaFromStructure($formulaStructure, $baseCell = 'A1') + private function getFormulaFromStructure($formulaStructure, $baseCell = 'A1'): string { // offset: 0; size: 2; size of the following formula data $sz = self::getUInt2d($formulaStructure, 0); @@ -5265,7 +5251,7 @@ private function getFormulaFromStructure($formulaStructure, $baseCell = 'A1') * * @return string Human readable formula */ - private function getFormulaFromData($formulaData, $additionalData = '', $baseCell = 'A1') + private function getFormulaFromData(string $formulaData, string $additionalData = '', string $baseCell = 'A1'): string { // start parsing the formula data $tokens = []; @@ -5283,12 +5269,11 @@ private function getFormulaFromData($formulaData, $additionalData = '', $baseCel /** * Take array of tokens together with additional data for formula and return human readable formula. * - * @param array $tokens * @param string $additionalData Additional binary data going with the formula * * @return string Human readable formula */ - private function createFormulaFromTokens($tokens, $additionalData) + private function createFormulaFromTokens(array $tokens, string $additionalData): string { // empty formula? if (empty($tokens)) { @@ -5460,10 +5445,8 @@ private function createFormulaFromTokens($tokens, $additionalData) * * @param string $formulaData Formula data * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas - * - * @return array */ - private function getNextToken($formulaData, $baseCell = 'A1') + private function getNextToken(string $formulaData, string $baseCell = 'A1'): array { // offset: 0; size: 1; token id $id = ord($formulaData[0]); // token id @@ -7040,12 +7023,8 @@ private function getNextToken($formulaData, $baseCell = 'A1') /** * Reads a cell address in BIFF8 e.g. 'A2' or '$A$2' * section 3.3.4. - * - * @param string $cellAddressStructure - * - * @return string */ - private function readBIFF8CellAddress($cellAddressStructure) + private function readBIFF8CellAddress(string $cellAddressStructure): string { // offset: 0; size: 2; index to row (0... 65535) (or offset (-32768... 32767)) $row = self::getUInt2d($cellAddressStructure, 0) + 1; @@ -7071,12 +7050,9 @@ private function readBIFF8CellAddress($cellAddressStructure) * to indicate offsets from a base cell * section 3.3.4. * - * @param string $cellAddressStructure * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas - * - * @return string */ - private function readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1') + private function readBIFF8CellAddressB(string $cellAddressStructure, $baseCell = 'A1'): string { [$baseCol, $baseRow] = Coordinate::coordinateFromString($baseCell); $baseCol = Coordinate::columnIndexFromString($baseCol) - 1; @@ -7119,12 +7095,8 @@ private function readBIFF8CellAddressB($cellAddressStructure, $baseCell = 'A1') * Reads a cell range address in BIFF5 e.g. 'A2:B6' or 'A1' * always fixed range * section 2.5.14. - * - * @param string $subData - * - * @return string */ - private function readBIFF5CellRangeAddressFixed($subData) + private function readBIFF5CellRangeAddressFixed(string $subData): string { // offset: 0; size: 2; index to first row $fr = self::getUInt2d($subData, 0) + 1; @@ -7158,12 +7130,8 @@ private function readBIFF5CellRangeAddressFixed($subData) * Reads a cell range address in BIFF8 e.g. 'A2:B6' or 'A1' * always fixed range * section 2.5.14. - * - * @param string $subData - * - * @return string */ - private function readBIFF8CellRangeAddressFixed($subData) + private function readBIFF8CellRangeAddressFixed(string $subData): string { // offset: 0; size: 2; index to first row $fr = self::getUInt2d($subData, 0) + 1; @@ -7197,12 +7165,8 @@ private function readBIFF8CellRangeAddressFixed($subData) * Reads a cell range address in BIFF8 e.g. 'A2:B6' or '$A$2:$B$6' * there are flags indicating whether column/row index is relative * section 3.3.4. - * - * @param string $subData - * - * @return string */ - private function readBIFF8CellRangeAddress($subData) + private function readBIFF8CellRangeAddress(string $subData): string { // todo: if cell range is just a single cell, should this funciton // not just return e.g. 'A1' and not 'A1:A1' ? @@ -7251,12 +7215,11 @@ private function readBIFF8CellRangeAddress($subData) * to indicate offsets from a base cell * section 3.3.4. * - * @param string $subData * @param string $baseCell Base cell * * @return string Cell range address */ - private function readBIFF8CellRangeAddressB($subData, $baseCell = 'A1') + private function readBIFF8CellRangeAddressB(string $subData, string $baseCell = 'A1'): string { [$baseCol, $baseRow] = Coordinate::indexesFromString($baseCell); $baseCol = $baseCol - 1; @@ -7336,12 +7299,8 @@ private function readBIFF8CellRangeAddressB($subData, $baseCell = 'A1') /** * Read BIFF8 cell range address list * section 2.5.15. - * - * @param string $subData - * - * @return array */ - private function readBIFF8CellRangeAddressList($subData) + private function readBIFF8CellRangeAddressList(string $subData): array { $cellRangeAddresses = []; @@ -7364,12 +7323,8 @@ private function readBIFF8CellRangeAddressList($subData) /** * Read BIFF5 cell range address list * section 2.5.15. - * - * @param string $subData - * - * @return array */ - private function readBIFF5CellRangeAddressList($subData) + private function readBIFF5CellRangeAddressList(string $subData): array { $cellRangeAddresses = []; @@ -7394,12 +7349,8 @@ private function readBIFF5CellRangeAddressList($subData) * Note: If there is only one sheet in the range, one gets e.g Sheet1 * It can also happen that the REF structure uses the -1 (FFFF) code to indicate deleted sheets, * in which case an Exception is thrown. - * - * @param int $index - * - * @return false|string */ - private function readSheetRangeByRefIndex($index) + private function readSheetRangeByRefIndex(int $index): string|false { if (isset($this->ref[$index])) { $type = $this->externalBooks[$this->ref[$index]['externalBookIndex']]['type']; @@ -7449,10 +7400,8 @@ private function readSheetRangeByRefIndex($index) * section 2.5.8. * * @param string $arrayData - * - * @return array */ - private static function readBIFF8ConstantArray($arrayData) + private static function readBIFF8ConstantArray($arrayData): array { // offset: 0; size: 1; number of columns decreased by 1 $nc = ord($arrayData[0]); @@ -7488,10 +7437,8 @@ private static function readBIFF8ConstantArray($arrayData) * returns e.g. ['value' => '5', 'size' => 9]. * * @param string $valueData - * - * @return array */ - private static function readBIFF8Constant($valueData) + private static function readBIFF8Constant($valueData): array { // offset: 0; size: 1; identifier for type of constant $identifier = ord($valueData[0]); @@ -7546,10 +7493,8 @@ private static function readBIFF8Constant($valueData) * OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.4. * * @param string $rgb Encoded RGB value (4 bytes) - * - * @return array */ - private static function readRGB($rgb) + private static function readRGB($rgb): array { // offset: 0; size 1; Red component $r = ord($rgb[0]); @@ -7569,12 +7514,8 @@ private static function readRGB($rgb) /** * Read byte string (8-bit string length) * OpenOffice documentation: 2.5.2. - * - * @param string $subData - * - * @return array */ - private function readByteStringShort($subData) + private function readByteStringShort(string $subData): array { // offset: 0; size: 1; length of the string (character count) $ln = ord($subData[0]); @@ -7591,12 +7532,8 @@ private function readByteStringShort($subData) /** * Read byte string (16-bit string length) * OpenOffice documentation: 2.5.2. - * - * @param string $subData - * - * @return array */ - private function readByteStringLong($subData) + private function readByteStringLong(string $subData): array { // offset: 0; size: 2; length of the string (character count) $ln = self::getUInt2d($subData, 0); @@ -7666,10 +7603,8 @@ private static function readUnicodeStringLong($subData) * * @param string $subData * @param int $characterCount - * - * @return array */ - private static function readUnicodeString($subData, $characterCount) + private static function readUnicodeString($subData, $characterCount): array { $value = ''; @@ -7699,10 +7634,8 @@ private static function readUnicodeString($subData, $characterCount) * Example: hello"world --> "hello""world". * * @param string $value UTF-8 encoded string - * - * @return string */ - private static function UTF8toExcelDoubleQuoted($value) + private static function UTF8toExcelDoubleQuoted($value): string { return '"' . str_replace('"', '""', $value) . '"'; } @@ -7714,7 +7647,7 @@ private static function UTF8toExcelDoubleQuoted($value) * * @return float */ - private static function extractNumber($data) + private static function extractNumber($data): int|float { $rknumhigh = self::getInt4d($data, 4); $rknumlow = self::getInt4d($data, 0); @@ -7742,7 +7675,7 @@ private static function extractNumber($data) * * @return float */ - private static function getIEEE754($rknum) + private static function getIEEE754($rknum): float|int { if (($rknum & 0x02) != 0) { $value = $rknum >> 2; @@ -7773,10 +7706,8 @@ private static function getIEEE754($rknum) * * @param string $string * @param bool $compressed - * - * @return string */ - private static function encodeUTF16($string, $compressed = false) + private static function encodeUTF16($string, $compressed = false): string { if ($compressed) { $string = self::uncompressByteString($string); @@ -7789,10 +7720,8 @@ private static function encodeUTF16($string, $compressed = false) * Convert UTF-16 string in compressed notation to uncompressed form. Only used for BIFF8. * * @param string $string - * - * @return string */ - private static function uncompressByteString($string) + private static function uncompressByteString($string): string { $uncompressedString = ''; $strLen = strlen($string); @@ -7805,12 +7734,8 @@ private static function uncompressByteString($string) /** * Convert string to UTF-8. Only used for BIFF5. - * - * @param string $string - * - * @return string */ - private function decodeCodepage($string) + private function decodeCodepage(string $string): string { return StringHelper::convertEncoding($string, 'UTF-8', $this->codepage); } @@ -7820,10 +7745,8 @@ private function decodeCodepage($string) * * @param string $data * @param int $pos - * - * @return int */ - public static function getUInt2d($data, $pos) + public static function getUInt2d($data, $pos): int { return ord($data[$pos]) | (ord($data[$pos + 1]) << 8); } @@ -7846,10 +7769,8 @@ public static function getInt2d($data, $pos) * * @param string $data * @param int $pos - * - * @return int */ - public static function getInt4d($data, $pos) + public static function getInt4d($data, $pos): int { // FIX: represent numbers correctly on 64-bit system // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 @@ -8065,10 +7986,7 @@ private function getCFProtectionStyle(string $options, Style $style): void { } - /** - * @return null|float|int|string - */ - private function readCFFormula(string $recordData, int $offset, int $size) + private function readCFFormula(string $recordData, int $offset, int $size): float|int|string|null { try { $formula = substr($recordData, $offset, $size); diff --git a/src/PhpSpreadsheet/Reader/Xls/Color.php b/src/PhpSpreadsheet/Reader/Xls/Color.php index 06c2d0b90e..fd5d723a0f 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color.php @@ -15,7 +15,7 @@ class Color * * @return array RGB color value, example: ['rgb' => 'FF0000'] */ - public static function map($color, $palette, $version) + public static function map($color, array $palette, $version) { if ($color <= 0x07 || $color >= 0x40) { // special built-in color diff --git a/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php b/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php index 15d0b73313..5569bbd482 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php @@ -67,10 +67,8 @@ class BIFF5 * Map color array from BIFF5 built-in color index. * * @param int $color - * - * @return array */ - public static function lookup($color) + public static function lookup($color): array { return ['rgb' => self::BIFF5_COLOR_MAP[$color] ?? '000000']; } diff --git a/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php b/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php index 019ec79e83..baa2c57fcf 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php @@ -67,10 +67,8 @@ class BIFF8 * Map color array from BIFF8 built-in color index. * * @param int $color - * - * @return array */ - public static function lookup($color) + public static function lookup($color): array { return ['rgb' => self::BIFF8_COLOR_MAP[$color] ?? '000000']; } diff --git a/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php b/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php index b6a96af831..c1d34f0152 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php @@ -21,10 +21,8 @@ class BuiltIn * Map built-in color to RGB value. * * @param int $color Indexed color - * - * @return array */ - public static function lookup($color) + public static function lookup($color): array { return ['rgb' => self::BUILTIN_COLOR_MAP[$color] ?? '000000']; } diff --git a/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php b/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php index 0b79366b94..b33163dfa7 100644 --- a/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php +++ b/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php @@ -18,10 +18,8 @@ class ErrorCode * Map error code, e.g. '#N/A'. * * @param int $code - * - * @return bool|string */ - public static function lookup($code) + public static function lookup($code): string|bool { return self::ERROR_CODE_MAP[$code] ?? false; } diff --git a/src/PhpSpreadsheet/Reader/Xls/Escher.php b/src/PhpSpreadsheet/Reader/Xls/Escher.php index e9c95c8843..8a702a6c28 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Escher.php +++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php @@ -553,10 +553,7 @@ private function readClientAnchor(): void $this->applyAttribute('setEndOffsetY', $endOffsetY); } - /** - * @param mixed $value - */ - private function applyAttribute(string $name, $value): void + private function applyAttribute(string $name, mixed $value): void { if (method_exists($this->object, $name)) { $this->object->$name($value); @@ -581,7 +578,7 @@ private function readClientData(): void * @param string $data Binary data * @param int $n Number of properties */ - private function readOfficeArtRGFOPTE($data, $n): void + private function readOfficeArtRGFOPTE(string $data, int $n): void { $splicedComplexData = substr($data, 6 * $n); diff --git a/src/PhpSpreadsheet/Reader/Xls/MD5.php b/src/PhpSpreadsheet/Reader/Xls/MD5.php index d376c456f0..42bd92a3c7 100644 --- a/src/PhpSpreadsheet/Reader/Xls/MD5.php +++ b/src/PhpSpreadsheet/Reader/Xls/MD5.php @@ -24,10 +24,7 @@ class MD5 */ private $d; - /** - * @var int - */ - private static $allOneBits; + private static int $allOneBits; /** * MD5 stream constructor. @@ -51,10 +48,8 @@ public function reset(): void /** * Get MD5 stream context. - * - * @return string */ - public function getContext() + public function getContext(): string { $s = ''; foreach (['a', 'b', 'c', 'd'] as $i) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index c57155774a..bf36be6522 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -49,10 +49,8 @@ class Xlsx extends BaseReader /** * ReferenceHelper instance. - * - * @var ReferenceHelper */ - private $referenceHelper; + private ReferenceHelper $referenceHelper; /** * @var ZipArchive @@ -174,12 +172,8 @@ private function loadZipNonamespace(string $filename, string $ns): SimpleXMLElem /** * Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object. - * - * @param string $filename - * - * @return array */ - public function listWorksheetNames($filename) + public function listWorksheetNames(string $filename): array { File::assertFile($filename, self::INITIAL_FILE); @@ -213,12 +207,8 @@ public function listWorksheetNames($filename) /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { File::assertFile($filename, self::INITIAL_FILE); @@ -362,10 +352,7 @@ private function castToFormula(?SimpleXMLElement $c, string $r, string &$cellDat } } - /** - * @param string $fileName - */ - private function fileExistsInArchive(ZipArchive $archive, $fileName = ''): bool + private function fileExistsInArchive(ZipArchive $archive, string $fileName = ''): bool { // Root-relative paths if (strpos($fileName, '//') !== false) { @@ -1742,12 +1729,12 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet break; default: if ($mapSheetId[(int) $definedName['localSheetId']] !== null) { - $range = Worksheet::extractSheetTitle((string) $definedName, true); + $range = Worksheet::extractSheetTitle($extractedRange, true); $scope = $excel->getSheet($mapSheetId[(int) $definedName['localSheetId']]); if (strpos((string) $definedName, '!') !== false) { $range[0] = str_replace("''", "'", $range[0]); $range[0] = str_replace("'", '', $range[0]); - if ($worksheet = $excel->getSheetByName($range[0])) { // @phpstan-ignore-line + if ($worksheet = $excel->getSheetByName($range[0])) { $excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $worksheet, $extractedRange, true, $scope)); } else { $excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $scope, $extractedRange, true, $scope)); @@ -1760,25 +1747,24 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet break; } } elseif (!isset($definedName['localSheetId'])) { - $definedRange = (string) $definedName; // "Global" definedNames $locatedSheet = null; if (strpos((string) $definedName, '!') !== false) { // Modify range, and extract the first worksheet reference // Need to split on a comma or a space if not in quotes, and extract the first part. - $definedNameValueParts = preg_split("/[ ,](?=([^']*'[^']*')*[^']*$)/miuU", $definedRange); + $definedNameValueParts = preg_split("/[ ,](?=([^']*'[^']*')*[^']*$)/miuU", $extractedRange); // Extract sheet name [$extractedSheetName] = Worksheet::extractSheetTitle((string) $definedNameValueParts[0], true); // @phpstan-ignore-line - $extractedSheetName = trim($extractedSheetName, "'"); + $extractedSheetName = trim($extractedSheetName, "'"); // @phpstan-ignore-line // Locate sheet $locatedSheet = $excel->getSheetByName($extractedSheetName); } - if ($locatedSheet === null && !DefinedName::testIfFormula($definedRange)) { - $definedRange = '#REF!'; + if ($locatedSheet === null && !DefinedName::testIfFormula($extractedRange)) { + $extractedRange = '#REF!'; } - $excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $locatedSheet, $definedRange, false)); + $excel->addDefinedName(DefinedName::createInstance((string) $definedName['name'], $locatedSheet, $extractedRange, false)); } } } @@ -1853,10 +1839,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet return $excel; } - /** - * @return RichText - */ - private function parseRichText(?SimpleXMLElement $is) + private function parseRichText(?SimpleXMLElement $is): RichText { $value = new RichText(); @@ -1920,7 +1903,7 @@ private function parseRichText(?SimpleXMLElement $is) if (isset($run->rPr->u)) { $attr = $run->rPr->u->attributes(); if (!isset($attr['val'])) { - $objFont->setUnderline(\PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE); + $objFont->setUnderline(StyleFont::UNDERLINE_SINGLE); } else { $objFont->setUnderline((string) $attr['val']); } @@ -2052,10 +2035,7 @@ private static function boolean(string $value): bool return $value === 'true' || $value === 'TRUE'; } - /** - * @param array $hyperlinks - */ - private function readHyperLinkDrawing(\PhpOffice\PhpSpreadsheet\Worksheet\Drawing $objDrawing, SimpleXMLElement $cellAnchor, $hyperlinks): void + private function readHyperLinkDrawing(\PhpOffice\PhpSpreadsheet\Worksheet\Drawing $objDrawing, SimpleXMLElement $cellAnchor, array $hyperlinks): void { $hlinkClick = $cellAnchor->pic->nvPicPr->cNvPr->children(Namespaces::DRAWINGML)->hlinkClick; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php b/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php index 5cf62efd85..b1bf43b0cc 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php @@ -16,10 +16,7 @@ class AutoFilter */ private $parent; - /** - * @var SimpleXMLElement - */ - private $worksheetXml; + private SimpleXMLElement $worksheetXml; /** * @param Table|Worksheet $parent diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index c5a59f5583..789d46ee78 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -22,11 +22,9 @@ class Chart { - /** @var string */ - private $cNamespace; + private string $cNamespace; - /** @var string */ - private $aNamespace; + private string $aNamespace; public function __construct(string $cNamespace = Namespaces::CHART, string $aNamespace = Namespaces::DRAWINGML) { @@ -34,26 +32,42 @@ public function __construct(string $cNamespace = Namespaces::CHART, string $aNam $this->aNamespace = $aNamespace; } - /** - * @param string $name - * @param string $format - * - * @return null|bool|float|int|string - */ - private static function getAttribute(SimpleXMLElement $component, $name, $format) + private static function getAttributeString(SimpleXMLElement $component, string $name): string|null { $attributes = $component->attributes(); if (@isset($attributes[$name])) { - if ($format == 'string') { - return (string) $attributes[$name]; - } elseif ($format == 'integer') { - return (int) $attributes[$name]; - } elseif ($format == 'boolean') { - $value = (string) $attributes[$name]; - - return $value === 'true' || $value === '1'; - } + return (string) $attributes[$name]; + } + + return null; + } + + private static function getAttributeInteger(SimpleXMLElement $component, string $name): int|null + { + $attributes = $component->attributes(); + if (@isset($attributes[$name])) { + return (int) $attributes[$name]; + } + + return null; + } + + private static function getAttributeBoolean(SimpleXMLElement $component, string $name): bool|null + { + $attributes = $component->attributes(); + if (@isset($attributes[$name])) { + $value = (string) $attributes[$name]; + + return $value === 'true' || $value === '1'; + } + + return null; + } + private static function getAttributeFloat(SimpleXMLElement $component, string $name): float|null + { + $attributes = $component->attributes(); + if (@isset($attributes[$name])) { return (float) $attributes[$name]; } @@ -62,10 +76,8 @@ private static function getAttribute(SimpleXMLElement $component, $name, $format /** * @param string $chartName - * - * @return \PhpOffice\PhpSpreadsheet\Chart\Chart */ - public function readChart(SimpleXMLElement $chartElements, $chartName) + public function readChart(SimpleXMLElement $chartElements, $chartName): \PhpOffice\PhpSpreadsheet\Chart\Chart { $chartElementsC = $chartElements->children($this->cNamespace); @@ -103,7 +115,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) break; case 'roundedCorners': /** @var bool */ - $roundedCorners = self::getAttribute($chartElementsC->roundedCorners, 'val', 'boolean'); + $roundedCorners = self::getAttributeBoolean($chartElementsC->roundedCorners, 'val'); break; case 'chart': @@ -112,14 +124,14 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) switch ($chartDetailsKey) { case 'autoTitleDeleted': /** @var bool */ - $autoTitleDeleted = self::getAttribute($chartElementsC->chart->autoTitleDeleted, 'val', 'boolean'); + $autoTitleDeleted = self::getAttributeBoolean($chartElementsC->chart->autoTitleDeleted, 'val'); break; case 'view3D': - $rotX = self::getAttribute($chartDetails->rotX, 'val', 'integer'); - $rotY = self::getAttribute($chartDetails->rotY, 'val', 'integer'); - $rAngAx = self::getAttribute($chartDetails->rAngAx, 'val', 'integer'); - $perspective = self::getAttribute($chartDetails->perspective, 'val', 'integer'); + $rotX = self::getAttributeInteger($chartDetails->rotX, 'val'); + $rotY = self::getAttributeInteger($chartDetails->rotY, 'val'); + $rAngAx = self::getAttributeInteger($chartDetails->rAngAx, 'val'); + $perspective = self::getAttributeInteger($chartDetails->perspective, 'val'); break; case 'plotArea': @@ -139,7 +151,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) foreach ($possibleNoFill->gradFill->gsLst->gs as $gradient) { $gradient = Xlsx::testSimpleXml($gradient); /** @var float */ - $pos = self::getAttribute($gradient, 'pos', 'float'); + $pos = self::getAttributeFloat($gradient, 'pos'); $gradientArray[] = [ $pos / ChartProperties::PERCENTAGE_MULTIPLIER, new ChartColor($this->readColor($gradient)), @@ -147,7 +159,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) } } if (isset($possibleNoFill->gradFill->lin)) { - $gradientLin = ChartProperties::XmlToAngle((string) self::getAttribute($possibleNoFill->gradFill->lin, 'ang', 'string')); + $gradientLin = ChartProperties::XmlToAngle((string) self::getAttributeString($possibleNoFill->gradFill->lin, 'ang')); } break; @@ -198,7 +210,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) $whichAxis = null; $axPos = null; if (isset($chartDetail->axPos)) { - $axPos = self::getAttribute($chartDetail->axPos, 'val', 'string'); + $axPos = self::getAttributeString($chartDetail->axPos, 'val'); } if ($catAxRead) { $whichAxis = $yAxis; @@ -269,7 +281,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) break; case 'barChart': case 'bar3DChart': - $barDirection = self::getAttribute($chartDetail->barDir, 'val', 'string'); + $barDirection = self::getAttributeString($chartDetail->barDir, 'val'); $plotSer = $this->chartDataSeries($chartDetail, $chartDetailKey); $plotSer->setPlotDirection("$barDirection"); $plotSeries[] = $plotSer; @@ -291,7 +303,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) case 'doughnutChart': case 'pieChart': case 'pie3DChart': - $explosion = self::getAttribute($chartDetail->ser->explosion, 'val', 'string'); + $explosion = self::getAttributeString($chartDetail->ser->explosion, 'val'); $plotSer = $this->chartDataSeries($chartDetail, $chartDetailKey); $plotSer->setPlotStyle("$explosion"); $plotSeries[] = $plotSer; @@ -300,7 +312,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) break; case 'scatterChart': /** @var string */ - $scatterStyle = self::getAttribute($chartDetail->scatterStyle, 'val', 'string'); + $scatterStyle = self::getAttributeString($chartDetail->scatterStyle, 'val'); $plotSer = $this->chartDataSeries($chartDetail, $chartDetailKey); $plotSer->setPlotStyle($scatterStyle); $plotSeries[] = $plotSer; @@ -308,7 +320,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) break; case 'bubbleChart': - $bubbleScale = self::getAttribute($chartDetail->bubbleScale, 'val', 'integer'); + $bubbleScale = self::getAttributeInteger($chartDetail->bubbleScale, 'val'); $plotSer = $this->chartDataSeries($chartDetail, $chartDetailKey); $plotSer->setPlotStyle("$bubbleScale"); $plotSeries[] = $plotSer; @@ -317,7 +329,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) break; case 'radarChart': /** @var string */ - $radarStyle = self::getAttribute($chartDetail->radarStyle, 'val', 'string'); + $radarStyle = self::getAttributeString($chartDetail->radarStyle, 'val'); $plotSer = $this->chartDataSeries($chartDetail, $chartDetailKey); $plotSer->setPlotStyle($radarStyle); $plotSeries[] = $plotSer; @@ -326,7 +338,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) break; case 'surfaceChart': case 'surface3DChart': - $wireFrame = self::getAttribute($chartDetail->wireframe, 'val', 'boolean'); + $wireFrame = self::getAttributeBoolean($chartDetail->wireframe, 'val'); $plotSer = $this->chartDataSeries($chartDetail, $chartDetailKey); $plotSer->setPlotStyle("$wireFrame"); $plotSeries[] = $plotSer; @@ -336,7 +348,7 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) case 'stockChart': $plotSeries[] = $this->chartDataSeries($chartDetail, $chartDetailKey); if (isset($chartDetail->upDownBars->gapWidth)) { - $gapWidth = self::getAttribute($chartDetail->upDownBars->gapWidth, 'val', 'integer'); + $gapWidth = self::getAttributeInteger($chartDetail->upDownBars->gapWidth, 'val'); } if (isset($chartDetail->upDownBars->upBars)) { $useUpBars = true; @@ -372,11 +384,11 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) break; case 'plotVisOnly': - $plotVisOnly = self::getAttribute($chartDetails, 'val', 'string'); + $plotVisOnly = self::getAttributeString($chartDetails, 'val'); break; case 'dispBlanksAs': - $dispBlanksAs = self::getAttribute($chartDetails, 'val', 'string'); + $dispBlanksAs = self::getAttributeString($chartDetails, 'val'); break; case 'title': @@ -395,11 +407,11 @@ public function readChart(SimpleXMLElement $chartElements, $chartName) $chartDetail = Xlsx::testSimpleXml($chartDetail); switch ($chartDetailKey) { case 'legendPos': - $legendPos = self::getAttribute($chartDetail, 'val', 'string'); + $legendPos = self::getAttributeString($chartDetail, 'val'); break; case 'overlay': - $legendOverlay = self::getAttribute($chartDetail, 'val', 'boolean'); + $legendOverlay = self::getAttributeBoolean($chartDetail, 'val'); break; case 'layout': @@ -509,7 +521,7 @@ private function chartTitle(SimpleXMLElement $titleDetails): Title break; case 'overlay': - $titleOverlay = self::getAttribute($chartDetail, 'val', 'boolean'); + $titleOverlay = self::getAttributeBoolean($chartDetail, 'val'); break; case 'layout': @@ -534,7 +546,7 @@ private function chartLayoutDetails(SimpleXMLElement $chartDetail): ?Layout $layout = []; foreach ($details as $detailKey => $detail) { $detail = Xlsx::testSimpleXml($detail); - $layout[$detailKey] = self::getAttribute($detail, 'val', 'string'); + $layout[$detailKey] = self::getAttributeString($detail, 'val'); } return new Layout($layout); @@ -550,7 +562,7 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType foreach ($seriesDetailSet as $seriesDetailKey => $seriesDetails) { switch ($seriesDetailKey) { case 'grouping': - $multiSeriesType = self::getAttribute($chartDetail->grouping, 'val', 'string'); + $multiSeriesType = self::getAttributeString($chartDetail->grouping, 'val'); break; case 'ser': @@ -570,11 +582,11 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType $seriesDetail = Xlsx::testSimpleXml($seriesDetail); switch ($seriesKey) { case 'idx': - $seriesIndex = self::getAttribute($seriesDetail, 'val', 'integer'); + $seriesIndex = self::getAttributeInteger($seriesDetail, 'val'); break; case 'order': - $seriesOrder = self::getAttribute($seriesDetail, 'val', 'integer'); + $seriesOrder = self::getAttributeInteger($seriesDetail, 'val'); $plotOrder[$seriesIndex] = $seriesOrder; break; @@ -604,7 +616,7 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType break; case 'dPt': - $dptIdx = (int) self::getAttribute($seriesDetail->idx, 'val', 'string'); + $dptIdx = (int) self::getAttributeString($seriesDetail->idx, 'val'); if (isset($seriesDetail->spPr)) { $children = $seriesDetail->spPr->children($this->aNamespace); if (isset($children->solidFill)) { @@ -618,21 +630,21 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType $trendLine = new TrendLine(); $this->readLineStyle($seriesDetail, $trendLine); /** @var ?string */ - $trendLineType = self::getAttribute($seriesDetail->trendlineType, 'val', 'string'); + $trendLineType = self::getAttributeString($seriesDetail->trendlineType, 'val'); /** @var ?bool */ - $dispRSqr = self::getAttribute($seriesDetail->dispRSqr, 'val', 'boolean'); + $dispRSqr = self::getAttributeBoolean($seriesDetail->dispRSqr, 'val'); /** @var ?bool */ - $dispEq = self::getAttribute($seriesDetail->dispEq, 'val', 'boolean'); + $dispEq = self::getAttributeBoolean($seriesDetail->dispEq, 'val'); /** @var ?int */ - $order = self::getAttribute($seriesDetail->order, 'val', 'integer'); + $order = self::getAttributeInteger($seriesDetail->order, 'val'); /** @var ?int */ - $period = self::getAttribute($seriesDetail->period, 'val', 'integer'); + $period = self::getAttributeInteger($seriesDetail->period, 'val'); /** @var ?float */ - $forward = self::getAttribute($seriesDetail->forward, 'val', 'float'); + $forward = self::getAttributeFloat($seriesDetail->forward, 'val'); /** @var ?float */ - $backward = self::getAttribute($seriesDetail->backward, 'val', 'float'); + $backward = self::getAttributeFloat($seriesDetail->backward, 'val'); /** @var ?float */ - $intercept = self::getAttribute($seriesDetail->intercept, 'val', 'float'); + $intercept = self::getAttributeFloat($seriesDetail->intercept, 'val'); /** @var ?string */ $name = (string) $seriesDetail->name; $trendLine->setTrendLineProperties( @@ -650,8 +662,8 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType break; case 'marker': - $marker = self::getAttribute($seriesDetail->symbol, 'val', 'string'); - $pointSize = self::getAttribute($seriesDetail->size, 'val', 'string'); + $marker = self::getAttributeString($seriesDetail->symbol, 'val'); + $pointSize = self::getAttributeString($seriesDetail->size, 'val'); $pointSize = is_numeric($pointSize) ? ((int) $pointSize) : null; if (isset($seriesDetail->spPr)) { $children = $seriesDetail->spPr->children($this->aNamespace); @@ -665,7 +677,7 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType break; case 'smooth': - $smoothLine = self::getAttribute($seriesDetail, 'val', 'boolean'); + $smoothLine = self::getAttributeBoolean($seriesDetail, 'val'); break; case 'cat': @@ -689,7 +701,7 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType break; case 'bubble3D': - $bubble3D = self::getAttribute($seriesDetail, 'val', 'boolean'); + $bubble3D = self::getAttributeBoolean($seriesDetail, 'val'); break; case 'dLbls': @@ -801,15 +813,13 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType } /** @phpstan-ignore-next-line */ $series = new DataSeries($plotType, $multiSeriesType, $plotOrder, $seriesLabel, $seriesCategory, $seriesValues, $smoothLine); + /** @phpstan-ignore-next-line */ $series->setPlotBubbleSizes($seriesBubbles); return $series; } - /** - * @return mixed - */ - private function chartDataSeriesValueSet(SimpleXMLElement $seriesDetail, ?string $marker = null, ?ChartColor $fillColor = null, ?string $pointSize = null) + private function chartDataSeriesValueSet(SimpleXMLElement $seriesDetail, ?string $marker = null, ?ChartColor $fillColor = null, ?string $pointSize = null): ?DataSeriesValues { if (isset($seriesDetail->strRef)) { $seriesSource = (string) $seriesDetail->strRef->f; @@ -883,7 +893,7 @@ private function chartDataSeriesValues(SimpleXMLElement $seriesValueSet, string $seriesValue = Xlsx::testSimpleXml($seriesValue); switch ($seriesValueIdx) { case 'ptCount': - $pointCount = self::getAttribute($seriesValue, 'val', 'integer'); + $pointCount = self::getAttributeInteger($seriesValue, 'val'); break; case 'formatCode': @@ -891,7 +901,7 @@ private function chartDataSeriesValues(SimpleXMLElement $seriesValueSet, string break; case 'pt': - $pointVal = self::getAttribute($seriesValue, 'idx', 'integer'); + $pointVal = self::getAttributeInteger($seriesValue, 'idx'); if ($dataType == 's') { $seriesVal[$pointVal] = (string) $seriesValue->v; } elseif ((string) $seriesValue->v === ExcelError::NA()) { @@ -922,7 +932,7 @@ private function chartDataSeriesValuesMultiLevel(SimpleXMLElement $seriesValueSe $seriesValue = Xlsx::testSimpleXml($seriesValue); switch ($seriesValueIdx) { case 'ptCount': - $pointCount = self::getAttribute($seriesValue, 'val', 'integer'); + $pointCount = self::getAttributeInteger($seriesValue, 'val'); break; case 'formatCode': @@ -930,7 +940,7 @@ private function chartDataSeriesValuesMultiLevel(SimpleXMLElement $seriesValueSe break; case 'pt': - $pointVal = self::getAttribute($seriesValue, 'idx', 'integer'); + $pointVal = self::getAttributeInteger($seriesValue, 'idx'); if ($dataType == 's') { $seriesVal[$pointVal][] = (string) $seriesValue->v; } elseif ((string) $seriesValue->v === ExcelError::NA()) { @@ -967,31 +977,31 @@ private function parseRichText(SimpleXMLElement $titleDetailPart): RichText $defaultFontColor = null; if (isset($titleDetailPart->pPr->defRPr)) { /** @var ?int */ - $defaultFontSize = self::getAttribute($titleDetailPart->pPr->defRPr, 'sz', 'integer'); + $defaultFontSize = self::getAttributeInteger($titleDetailPart->pPr->defRPr, 'sz'); /** @var ?bool */ - $defaultBold = self::getAttribute($titleDetailPart->pPr->defRPr, 'b', 'boolean'); + $defaultBold = self::getAttributeBoolean($titleDetailPart->pPr->defRPr, 'b'); /** @var ?bool */ - $defaultItalic = self::getAttribute($titleDetailPart->pPr->defRPr, 'i', 'boolean'); + $defaultItalic = self::getAttributeBoolean($titleDetailPart->pPr->defRPr, 'i'); /** @var ?string */ - $defaultUnderscore = self::getAttribute($titleDetailPart->pPr->defRPr, 'u', 'string'); + $defaultUnderscore = self::getAttributeString($titleDetailPart->pPr->defRPr, 'u'); /** @var ?string */ - $defaultStrikethrough = self::getAttribute($titleDetailPart->pPr->defRPr, 'strike', 'string'); + $defaultStrikethrough = self::getAttributeString($titleDetailPart->pPr->defRPr, 'strike'); /** @var ?int */ - $defaultBaseline = self::getAttribute($titleDetailPart->pPr->defRPr, 'baseline', 'integer'); + $defaultBaseline = self::getAttributeInteger($titleDetailPart->pPr->defRPr, 'baseline'); if (isset($titleDetailPart->defRPr->rFont['val'])) { $defaultFontName = (string) $titleDetailPart->defRPr->rFont['val']; } if (isset($titleDetailPart->pPr->defRPr->latin)) { /** @var ?string */ - $defaultLatin = self::getAttribute($titleDetailPart->pPr->defRPr->latin, 'typeface', 'string'); + $defaultLatin = self::getAttributeString($titleDetailPart->pPr->defRPr->latin, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->ea)) { /** @var ?string */ - $defaultEastAsian = self::getAttribute($titleDetailPart->pPr->defRPr->ea, 'typeface', 'string'); + $defaultEastAsian = self::getAttributeString($titleDetailPart->pPr->defRPr->ea, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->cs)) { /** @var ?string */ - $defaultComplexScript = self::getAttribute($titleDetailPart->pPr->defRPr->cs, 'typeface', 'string'); + $defaultComplexScript = self::getAttributeString($titleDetailPart->pPr->defRPr->cs, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->solidFill)) { $defaultFontColor = $this->readColor($titleDetailPart->pPr->defRPr->solidFill); @@ -1031,18 +1041,18 @@ private function parseRichText(SimpleXMLElement $titleDetailPart): RichText } if (isset($titleDetailElement->rPr->latin)) { /** @var ?string */ - $latinName = self::getAttribute($titleDetailElement->rPr->latin, 'typeface', 'string'); + $latinName = self::getAttributeString($titleDetailElement->rPr->latin, 'typeface'); } if (isset($titleDetailElement->rPr->ea)) { /** @var ?string */ - $eastAsian = self::getAttribute($titleDetailElement->rPr->ea, 'typeface', 'string'); + $eastAsian = self::getAttributeString($titleDetailElement->rPr->ea, 'typeface'); } if (isset($titleDetailElement->rPr->cs)) { /** @var ?string */ - $complexScript = self::getAttribute($titleDetailElement->rPr->cs, 'typeface', 'string'); + $complexScript = self::getAttributeString($titleDetailElement->rPr->cs, 'typeface'); } /** @var ?int */ - $fontSize = self::getAttribute($titleDetailElement->rPr, 'sz', 'integer'); + $fontSize = self::getAttributeInteger($titleDetailElement->rPr, 'sz'); // not used now, not sure it ever was, grandfathering if (isset($titleDetailElement->rPr->solidFill)) { @@ -1050,22 +1060,22 @@ private function parseRichText(SimpleXMLElement $titleDetailPart): RichText } /** @var ?bool */ - $bold = self::getAttribute($titleDetailElement->rPr, 'b', 'boolean'); + $bold = self::getAttributeBoolean($titleDetailElement->rPr, 'b'); /** @var ?bool */ - $italic = self::getAttribute($titleDetailElement->rPr, 'i', 'boolean'); + $italic = self::getAttributeBoolean($titleDetailElement->rPr, 'i'); /** @var ?int */ - $baseline = self::getAttribute($titleDetailElement->rPr, 'baseline', 'integer'); + $baseline = self::getAttributeInteger($titleDetailElement->rPr, 'baseline'); /** @var ?string */ - $underscore = self::getAttribute($titleDetailElement->rPr, 'u', 'string'); + $underscore = self::getAttributeString($titleDetailElement->rPr, 'u'); if (isset($titleDetailElement->rPr->uFill->solidFill)) { $underlineColor = $this->readColor($titleDetailElement->rPr->uFill->solidFill); } /** @var ?string */ - $strikethrough = self::getAttribute($titleDetailElement->rPr, 'strike', 'string'); + $strikethrough = self::getAttributeString($titleDetailElement->rPr, 'strike'); } $fontFound = false; @@ -1170,20 +1180,20 @@ private function parseFont(SimpleXMLElement $titleDetailPart): ?Font return null; } $fontArray = []; - $fontArray['size'] = self::getAttribute($titleDetailPart->pPr->defRPr, 'sz', 'integer'); - $fontArray['bold'] = self::getAttribute($titleDetailPart->pPr->defRPr, 'b', 'boolean'); - $fontArray['italic'] = self::getAttribute($titleDetailPart->pPr->defRPr, 'i', 'boolean'); - $fontArray['underscore'] = self::getAttribute($titleDetailPart->pPr->defRPr, 'u', 'string'); - $fontArray['strikethrough'] = self::getAttribute($titleDetailPart->pPr->defRPr, 'strike', 'string'); + $fontArray['size'] = self::getAttributeInteger($titleDetailPart->pPr->defRPr, 'sz'); + $fontArray['bold'] = self::getAttributeBoolean($titleDetailPart->pPr->defRPr, 'b'); + $fontArray['italic'] = self::getAttributeBoolean($titleDetailPart->pPr->defRPr, 'i'); + $fontArray['underscore'] = self::getAttributeString($titleDetailPart->pPr->defRPr, 'u'); + $fontArray['strikethrough'] = self::getAttributeString($titleDetailPart->pPr->defRPr, 'strike'); if (isset($titleDetailPart->pPr->defRPr->latin)) { - $fontArray['latin'] = self::getAttribute($titleDetailPart->pPr->defRPr->latin, 'typeface', 'string'); + $fontArray['latin'] = self::getAttributeString($titleDetailPart->pPr->defRPr->latin, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->ea)) { - $fontArray['eastAsian'] = self::getAttribute($titleDetailPart->pPr->defRPr->ea, 'typeface', 'string'); + $fontArray['eastAsian'] = self::getAttributeString($titleDetailPart->pPr->defRPr->ea, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->cs)) { - $fontArray['complexScript'] = self::getAttribute($titleDetailPart->pPr->defRPr->cs, 'typeface', 'string'); + $fontArray['complexScript'] = self::getAttributeString($titleDetailPart->pPr->defRPr->cs, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->solidFill)) { $fontArray['chartColor'] = new ChartColor($this->readColor($titleDetailPart->pPr->defRPr->solidFill)); @@ -1203,32 +1213,32 @@ private function readChartAttributes($chartDetail): array $plotAttributes = []; if (isset($chartDetail->dLbls)) { if (isset($chartDetail->dLbls->dLblPos)) { - $plotAttributes['dLblPos'] = self::getAttribute($chartDetail->dLbls->dLblPos, 'val', 'string'); + $plotAttributes['dLblPos'] = self::getAttributeString($chartDetail->dLbls->dLblPos, 'val'); } if (isset($chartDetail->dLbls->numFmt)) { - $plotAttributes['numFmtCode'] = self::getAttribute($chartDetail->dLbls->numFmt, 'formatCode', 'string'); - $plotAttributes['numFmtLinked'] = self::getAttribute($chartDetail->dLbls->numFmt, 'sourceLinked', 'boolean'); + $plotAttributes['numFmtCode'] = self::getAttributeString($chartDetail->dLbls->numFmt, 'formatCode'); + $plotAttributes['numFmtLinked'] = self::getAttributeBoolean($chartDetail->dLbls->numFmt, 'sourceLinked'); } if (isset($chartDetail->dLbls->showLegendKey)) { - $plotAttributes['showLegendKey'] = self::getAttribute($chartDetail->dLbls->showLegendKey, 'val', 'string'); + $plotAttributes['showLegendKey'] = self::getAttributeString($chartDetail->dLbls->showLegendKey, 'val'); } if (isset($chartDetail->dLbls->showVal)) { - $plotAttributes['showVal'] = self::getAttribute($chartDetail->dLbls->showVal, 'val', 'string'); + $plotAttributes['showVal'] = self::getAttributeString($chartDetail->dLbls->showVal, 'val'); } if (isset($chartDetail->dLbls->showCatName)) { - $plotAttributes['showCatName'] = self::getAttribute($chartDetail->dLbls->showCatName, 'val', 'string'); + $plotAttributes['showCatName'] = self::getAttributeString($chartDetail->dLbls->showCatName, 'val'); } if (isset($chartDetail->dLbls->showSerName)) { - $plotAttributes['showSerName'] = self::getAttribute($chartDetail->dLbls->showSerName, 'val', 'string'); + $plotAttributes['showSerName'] = self::getAttributeString($chartDetail->dLbls->showSerName, 'val'); } if (isset($chartDetail->dLbls->showPercent)) { - $plotAttributes['showPercent'] = self::getAttribute($chartDetail->dLbls->showPercent, 'val', 'string'); + $plotAttributes['showPercent'] = self::getAttributeString($chartDetail->dLbls->showPercent, 'val'); } if (isset($chartDetail->dLbls->showBubbleSize)) { - $plotAttributes['showBubbleSize'] = self::getAttribute($chartDetail->dLbls->showBubbleSize, 'val', 'string'); + $plotAttributes['showBubbleSize'] = self::getAttributeString($chartDetail->dLbls->showBubbleSize, 'val'); } if (isset($chartDetail->dLbls->showLeaderLines)) { - $plotAttributes['showLeaderLines'] = self::getAttribute($chartDetail->dLbls->showLeaderLines, 'val', 'string'); + $plotAttributes['showLeaderLines'] = self::getAttributeString($chartDetail->dLbls->showLeaderLines, 'val'); } if (isset($chartDetail->dLbls->spPr)) { $sppr = $chartDetail->dLbls->spPr->children($this->aNamespace); @@ -1255,10 +1265,7 @@ private function readChartAttributes($chartDetail): array return $plotAttributes; } - /** - * @param mixed $plotAttributes - */ - private function setChartAttributes(Layout $plotArea, $plotAttributes): void + private function setChartAttributes(Layout $plotArea, array $plotAttributes): void { foreach ($plotAttributes as $plotAttributeKey => $plotAttributeValue) { switch ($plotAttributeKey) { @@ -1308,7 +1315,7 @@ private function readEffects(SimpleXMLElement $chartDetail, ?ChartProperties $ch $sppr = $chartDetail; } if (isset($sppr->effectLst->glow)) { - $axisGlowSize = (float) self::getAttribute($sppr->effectLst->glow, 'rad', 'integer') / ChartProperties::POINTS_WIDTH_MULTIPLIER; + $axisGlowSize = (float) self::getAttributeInteger($sppr->effectLst->glow, 'rad') / ChartProperties::POINTS_WIDTH_MULTIPLIER; if ($axisGlowSize != 0.0) { $colorArray = $this->readColor($sppr->effectLst->glow); $chartObject->setGlowProperties($axisGlowSize, $colorArray['value'], $colorArray['alpha'], $colorArray['type']); @@ -1317,7 +1324,7 @@ private function readEffects(SimpleXMLElement $chartDetail, ?ChartProperties $ch if (isset($sppr->effectLst->softEdge)) { /** @var string */ - $softEdgeSize = self::getAttribute($sppr->effectLst->softEdge, 'rad', 'string'); + $softEdgeSize = self::getAttributeString($sppr->effectLst->softEdge, 'rad'); if (is_numeric($softEdgeSize)) { $chartObject->setSoftEdges((float) ChartProperties::xmlToPoints($softEdgeSize)); } @@ -1333,19 +1340,19 @@ private function readEffects(SimpleXMLElement $chartDetail, ?ChartProperties $ch } if ($type !== '') { /** @var string */ - $blur = self::getAttribute($sppr->effectLst->$type, 'blurRad', 'string'); + $blur = self::getAttributeString($sppr->effectLst->$type, 'blurRad'); $blur = is_numeric($blur) ? ChartProperties::xmlToPoints($blur) : null; /** @var string */ - $dist = self::getAttribute($sppr->effectLst->$type, 'dist', 'string'); + $dist = self::getAttributeString($sppr->effectLst->$type, 'dist'); $dist = is_numeric($dist) ? ChartProperties::xmlToPoints($dist) : null; /** @var string */ - $direction = self::getAttribute($sppr->effectLst->$type, 'dir', 'string'); + $direction = self::getAttributeString($sppr->effectLst->$type, 'dir'); $direction = is_numeric($direction) ? ChartProperties::xmlToAngle($direction) : null; - $algn = self::getAttribute($sppr->effectLst->$type, 'algn', 'string'); - $rot = self::getAttribute($sppr->effectLst->$type, 'rotWithShape', 'string'); + $algn = self::getAttributeString($sppr->effectLst->$type, 'algn'); + $rot = self::getAttributeString($sppr->effectLst->$type, 'rotWithShape'); $size = []; foreach (['sx', 'sy'] as $sizeType) { - $sizeValue = self::getAttribute($sppr->effectLst->$type, $sizeType, 'string'); + $sizeValue = self::getAttributeString($sppr->effectLst->$type, $sizeType); if (is_numeric($sizeValue)) { $size[$sizeType] = ChartProperties::xmlToTenthOfPercent((string) $sizeValue); } else { @@ -1353,7 +1360,7 @@ private function readEffects(SimpleXMLElement $chartDetail, ?ChartProperties $ch } } foreach (['kx', 'ky'] as $sizeType) { - $sizeValue = self::getAttribute($sppr->effectLst->$type, $sizeType, 'string'); + $sizeValue = self::getAttributeString($sppr->effectLst->$type, $sizeType); if (is_numeric($sizeValue)) { $size[$sizeType] = ChartProperties::xmlToAngle((string) $sizeValue); } else { @@ -1389,17 +1396,17 @@ private function readColor(SimpleXMLElement $colorXml): array foreach (ChartColor::EXCEL_COLOR_TYPES as $type) { if (isset($colorXml->$type)) { $result['type'] = $type; - $result['value'] = self::getAttribute($colorXml->$type, 'val', 'string'); + $result['value'] = self::getAttributeString($colorXml->$type, 'val'); if (isset($colorXml->$type->alpha)) { /** @var string */ - $alpha = self::getAttribute($colorXml->$type->alpha, 'val', 'string'); + $alpha = self::getAttributeString($colorXml->$type->alpha, 'val'); if (is_numeric($alpha)) { $result['alpha'] = ChartColor::alphaFromXml($alpha); } } if (isset($colorXml->$type->lumMod)) { /** @var string */ - $brightness = self::getAttribute($colorXml->$type->lumMod, 'val', 'string'); + $brightness = self::getAttributeString($colorXml->$type->lumMod, 'val'); if (is_numeric($brightness)) { $result['brightness'] = ChartColor::alphaFromXml($brightness); } @@ -1424,16 +1431,16 @@ private function readLineStyle(SimpleXMLElement $chartDetail, ?ChartProperties $ } $lineWidth = null; /** @var string */ - $lineWidthTemp = self::getAttribute($sppr->ln, 'w', 'string'); + $lineWidthTemp = self::getAttributeString($sppr->ln, 'w'); if (is_numeric($lineWidthTemp)) { $lineWidth = ChartProperties::xmlToPoints($lineWidthTemp); } /** @var string */ - $compoundType = self::getAttribute($sppr->ln, 'cmpd', 'string'); + $compoundType = self::getAttributeString($sppr->ln, 'cmpd'); /** @var string */ - $dashType = self::getAttribute($sppr->ln->prstDash, 'val', 'string'); + $dashType = self::getAttributeString($sppr->ln->prstDash, 'val'); /** @var string */ - $capType = self::getAttribute($sppr->ln, 'cap', 'string'); + $capType = self::getAttributeString($sppr->ln, 'cap'); if (isset($sppr->ln->miter)) { $joinType = ChartProperties::LINE_STYLE_JOIN_MITER; } elseif (isset($sppr->ln->bevel)) { @@ -1444,17 +1451,17 @@ private function readLineStyle(SimpleXMLElement $chartDetail, ?ChartProperties $ $headArrowSize = ''; $endArrowSize = ''; /** @var string */ - $headArrowType = self::getAttribute($sppr->ln->headEnd, 'type', 'string'); + $headArrowType = self::getAttributeString($sppr->ln->headEnd, 'type'); /** @var string */ - $headArrowWidth = self::getAttribute($sppr->ln->headEnd, 'w', 'string'); + $headArrowWidth = self::getAttributeString($sppr->ln->headEnd, 'w'); /** @var string */ - $headArrowLength = self::getAttribute($sppr->ln->headEnd, 'len', 'string'); + $headArrowLength = self::getAttributeString($sppr->ln->headEnd, 'len'); /** @var string */ - $endArrowType = self::getAttribute($sppr->ln->tailEnd, 'type', 'string'); + $endArrowType = self::getAttributeString($sppr->ln->tailEnd, 'type'); /** @var string */ - $endArrowWidth = self::getAttribute($sppr->ln->tailEnd, 'w', 'string'); + $endArrowWidth = self::getAttributeString($sppr->ln->tailEnd, 'w'); /** @var string */ - $endArrowLength = self::getAttribute($sppr->ln->tailEnd, 'len', 'string'); + $endArrowLength = self::getAttributeString($sppr->ln->tailEnd, 'len'); $chartObject->setLineStyleProperties( $lineWidth, $compoundType, @@ -1480,59 +1487,59 @@ private function setAxisProperties(SimpleXMLElement $chartDetail, ?Axis $whichAx return; } if (isset($chartDetail->delete)) { - $whichAxis->setAxisOption('hidden', (string) self::getAttribute($chartDetail->delete, 'val', 'string')); + $whichAxis->setAxisOption('hidden', (string) self::getAttributeString($chartDetail->delete, 'val')); } if (isset($chartDetail->numFmt)) { $whichAxis->setAxisNumberProperties( - (string) self::getAttribute($chartDetail->numFmt, 'formatCode', 'string'), + (string) self::getAttributeString($chartDetail->numFmt, 'formatCode'), null, - (int) self::getAttribute($chartDetail->numFmt, 'sourceLinked', 'int') + (int) self::getAttributeInteger($chartDetail->numFmt, 'sourceLinked') ); } if (isset($chartDetail->crossBetween)) { - $whichAxis->setCrossBetween((string) self::getAttribute($chartDetail->crossBetween, 'val', 'string')); + $whichAxis->setCrossBetween((string) self::getAttributeString($chartDetail->crossBetween, 'val')); } if (isset($chartDetail->majorTickMark)) { - $whichAxis->setAxisOption('major_tick_mark', (string) self::getAttribute($chartDetail->majorTickMark, 'val', 'string')); + $whichAxis->setAxisOption('major_tick_mark', (string) self::getAttributeString($chartDetail->majorTickMark, 'val')); } if (isset($chartDetail->minorTickMark)) { - $whichAxis->setAxisOption('minor_tick_mark', (string) self::getAttribute($chartDetail->minorTickMark, 'val', 'string')); + $whichAxis->setAxisOption('minor_tick_mark', (string) self::getAttributeString($chartDetail->minorTickMark, 'val')); } if (isset($chartDetail->tickLblPos)) { - $whichAxis->setAxisOption('axis_labels', (string) self::getAttribute($chartDetail->tickLblPos, 'val', 'string')); + $whichAxis->setAxisOption('axis_labels', (string) self::getAttributeString($chartDetail->tickLblPos, 'val')); } if (isset($chartDetail->crosses)) { - $whichAxis->setAxisOption('horizontal_crosses', (string) self::getAttribute($chartDetail->crosses, 'val', 'string')); + $whichAxis->setAxisOption('horizontal_crosses', (string) self::getAttributeString($chartDetail->crosses, 'val')); } if (isset($chartDetail->crossesAt)) { - $whichAxis->setAxisOption('horizontal_crosses_value', (string) self::getAttribute($chartDetail->crossesAt, 'val', 'string')); + $whichAxis->setAxisOption('horizontal_crosses_value', (string) self::getAttributeString($chartDetail->crossesAt, 'val')); } if (isset($chartDetail->scaling->orientation)) { - $whichAxis->setAxisOption('orientation', (string) self::getAttribute($chartDetail->scaling->orientation, 'val', 'string')); + $whichAxis->setAxisOption('orientation', (string) self::getAttributeString($chartDetail->scaling->orientation, 'val')); } if (isset($chartDetail->scaling->max)) { - $whichAxis->setAxisOption('maximum', (string) self::getAttribute($chartDetail->scaling->max, 'val', 'string')); + $whichAxis->setAxisOption('maximum', (string) self::getAttributeString($chartDetail->scaling->max, 'val')); } if (isset($chartDetail->scaling->min)) { - $whichAxis->setAxisOption('minimum', (string) self::getAttribute($chartDetail->scaling->min, 'val', 'string')); + $whichAxis->setAxisOption('minimum', (string) self::getAttributeString($chartDetail->scaling->min, 'val')); } if (isset($chartDetail->scaling->min)) { - $whichAxis->setAxisOption('minimum', (string) self::getAttribute($chartDetail->scaling->min, 'val', 'string')); + $whichAxis->setAxisOption('minimum', (string) self::getAttributeString($chartDetail->scaling->min, 'val')); } if (isset($chartDetail->majorUnit)) { - $whichAxis->setAxisOption('major_unit', (string) self::getAttribute($chartDetail->majorUnit, 'val', 'string')); + $whichAxis->setAxisOption('major_unit', (string) self::getAttributeString($chartDetail->majorUnit, 'val')); } if (isset($chartDetail->minorUnit)) { - $whichAxis->setAxisOption('minor_unit', (string) self::getAttribute($chartDetail->minorUnit, 'val', 'string')); + $whichAxis->setAxisOption('minor_unit', (string) self::getAttributeString($chartDetail->minorUnit, 'val')); } if (isset($chartDetail->baseTimeUnit)) { - $whichAxis->setAxisOption('baseTimeUnit', (string) self::getAttribute($chartDetail->baseTimeUnit, 'val', 'string')); + $whichAxis->setAxisOption('baseTimeUnit', (string) self::getAttributeString($chartDetail->baseTimeUnit, 'val')); } if (isset($chartDetail->majorTimeUnit)) { - $whichAxis->setAxisOption('majorTimeUnit', (string) self::getAttribute($chartDetail->majorTimeUnit, 'val', 'string')); + $whichAxis->setAxisOption('majorTimeUnit', (string) self::getAttributeString($chartDetail->majorTimeUnit, 'val')); } if (isset($chartDetail->minorTimeUnit)) { - $whichAxis->setAxisOption('minorTimeUnit', (string) self::getAttribute($chartDetail->minorTimeUnit, 'val', 'string')); + $whichAxis->setAxisOption('minorTimeUnit', (string) self::getAttributeString($chartDetail->minorTimeUnit, 'val')); } if (isset($chartDetail->txPr)) { $children = $chartDetail->txPr->children($this->aNamespace); @@ -1540,7 +1547,7 @@ private function setAxisProperties(SimpleXMLElement $chartDetail, ?Axis $whichAx $axisText = new AxisText(); if (isset($children->bodyPr)) { /** @var string */ - $textRotation = self::getAttribute($children->bodyPr, 'rot', 'string'); + $textRotation = self::getAttributeString($children->bodyPr, 'rot'); if (is_numeric($textRotation)) { $axisText->setRotation((int) ChartProperties::xmlToAngle($textRotation)); $addAxisText = true; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php index 2b14eab7cc..5368bc0173 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ColumnAndRowAttributes.php @@ -10,11 +10,9 @@ class ColumnAndRowAttributes extends BaseParserClass { - /** @var Worksheet */ - private $worksheet; + private Worksheet $worksheet; - /** @var ?SimpleXMLElement */ - private $worksheetXml; + private ?SimpleXMLElement $worksheetXml; public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null) { @@ -29,7 +27,7 @@ public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXm * @param array $columnAttributes array of attributes (indexes are attribute name, values are value) * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'width', ... ? */ - private function setColumnAttributes($columnAddress, array $columnAttributes): void + private function setColumnAttributes(string $columnAddress, array $columnAttributes): void { if (isset($columnAttributes['xfIndex'])) { $this->worksheet->getColumnDimension($columnAddress)->setXfIndex($columnAttributes['xfIndex']); @@ -55,7 +53,7 @@ private function setColumnAttributes($columnAddress, array $columnAttributes): v * @param array $rowAttributes array of attributes (indexes are attribute name, values are value) * 'xfIndex', 'visible', 'collapsed', 'outlineLevel', 'rowHeight', ... ? */ - private function setRowAttributes($rowNumber, array $rowAttributes): void + private function setRowAttributes(int $rowNumber, array $rowAttributes): void { if (isset($rowAttributes['xfIndex'])) { $this->worksheet->getRowDimension($rowNumber)->setXfIndex($rowAttributes['xfIndex']); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php index 0a90a9d78f..5b68189e1b 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php @@ -14,19 +14,16 @@ class ConditionalStyles { - /** @var Worksheet */ - private $worksheet; + private Worksheet $worksheet; - /** @var SimpleXMLElement */ - private $worksheetXml; + private SimpleXMLElement $worksheetXml; /** * @var array */ private $ns; - /** @var array */ - private $dxfs; + private array $dxfs; public function __construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml, array $dxfs = []) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php index 210c322f9d..d494dc9dad 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/DataValidations.php @@ -8,11 +8,9 @@ class DataValidations { - /** @var Worksheet */ - private $worksheet; + private Worksheet $worksheet; - /** @var SimpleXMLElement */ - private $worksheetXml; + private SimpleXMLElement $worksheetXml; public function __construct(Worksheet $workSheet, SimpleXMLElement $worksheetXml) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php b/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php index 7d48c7967f..e047f236ae 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php @@ -9,8 +9,7 @@ class Hyperlinks { - /** @var Worksheet */ - private $worksheet; + private Worksheet $worksheet; /** @var array */ private $hyperlinks = []; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php index ab57548847..ca58fbee9a 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/PageSetup.php @@ -8,11 +8,9 @@ class PageSetup extends BaseParserClass { - /** @var Worksheet */ - private $worksheet; + private Worksheet $worksheet; - /** @var ?SimpleXMLElement */ - private $worksheetXml; + private ?SimpleXMLElement $worksheetXml; public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php index 0d4701afac..42d55415e1 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php @@ -9,11 +9,9 @@ class Properties { - /** @var XmlScanner */ - private $securityScanner; + private XmlScanner $securityScanner; - /** @var DocumentProperties */ - private $docProps; + private DocumentProperties $docProps; public function __construct(XmlScanner $securityScanner, DocumentProperties $docProps) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php b/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php index 5a496444fe..1b77f0d998 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/SheetViewOptions.php @@ -7,11 +7,9 @@ class SheetViewOptions extends BaseParserClass { - /** @var Worksheet */ - private $worksheet; + private Worksheet $worksheet; - /** @var ?SimpleXMLElement */ - private $worksheetXml; + private ?SimpleXMLElement $worksheetXml; public function __construct(Worksheet $workSheet, ?SimpleXMLElement $worksheetXml = null) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php b/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php index 50467fe745..98e74e3cef 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/SheetViews.php @@ -10,14 +10,11 @@ class SheetViews extends BaseParserClass { - /** @var SimpleXMLElement */ - private $sheetViewXml; + private SimpleXMLElement $sheetViewXml; - /** @var SimpleXMLElement */ - private $sheetViewAttributes; + private SimpleXMLElement $sheetViewAttributes; - /** @var Worksheet */ - private $worksheet; + private Worksheet $worksheet; private string $activePane = ''; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/TableReader.php b/src/PhpSpreadsheet/Reader/Xlsx/TableReader.php index 7f8fd85596..e434ca6836 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/TableReader.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/TableReader.php @@ -9,15 +9,9 @@ class TableReader { - /** - * @var Worksheet - */ - private $worksheet; + private Worksheet $worksheet; - /** - * @var SimpleXMLElement - */ - private $tableXml; + private SimpleXMLElement $tableXml; /** @var array|SimpleXMLElement */ private $tableAttributes; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php b/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php index d7db6240ee..3f7a4f857f 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/WorkbookView.php @@ -7,10 +7,7 @@ class WorkbookView { - /** - * @var Spreadsheet - */ - private $spreadsheet; + private Spreadsheet $spreadsheet; public function __construct(Spreadsheet $spreadsheet) { diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index 9329ae0588..bbc14a9631 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -108,11 +108,9 @@ public function canRead(string $filename): bool /** * Check if the file is a valid SimpleXML. * - * @param string $filename - * * @return false|SimpleXMLElement */ - public function trySimpleXMLLoadString($filename) + public function trySimpleXMLLoadString(string $filename): SimpleXMLElement|bool { try { $xml = simplexml_load_string( @@ -130,12 +128,8 @@ public function trySimpleXMLLoadString($filename) /** * Reads names of the worksheets from a file, without parsing the whole file to a Spreadsheet object. - * - * @param string $filename - * - * @return array */ - public function listWorksheetNames($filename) + public function listWorksheetNames(string $filename): array { File::assertFile($filename); if (!$this->canRead($filename)) { @@ -160,12 +154,8 @@ public function listWorksheetNames($filename) /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). - * - * @param string $filename - * - * @return array */ - public function listWorksheetInfo($filename) + public function listWorksheetInfo(string $filename): array { File::assertFile($filename); if (!$this->canRead($filename)) { diff --git a/src/PhpSpreadsheet/Reader/Xml/PageSettings.php b/src/PhpSpreadsheet/Reader/Xml/PageSettings.php index 137cabaf30..d3b4ccc09c 100644 --- a/src/PhpSpreadsheet/Reader/Xml/PageSettings.php +++ b/src/PhpSpreadsheet/Reader/Xml/PageSettings.php @@ -10,10 +10,7 @@ class PageSettings { - /** - * @var stdClass - */ - private $printSettings; + private stdClass $printSettings; public function __construct(SimpleXMLElement $xmlX) { diff --git a/src/PhpSpreadsheet/Reader/Xml/Properties.php b/src/PhpSpreadsheet/Reader/Xml/Properties.php index e216c254da..17e1121306 100644 --- a/src/PhpSpreadsheet/Reader/Xml/Properties.php +++ b/src/PhpSpreadsheet/Reader/Xml/Properties.php @@ -8,10 +8,7 @@ class Properties { - /** - * @var Spreadsheet - */ - protected $spreadsheet; + protected Spreadsheet $spreadsheet; public function __construct(Spreadsheet $spreadsheet) { diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 4c7de199ee..abd3addf8d 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -59,10 +59,8 @@ protected function __construct() * * @param string $a First column to test (e.g. 'AA') * @param string $b Second column to test (e.g. 'Z') - * - * @return int */ - public static function columnSort($a, $b) + public static function columnSort(string $a, string $b): int { return strcasecmp(strlen($a) . $a, strlen($b) . $b); } @@ -73,10 +71,8 @@ public static function columnSort($a, $b) * * @param string $a First column to test (e.g. 'AA') * @param string $b Second column to test (e.g. 'Z') - * - * @return int */ - public static function columnReverseSort(string $a, string $b) + public static function columnReverseSort(string $a, string $b): int { return -strcasecmp(strlen($a) . $a, strlen($b) . $b); } @@ -87,10 +83,8 @@ public static function columnReverseSort(string $a, string $b) * * @param string $a First cell to test (e.g. 'AA1') * @param string $b Second cell to test (e.g. 'Z1') - * - * @return int */ - public static function cellSort(string $a, string $b) + public static function cellSort(string $a, string $b): int { /** @scrutinizer be-damned */ sscanf($a, '%[A-Z]%d', $ac, $ar); @@ -113,10 +107,8 @@ public static function cellSort(string $a, string $b) * * @param string $a First cell to test (e.g. 'AA1') * @param string $b Second cell to test (e.g. 'Z1') - * - * @return int */ - public static function cellReverseSort(string $a, string $b) + public static function cellReverseSort(string $a, string $b): int { /** @scrutinizer be-damned */ sscanf($a, '%[A-Z]%d', $ac, $ar); @@ -409,10 +401,10 @@ public function insertNewBefore( // Find missing coordinates. This is important when inserting column before the last column $cellCollection = $worksheet->getCellCollection(); $missingCoordinates = array_filter( - array_map(function ($row) use ($highestColumn) { + array_map(function ($row) use ($highestColumn): string { return "{$highestColumn}{$row}"; }, range(1, $highestRow)), - function ($coordinate) use ($cellCollection) { + function ($coordinate) use ($cellCollection): bool { return $cellCollection->has($coordinate) === false; } ); @@ -575,7 +567,7 @@ public function updateFormulaReferences( $worksheetName = '', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false - ) { + ): string { if ( $this->cellReferenceHelper === null || $this->cellReferenceHelper->refreshRequired($beforeCellAddress, $numberOfColumns, $numberOfRows) @@ -881,7 +873,7 @@ private function updateCellReference($cellReference = 'A1', bool $includeAbsolut * @param string $oldName Old name (name to replace) * @param string $newName New name */ - public function updateNamedFormulae(Spreadsheet $spreadsheet, $oldName = '', $newName = ''): void + public function updateNamedFormulae(Spreadsheet $spreadsheet, string $oldName = '', string $newName = ''): void { if ($oldName == '') { return; diff --git a/src/PhpSpreadsheet/RichText/ITextElement.php b/src/PhpSpreadsheet/RichText/ITextElement.php index 39b70c868b..284a365e35 100644 --- a/src/PhpSpreadsheet/RichText/ITextElement.php +++ b/src/PhpSpreadsheet/RichText/ITextElement.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Style\Font; + interface ITextElement { /** @@ -23,7 +25,7 @@ public function setText($text); /** * Get font. * - * @return null|\PhpOffice\PhpSpreadsheet\Style\Font + * @return null|Font */ public function getFont(); diff --git a/src/PhpSpreadsheet/RichText/RichText.php b/src/PhpSpreadsheet/RichText/RichText.php index 88e7c79236..564b0fe44f 100644 --- a/src/PhpSpreadsheet/RichText/RichText.php +++ b/src/PhpSpreadsheet/RichText/RichText.php @@ -13,7 +13,7 @@ class RichText implements IComparable * * @var ITextElement[] */ - private $richTextElements; + private array $richTextElements; /** * Create a new RichText instance. @@ -44,7 +44,7 @@ public function __construct(?Cell $cell = null) * * @return $this */ - public function addText(ITextElement $text) + public function addText(ITextElement $text): static { $this->richTextElements[] = $text; @@ -55,10 +55,8 @@ public function addText(ITextElement $text) * Create text. * * @param string $text Text - * - * @return TextElement */ - public function createText($text) + public function createText($text): TextElement { $objText = new TextElement($text); $this->addText($objText); @@ -70,10 +68,8 @@ public function createText($text) * Create text run. * * @param string $text Text - * - * @return Run */ - public function createTextRun($text) + public function createTextRun($text): Run { $objText = new Run($text); $this->addText($objText); @@ -83,10 +79,8 @@ public function createTextRun($text) /** * Get plain text. - * - * @return string */ - public function getPlainText() + public function getPlainText(): string { // Return value $returnValue = ''; @@ -101,10 +95,8 @@ public function getPlainText() /** * Convert to string. - * - * @return string */ - public function __toString() + public function __toString(): string { return $this->getPlainText(); } @@ -126,7 +118,7 @@ public function getRichTextElements() * * @return $this */ - public function setRichTextElements(array $textElements) + public function setRichTextElements(array $textElements): static { $this->richTextElements = $textElements; @@ -138,7 +130,7 @@ public function setRichTextElements(array $textElements) * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { $hashElements = ''; foreach ($this->richTextElements as $element) { diff --git a/src/PhpSpreadsheet/RichText/Run.php b/src/PhpSpreadsheet/RichText/Run.php index 862cdbf92b..ebc1865805 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -28,7 +28,7 @@ public function __construct($text = '') /** * Get font. * - * @return null|\PhpOffice\PhpSpreadsheet\Style\Font + * @return null|Font */ public function getFont() { @@ -42,7 +42,7 @@ public function getFont() * * @return $this */ - public function setFont(?Font $font = null) + public function setFont(?Font $font = null): static { $this->font = $font; @@ -54,7 +54,7 @@ public function setFont(?Font $font = null) * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->getText() . diff --git a/src/PhpSpreadsheet/RichText/TextElement.php b/src/PhpSpreadsheet/RichText/TextElement.php index ee693a2b3f..bd30d6276b 100644 --- a/src/PhpSpreadsheet/RichText/TextElement.php +++ b/src/PhpSpreadsheet/RichText/TextElement.php @@ -2,6 +2,8 @@ namespace PhpOffice\PhpSpreadsheet\RichText; +use PhpOffice\PhpSpreadsheet\Style\Font; + class TextElement implements ITextElement { /** @@ -49,7 +51,7 @@ public function setText($text) /** * Get font. For this class, the return value is always null. * - * @return null|\PhpOffice\PhpSpreadsheet\Style\Font + * @return null|Font */ public function getFont() { diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 214865afdf..d286afc685 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -53,7 +53,7 @@ class Settings * * @return bool Success or failure */ - public static function setLocale(string $locale) + public static function setLocale(string $locale): bool { return Calculation::getInstance()->setLocale($locale); } @@ -91,7 +91,7 @@ public static function getChartRenderer(): ?string public static function htmlEntityFlags(): int { - return \ENT_COMPAT; + return ENT_COMPAT; } /** diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 9f5abe34d9..700ee3c24f 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -72,7 +72,7 @@ class Date * * @return bool Success or failure */ - public static function setExcelCalendar($baseYear) + public static function setExcelCalendar($baseYear): bool { if ( ($baseYear == self::CALENDAR_WINDOWS_1900) || @@ -103,7 +103,7 @@ public static function getExcelCalendar() * * @return bool Success or failure */ - public static function setDefaultTimezone($timeZone) + public static function setDefaultTimezone($timeZone): bool { try { $timeZone = self::validateTimeZone($timeZone); @@ -147,7 +147,7 @@ public static function getDefaultTimezoneOrNull(): ?DateTimeZone * * @return ?DateTimeZone The timezone as a timezone object */ - private static function validateTimeZone($timeZone) + private static function validateTimeZone($timeZone): ?DateTimeZone { if ($timeZone instanceof DateTimeZone || $timeZone === null) { return $timeZone; @@ -252,7 +252,7 @@ public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) * * @return int Unix timetamp for this date/time */ - public static function excelToTimestamp($excelTimestamp, $timeZone = null) + public static function excelToTimestamp($excelTimestamp, $timeZone = null): int { $dto = self::excelToDateTimeObject($excelTimestamp, $timeZone); self::roundMicroseconds($dto); @@ -289,7 +289,7 @@ public static function PHPToExcel($dateValue) * * @return float MS Excel serialized date/time value */ - public static function dateTimeToExcel(DateTimeInterface $dateValue) + public static function dateTimeToExcel(DateTimeInterface $dateValue): float { $seconds = (float) sprintf('%d.%06d', $dateValue->format('s'), $dateValue->format('u')); @@ -312,7 +312,7 @@ public static function dateTimeToExcel(DateTimeInterface $dateValue) * * @return false|float MS Excel serialized date/time value */ - public static function timestampToExcel($unixTimestamp) + public static function timestampToExcel($unixTimestamp): bool|float { if (!is_numeric($unixTimestamp)) { return false; @@ -333,7 +333,7 @@ public static function timestampToExcel($unixTimestamp) * * @return float Excel date/time value */ - public static function formattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0) + public static function formattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0): float { if (self::$excelCalendar == self::CALENDAR_WINDOWS_1900) { // @@ -372,10 +372,8 @@ public static function formattedPHPToExcel($year, $month, $day, $hours = 0, $min * Is a given cell a date/time? * * @param mixed $value - * - * @return bool */ - public static function isDateTime(Cell $cell, $value = null, bool $dateWithoutTimeOkay = true) + public static function isDateTime(Cell $cell, $value = null, bool $dateWithoutTimeOkay = true): bool { $result = false; $worksheet = $cell->getWorksheetOrNull(); @@ -404,10 +402,8 @@ public static function isDateTime(Cell $cell, $value = null, bool $dateWithoutTi /** * Is a given NumberFormat code a date/time format code? - * - * @return bool */ - public static function isDateTimeFormat(NumberFormat $excelFormatCode, bool $dateWithoutTimeOkay = true) + public static function isDateTimeFormat(NumberFormat $excelFormatCode, bool $dateWithoutTimeOkay = true): bool { return self::isDateTimeFormatCode((string) $excelFormatCode->getFormatCode(), $dateWithoutTimeOkay); } @@ -419,10 +415,8 @@ public static function isDateTimeFormat(NumberFormat $excelFormatCode, bool $dat * Is a given number format code a date/time? * * @param string $excelFormatCode - * - * @return bool */ - public static function isDateTimeFormatCode($excelFormatCode, bool $dateWithoutTimeOkay = true) + public static function isDateTimeFormatCode($excelFormatCode, bool $dateWithoutTimeOkay = true): bool { if (strtolower($excelFormatCode) === strtolower(NumberFormat::FORMAT_GENERAL)) { // "General" contains an epoch letter 'e', so we trap for it explicitly here (case-insensitive check) @@ -482,7 +476,7 @@ public static function isDateTimeFormatCode($excelFormatCode, bool $dateWithoutT * * @return false|float Excel date/time serial value */ - public static function stringToExcel($dateValue) + public static function stringToExcel($dateValue): bool|float { if (strlen($dateValue) < 2) { return false; diff --git a/src/PhpSpreadsheet/Shared/Drawing.php b/src/PhpSpreadsheet/Shared/Drawing.php index f69310fc61..edaad86153 100644 --- a/src/PhpSpreadsheet/Shared/Drawing.php +++ b/src/PhpSpreadsheet/Shared/Drawing.php @@ -15,7 +15,7 @@ class Drawing * * @return int Value in EMU */ - public static function pixelsToEMU($pixelValue) + public static function pixelsToEMU($pixelValue): int|float { return $pixelValue * 9525; } @@ -27,7 +27,7 @@ public static function pixelsToEMU($pixelValue) * * @return int Value in pixels */ - public static function EMUToPixels($emuValue) + public static function EMUToPixels($emuValue): int { $emuValue = (int) $emuValue; if ($emuValue != 0) { @@ -46,7 +46,7 @@ public static function EMUToPixels($emuValue) * * @return float|int Value in cell dimension */ - public static function pixelsToCellDimension($pixelValue, \PhpOffice\PhpSpreadsheet\Style\Font $defaultFont) + public static function pixelsToCellDimension($pixelValue, \PhpOffice\PhpSpreadsheet\Style\Font $defaultFont): int|float { // Font name and size $name = $defaultFont->getName(); @@ -72,7 +72,7 @@ public static function pixelsToCellDimension($pixelValue, \PhpOffice\PhpSpreadsh * * @return int Value in pixels */ - public static function cellDimensionToPixels($cellWidth, \PhpOffice\PhpSpreadsheet\Style\Font $defaultFont) + public static function cellDimensionToPixels($cellWidth, \PhpOffice\PhpSpreadsheet\Style\Font $defaultFont): int { // Font name and size $name = $defaultFont->getName(); @@ -102,7 +102,7 @@ public static function cellDimensionToPixels($cellWidth, \PhpOffice\PhpSpreadshe * * @return float Value in points */ - public static function pixelsToPoints($pixelValue) + public static function pixelsToPoints($pixelValue): float { return $pixelValue * 0.75; } @@ -114,7 +114,7 @@ public static function pixelsToPoints($pixelValue) * * @return int Value in pixels */ - public static function pointsToPixels($pointValue) + public static function pointsToPixels($pointValue): int { if ($pointValue != 0) { return (int) ceil($pointValue / 0.75); @@ -130,7 +130,7 @@ public static function pointsToPixels($pointValue) * * @return int Angle */ - public static function degreesToAngle($degrees) + public static function degreesToAngle($degrees): int { return (int) round($degrees * 60000); } @@ -142,7 +142,7 @@ public static function degreesToAngle($degrees) * * @return int Degrees */ - public static function angleToDegrees($angle) + public static function angleToDegrees($angle): int { $angle = (int) $angle; if ($angle != 0) { @@ -159,13 +159,11 @@ public static function angleToDegrees($angle) * * @param string $bmpFilename Path to Windows DIB (BMP) image * - * @return GdImage|resource - * * @deprecated 1.26 use Php function imagecreatefrombmp instead * * @codeCoverageIgnore */ - public static function imagecreatefrombmp($bmpFilename) + public static function imagecreatefrombmp($bmpFilename): GdImage { $retVal = @imagecreatefrombmp($bmpFilename); if ($retVal === false) { diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php index 51c6860cbe..9cf5d43b5c 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php @@ -3,25 +3,21 @@ namespace PhpOffice\PhpSpreadsheet\Shared\Escher; use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException; +use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer; class DgContainer { /** * Drawing index, 1-based. - * - * @var ?int */ - private $dgId; + private ?int $dgId = null; /** * Last shape index in this drawing. - * - * @var ?int */ - private $lastSpId; + private ?int $lastSpId = null; - /** @var ?DgContainer\SpgrContainer */ - private $spgrContainer; + private ?SpgrContainer $spgrContainer = null; public function getDgId(): ?int { diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php index 260df9cd4c..76fe47608d 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php @@ -6,10 +6,8 @@ class SpgrContainer { /** * Parent Shape Group Container. - * - * @var null|SpgrContainer */ - private $parent; + private ?self $parent = null; /** * Shape Container collection. @@ -58,7 +56,7 @@ public function getChildren(): array * * @return SpgrContainer\SpContainer[] */ - public function getAllSpContainers() + public function getAllSpContainers(): array { $allSpContainers = []; diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index 8a81ff5797..426d775ed7 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -354,7 +354,7 @@ public function getEndOffsetY() * * @return int Nesting level */ - public function getNestingLevel() + public function getNestingLevel(): int { $nestingLevel = 0; diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php index 03b261f8fe..ea036afff2 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php @@ -8,10 +8,8 @@ class Blip { /** * The parent BSE. - * - * @var BSE */ - private $parent; + private BSE $parent; /** * Raw image data. diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index b868aaa23d..1bcab29144 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -296,7 +296,7 @@ public static function getExtraFontArray(): array * * @return bool Success or failure */ - public static function setAutoSizeMethod($method) + public static function setAutoSizeMethod($method): bool { if (!in_array($method, self::AUTOSIZE_METHODS)) { return false; @@ -470,12 +470,11 @@ public static function getTextWidthPixelsExact(string $text, FontStyle $font, in /** * Get approximate width in pixels for a string of text in a certain font at a certain rotation angle. * - * @param string $columnText * @param int $rotation * * @return int Text width in pixels (no padding added) */ - public static function getTextWidthPixelsApprox($columnText, FontStyle $font, $rotation = 0) + public static function getTextWidthPixelsApprox(string $columnText, FontStyle $font, $rotation = 0): int { $fontName = $font->getName(); $fontSize = $font->getSize(); @@ -528,7 +527,7 @@ public static function getTextWidthPixelsApprox($columnText, FontStyle $font, $r * * @return int Font size (in pixels) */ - public static function fontSizeToPixels($fontSizeInPoints) + public static function fontSizeToPixels($fontSizeInPoints): int { return (int) ((4 / 3) * $fontSizeInPoints); } @@ -540,7 +539,7 @@ public static function fontSizeToPixels($fontSizeInPoints) * * @return int Size (in pixels) */ - public static function inchSizeToPixels($sizeInInch) + public static function inchSizeToPixels($sizeInInch): int|float { return $sizeInInch * 96; } @@ -552,7 +551,7 @@ public static function inchSizeToPixels($sizeInInch) * * @return float Size (in pixels) */ - public static function centimeterSizeToPixels($sizeInCm) + public static function centimeterSizeToPixels($sizeInCm): float { return $sizeInCm * 37.795275591; } @@ -639,7 +638,7 @@ public static function getTrueTypeFontFileFromFont(FontStyle $font, bool $checkP * * @return int Character set code */ - public static function getCharsetFromFontName($fontName) + public static function getCharsetFromFontName($fontName): int { return self::CHARSET_FROM_FONT_NAME[$fontName] ?? self::CHARSET_ANSI_LATIN; } @@ -651,9 +650,9 @@ public static function getCharsetFromFontName($fontName) * @param FontStyle $font The workbooks default font * @param bool $returnAsPixels true = return column width in pixels, false = return in OOXML units * - * @return mixed Column width + * @return ($returnAsPixels is true ? int : float) Column width */ - public static function getDefaultColumnWidthByFont(FontStyle $font, $returnAsPixels = false) + public static function getDefaultColumnWidthByFont(FontStyle $font, bool $returnAsPixels = false): float|int { if (isset(self::DEFAULT_COLUMN_WIDTHS[$font->getName()][$font->getSize()])) { // Exact width can be determined @@ -685,7 +684,7 @@ public static function getDefaultColumnWidthByFont(FontStyle $font, $returnAsPix * * @return float Row height in points */ - public static function getDefaultRowHeightByFont(FontStyle $font) + public static function getDefaultRowHeightByFont(FontStyle $font): float { $name = $font->getName(); $size = $font->getSize(); diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index c14afb2cd0..7ea538b8b1 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -114,7 +114,7 @@ class OLE * * @return bool true on success, PEAR_Error on failure */ - public function read($filename) + public function read($filename): bool { $fh = @fopen($filename, 'rb'); if ($fh === false) { @@ -200,10 +200,8 @@ public function read($filename) /** * @param int $blockId byte offset from beginning of file - * - * @return int */ - public function getBlockOffset($blockId) + public function getBlockOffset(int $blockId): int { return 512 + $blockId * $this->bigBlockSize; } @@ -304,7 +302,7 @@ private static function readInt4($fileHandle) * * @return bool true on success, PEAR_Error on failure */ - public function readPpsWks($blockId) + public function readPpsWks($blockId): bool { $fh = $this->getStream($blockId); for ($pos = 0; true; $pos += 128) { @@ -381,7 +379,7 @@ public function readPpsWks($blockId) * * @return bool Whether the PPS tree for the given PPS is complete */ - private function ppsTreeComplete($index) + private function ppsTreeComplete($index): bool { return isset($this->_list[$index]) && ($pps = $this->_list[$index]) && @@ -401,7 +399,7 @@ private function ppsTreeComplete($index) * * @return bool true if it's a File PPS, false otherwise */ - public function isFile($index) + public function isFile($index): bool { if (isset($this->_list[$index])) { return $this->_list[$index]->Type == self::OLE_PPS_TYPE_FILE; @@ -418,7 +416,7 @@ public function isFile($index) * * @return bool true if it's a Root PPS, false otherwise */ - public function isRoot($index) + public function isRoot($index): bool { if (isset($this->_list[$index])) { return $this->_list[$index]->Type == self::OLE_PPS_TYPE_ROOT; @@ -432,7 +430,7 @@ public function isRoot($index) * * @return int The total number of PPS's found in the OLE container */ - public function ppsTotal() + public function ppsTotal(): int { return count($this->_list); } @@ -450,7 +448,7 @@ public function ppsTotal() * * @see OLE_PPS_File::getStream() */ - public function getData($index, $position, $length) + public function getData($index, $position, $length): string { // if position is not valid return empty string if (!isset($this->_list[$index]) || ($position >= $this->_list[$index]->Size) || ($position < 0)) { @@ -487,7 +485,7 @@ public function getDataLength($index) * * @return string The string in Unicode */ - public static function ascToUcs($ascii) + public static function ascToUcs($ascii): string { $rawname = ''; $iMax = strlen($ascii); @@ -507,7 +505,7 @@ public static function ascToUcs($ascii) * * @return string The string for the OLE container */ - public static function localDateToOLE($date) + public static function localDateToOLE($date): string { if (!$date) { return "\x00\x00\x00\x00\x00\x00\x00\x00"; diff --git a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php index 5d5babc3f4..28c72302f3 100644 --- a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php +++ b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php @@ -49,7 +49,7 @@ class ChainedBlockStream * * @return bool true on success */ - public function stream_open($path, $mode, $options, &$openedPath) // @codingStandardsIgnoreLine + public function stream_open($path, $mode, $options, &$openedPath): bool // @codingStandardsIgnoreLine { if ($mode[0] !== 'r') { if ($options & STREAM_REPORT_ERRORS) { @@ -117,7 +117,7 @@ public function stream_close(): void // @codingStandardsIgnoreLine * * @return false|string */ - public function stream_read($count) // @codingStandardsIgnoreLine + public function stream_read($count): bool|string // @codingStandardsIgnoreLine { if ($this->stream_eof()) { return false; @@ -133,7 +133,7 @@ public function stream_read($count) // @codingStandardsIgnoreLine * * @return bool TRUE if the file pointer is at EOF; otherwise FALSE */ - public function stream_eof() // @codingStandardsIgnoreLine + public function stream_eof(): bool // @codingStandardsIgnoreLine { return $this->pos >= strlen($this->data); } @@ -154,10 +154,8 @@ public function stream_tell() // @codingStandardsIgnoreLine * * @param int $offset byte offset * @param int $whence SEEK_SET, SEEK_CUR or SEEK_END - * - * @return bool */ - public function stream_seek($offset, $whence) // @codingStandardsIgnoreLine + public function stream_seek($offset, $whence): bool // @codingStandardsIgnoreLine { if ($whence == SEEK_SET && $offset >= 0) { $this->pos = $offset; @@ -176,10 +174,8 @@ public function stream_seek($offset, $whence) // @codingStandardsIgnoreLine /** * Implements support for fstat(). Currently the only supported field is * "size". - * - * @return array */ - public function stream_stat() // @codingStandardsIgnoreLine + public function stream_stat(): array // @codingStandardsIgnoreLine { return [ 'size' => strlen($this->data), diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index 2740a1b6da..6b487c36dd 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -203,7 +203,7 @@ public function getPpsWk() * * @return int The index for this PPS */ - public static function savePpsSetPnt(&$raList, $to_save, $depth = 0) + public static function savePpsSetPnt(array &$raList, $to_save, $depth = 0) { if (!is_array($to_save) || (empty($to_save))) { return 0xFFFFFFFF; diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php index dd1cda2de0..8a392817c5 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php @@ -44,10 +44,8 @@ public function __construct($name) /** * Initialization method. Has to be called right after OLE_PPS_File(). - * - * @return mixed true on success */ - public function init() + public function init(): bool { return true; } @@ -57,7 +55,7 @@ public function init() * * @param string $data The data to append */ - public function append($data): void + public function append(string $data): void { $this->_data .= $data; } diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index e1cbf8c90d..5a1e5d4629 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -66,7 +66,7 @@ public function __construct($time_1st, $time_2nd, $raChild) * * @return bool true on success */ - public function save($fileHandle) + public function save($fileHandle): bool { $this->fileHandle = $fileHandle; @@ -106,7 +106,7 @@ public function save($fileHandle) * * @return float[] The array of numbers */ - private function calcSize(&$raList) + private function calcSize(array &$raList): array { // Calculate Basic Setting [$iSBDcnt, $iBBcnt, $iPPScnt] = [0, 0, 0]; @@ -141,11 +141,9 @@ private function calcSize(&$raList) * * @param int $i2 The argument * - * @return float - * * @see save() */ - private static function adjust2($i2) + private static function adjust2($i2): float { $iWk = log($i2) / log(2); @@ -154,12 +152,8 @@ private static function adjust2($i2) /** * Save OLE header. - * - * @param int $iSBDcnt - * @param int $iBBcnt - * @param int $iPPScnt */ - private function saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void + private function saveHeader(int $iSBDcnt, int $iBBcnt, int $iPPScnt): void { $FILE = $this->fileHandle; @@ -235,10 +229,9 @@ private function saveHeader($iSBDcnt, $iBBcnt, $iPPScnt): void /** * Saving big data (PPS's with data bigger than \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL). * - * @param int $iStBlk * @param array $raList Reference to array of PPS's */ - private function saveBigData($iStBlk, &$raList): void + private function saveBigData(int $iStBlk, array &$raList): void { $FILE = $this->fileHandle; @@ -267,10 +260,8 @@ private function saveBigData($iStBlk, &$raList): void * get small data (PPS's with data smaller than \PhpOffice\PhpSpreadsheet\Shared\OLE::OLE_DATA_SIZE_SMALL). * * @param array $raList Reference to array of PPS's - * - * @return string */ - private function makeSmallData(&$raList) + private function makeSmallData(array &$raList): string { $sRes = ''; $FILE = $this->fileHandle; @@ -320,7 +311,7 @@ private function makeSmallData(&$raList) * * @param array $raList Reference to an array with all PPS's */ - private function savePps(&$raList): void + private function savePps(array &$raList): void { // Save each PPS WK $iC = count($raList); @@ -337,12 +328,8 @@ private function savePps(&$raList): void /** * Saving Big Block Depot. - * - * @param int $iSbdSize - * @param int $iBsize - * @param int $iPpsCnt */ - private function saveBbd($iSbdSize, $iBsize, $iPpsCnt): void + private function saveBbd(int $iSbdSize, int $iBsize, int $iPpsCnt): void { $FILE = $this->fileHandle; // Calculate Basic Setting diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index fcc9639530..e15e9dac94 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -190,10 +190,8 @@ public function read(string $filename): void * Extract binary stream data. * * @param ?int $stream - * - * @return null|string */ - public function getStream($stream) + public function getStream($stream): ?string { if ($stream === null) { return null; @@ -242,7 +240,7 @@ public function getStream($stream) * * @return string Data for standard stream */ - private function readData($block) + private function readData($block): string { $data = ''; @@ -317,12 +315,9 @@ private function readPropertySets(): void /** * Read 4 bytes of data at specified position. * - * @param string $data * @param int $pos - * - * @return int */ - private static function getInt4d($data, $pos) + private static function getInt4d(string $data, $pos): int { if ($pos < 0) { // Invalid position diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index f30a9bd2d8..988f7a7d10 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -288,10 +288,8 @@ private static function buildCharacterSets(): void * element or in the shared string element. * * @param string $textValue Value to unescape - * - * @return string */ - public static function controlCharacterOOXML2PHP($textValue) + public static function controlCharacterOOXML2PHP($textValue): string { self::buildCharacterSets(); @@ -310,10 +308,8 @@ public static function controlCharacterOOXML2PHP($textValue) * element or in the shared string element. * * @param string $textValue Value to escape - * - * @return string */ - public static function controlCharacterPHP2OOXML($textValue) + public static function controlCharacterPHP2OOXML($textValue): string { self::buildCharacterSets(); diff --git a/src/PhpSpreadsheet/Shared/Trend/BestFit.php b/src/PhpSpreadsheet/Shared/Trend/BestFit.php index a8d7c93b7d..29dbbed040 100644 --- a/src/PhpSpreadsheet/Shared/Trend/BestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/BestFit.php @@ -20,10 +20,8 @@ abstract class BestFit /** * Number of entries in the sets of x- and y-value arrays. - * - * @var int */ - protected $valueCount = 0; + protected int $valueCount; /** * X-value dataseries of values. @@ -430,7 +428,7 @@ private function sumSquares(array $values) { return array_sum( array_map( - function ($value) { + function ($value): float|int { return $value ** 2; }, $values diff --git a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php index eb8cd746d3..ebefd9c004 100644 --- a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php @@ -19,7 +19,7 @@ class ExponentialBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue) + public function getValueOfYForX($xValue): float { return $this->getIntersect() * $this->getSlope() ** ($xValue - $this->xOffset); } @@ -31,7 +31,7 @@ public function getValueOfYForX($xValue) * * @return float X-Value */ - public function getValueOfXForY($yValue) + public function getValueOfXForY($yValue): float { return log(($yValue + $this->yOffset) / $this->getIntersect()) / log($this->getSlope()); } @@ -40,10 +40,8 @@ public function getValueOfXForY($yValue) * Return the Equation of the best-fit line. * * @param int $dp Number of places of decimal precision to display - * - * @return string */ - public function getEquation($dp = 0) + public function getEquation($dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -55,10 +53,8 @@ public function getEquation($dp = 0) * Return the Slope of the line. * * @param int $dp Number of places of decimal precision to display - * - * @return float */ - public function getSlope($dp = 0) + public function getSlope($dp = 0): float { if ($dp != 0) { return round(exp($this->slope), $dp); @@ -71,10 +67,8 @@ public function getSlope($dp = 0) * Return the Value of X where it intersects Y = 0. * * @param int $dp Number of places of decimal precision to display - * - * @return float */ - public function getIntersect($dp = 0) + public function getIntersect($dp = 0): float { if ($dp != 0) { return round(exp($this->intersect), $dp); @@ -92,7 +86,7 @@ public function getIntersect($dp = 0) private function exponentialRegression(array $yValues, array $xValues, bool $const): void { $adjustedYValues = array_map( - function ($value) { + function ($value): float { return ($value < 0.0) ? 0 - log(abs($value)) : log($value); }, $yValues diff --git a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php index 65d6b4ff44..ef03b84050 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -19,7 +19,7 @@ class LinearBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue) + public function getValueOfYForX($xValue): int|float { return $this->getIntersect() + $this->getSlope() * $xValue; } @@ -31,7 +31,7 @@ public function getValueOfYForX($xValue) * * @return float X-Value */ - public function getValueOfXForY($yValue) + public function getValueOfXForY($yValue): int|float { return ($yValue - $this->getIntersect()) / $this->getSlope(); } @@ -40,10 +40,8 @@ public function getValueOfXForY($yValue) * Return the Equation of the best-fit line. * * @param int $dp Number of places of decimal precision to display - * - * @return string */ - public function getEquation($dp = 0) + public function getEquation($dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); diff --git a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php index 2366dc636a..1f91545fe6 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php @@ -19,7 +19,7 @@ class LogarithmicBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue) + public function getValueOfYForX($xValue): float { return $this->getIntersect() + $this->getSlope() * log($xValue - $this->xOffset); } @@ -31,7 +31,7 @@ public function getValueOfYForX($xValue) * * @return float X-Value */ - public function getValueOfXForY($yValue) + public function getValueOfXForY($yValue): float { return exp(($yValue - $this->getIntersect()) / $this->getSlope()); } @@ -40,10 +40,8 @@ public function getValueOfXForY($yValue) * Return the Equation of the best-fit line. * * @param int $dp Number of places of decimal precision to display - * - * @return string */ - public function getEquation($dp = 0) + public function getEquation($dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -60,7 +58,7 @@ public function getEquation($dp = 0) private function logarithmicRegression(array $yValues, array $xValues, bool $const): void { $adjustedYValues = array_map( - function ($value) { + function ($value): float { return ($value < 0.0) ? 0 - log(abs($value)) : log($value); }, $yValues diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index 222a423004..86131f42a3 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -64,7 +64,7 @@ public function getValueOfYForX($xValue) * * @return float X-Value */ - public function getValueOfXForY($yValue) + public function getValueOfXForY($yValue): int|float { return ($yValue - $this->getIntersect()) / $this->getSlope(); } @@ -73,10 +73,8 @@ public function getValueOfXForY($yValue) * Return the Equation of the best-fit line. * * @param int $dp Number of places of decimal precision to display - * - * @return string */ - public function getEquation($dp = 0) + public function getEquation($dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -122,10 +120,8 @@ public function getSlope($dp = 0) /** * @param int $dp - * - * @return array */ - public function getCoefficients($dp = 0) + public function getCoefficients($dp = 0): array { // Phpstan and Scrutinizer are both correct - getSlope returns float, not array. // @phpstan-ignore-next-line @@ -139,7 +135,7 @@ public function getCoefficients($dp = 0) * @param float[] $yValues The set of Y-values for this regression * @param float[] $xValues The set of X-values for this regression */ - private function polynomialRegression($order, $yValues, $xValues): void + private function polynomialRegression($order, array $yValues, array $xValues): void { // calculate sums $x_sum = array_sum($xValues); diff --git a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php index cafd01158e..e1955919a0 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php @@ -19,7 +19,7 @@ class PowerBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue) + public function getValueOfYForX($xValue): float { return $this->getIntersect() * ($xValue - $this->xOffset) ** $this->getSlope(); } @@ -31,7 +31,7 @@ public function getValueOfYForX($xValue) * * @return float X-Value */ - public function getValueOfXForY($yValue) + public function getValueOfXForY($yValue): float { return (($yValue + $this->yOffset) / $this->getIntersect()) ** (1 / $this->getSlope()); } @@ -40,10 +40,8 @@ public function getValueOfXForY($yValue) * Return the Equation of the best-fit line. * * @param int $dp Number of places of decimal precision to display - * - * @return string */ - public function getEquation($dp = 0) + public function getEquation($dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -55,10 +53,8 @@ public function getEquation($dp = 0) * Return the Value of X where it intersects Y = 0. * * @param int $dp Number of places of decimal precision to display - * - * @return float */ - public function getIntersect($dp = 0) + public function getIntersect($dp = 0): float { if ($dp != 0) { return round(exp($this->intersect), $dp); @@ -76,13 +72,13 @@ public function getIntersect($dp = 0) private function powerRegression(array $yValues, array $xValues, bool $const): void { $adjustedYValues = array_map( - function ($value) { + function ($value): float { return ($value < 0.0) ? 0 - log(abs($value)) : log($value); }, $yValues ); $adjustedXValues = array_map( - function ($value) { + function ($value): float { return ($value < 0.0) ? 0 - log(abs($value)) : log($value); }, $xValues diff --git a/src/PhpSpreadsheet/Shared/Trend/Trend.php b/src/PhpSpreadsheet/Shared/Trend/Trend.php index 117848c778..62399ca3ad 100644 --- a/src/PhpSpreadsheet/Shared/Trend/Trend.php +++ b/src/PhpSpreadsheet/Shared/Trend/Trend.php @@ -49,14 +49,13 @@ class Trend private static $trendCache = []; /** - * @param string $trendType * @param array $yValues * @param array $xValues * @param bool $const * * @return mixed */ - public static function calculate($trendType = self::TREND_BEST_FIT, $yValues = [], $xValues = [], $const = true) + public static function calculate(string $trendType = self::TREND_BEST_FIT, $yValues = [], $xValues = [], $const = true) { // Calculate number of points in each dataset $nY = count($yValues); diff --git a/src/PhpSpreadsheet/Shared/XMLWriter.php b/src/PhpSpreadsheet/Shared/XMLWriter.php index d9f403d7ad..c0d880e849 100644 --- a/src/PhpSpreadsheet/Shared/XMLWriter.php +++ b/src/PhpSpreadsheet/Shared/XMLWriter.php @@ -15,10 +15,8 @@ class XMLWriter extends \XMLWriter /** * Temporary filename. - * - * @var string */ - private $tempFileName = ''; + private string $tempFileName = ''; /** * Create a new XMLWriter instance. @@ -90,10 +88,8 @@ public function getData() * Wrapper method for writeRaw. * * @param null|string|string[] $rawTextData - * - * @return bool */ - public function writeRawData($rawTextData) + public function writeRawData($rawTextData): bool { if (is_array($rawTextData)) { $rawTextData = implode("\n", $rawTextData); diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php index a67583441c..8c16e3cd46 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -61,7 +61,7 @@ public static function sizeCol(Worksheet $worksheet, $col = 'A') * * @return int The width in pixels */ - public static function sizeRow(Worksheet $worksheet, $row = 1) + public static function sizeRow(Worksheet $worksheet, $row = 1): int { // default font of the workbook $font = $worksheet->getParentOrThrow()->getDefaultStyle()->getFont(); @@ -105,7 +105,7 @@ public static function sizeRow(Worksheet $worksheet, $row = 1) * * @return int Horizontal measured in pixels */ - public static function getDistanceX(Worksheet $worksheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0) + public static function getDistanceX(Worksheet $worksheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0): int { $distanceX = 0; @@ -136,7 +136,7 @@ public static function getDistanceX(Worksheet $worksheet, $startColumn = 'A', $s * * @return int Vertical distance measured in pixels */ - public static function getDistanceY(Worksheet $worksheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0) + public static function getDistanceY(Worksheet $worksheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0): int { $distanceY = 0; @@ -203,10 +203,8 @@ public static function getDistanceY(Worksheet $worksheet, $startRow = 1, $startO * @param int $offsetY Vertical offset in pixels * @param int $width Width in pixels * @param int $height Height in pixels - * - * @return null|array */ - public static function oneAnchor2twoAnchor(Worksheet $worksheet, $coordinates, $offsetX, $offsetY, $width, $height) + public static function oneAnchor2twoAnchor(Worksheet $worksheet, string $coordinates, $offsetX, $offsetY, $width, $height): ?array { [$col_start, $row] = Coordinate::indexesFromString($coordinates); $row_start = $row - 1; diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 5c398ee6a6..389fe4070c 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -4,6 +4,8 @@ use JsonSerializable; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; +use PhpOffice\PhpSpreadsheet\Document\Properties; +use PhpOffice\PhpSpreadsheet\Document\Security; use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader; use PhpOffice\PhpSpreadsheet\Shared\File; use PhpOffice\PhpSpreadsheet\Shared\StringHelper; @@ -31,24 +33,18 @@ class Spreadsheet implements JsonSerializable /** * Unique ID. - * - * @var string */ - private $uniqueID; + private string $uniqueID; /** * Document properties. - * - * @var Document\Properties */ - private $properties; + private Properties $properties; /** * Document security. - * - * @var Document\Security */ - private $security; + private Security $security; /** * Collection of Worksheet objects. @@ -66,10 +62,8 @@ class Spreadsheet implements JsonSerializable /** * Active sheet index. - * - * @var int */ - private $activeSheetIndex = 0; + private int $activeSheetIndex; /** * Named ranges. @@ -80,10 +74,8 @@ class Spreadsheet implements JsonSerializable /** * CellXf supervisor. - * - * @var Style */ - private $cellXfSupervisor; + private Style $cellXfSupervisor; /** * CellXf collection. @@ -204,8 +196,7 @@ class Spreadsheet implements JsonSerializable */ private $tabRatio = 600; - /** @var Theme */ - private $theme; + private Theme $theme; public function getTheme(): Theme { @@ -268,7 +259,7 @@ public function setMacrosCertificate($certificate): void * * @return bool true|false */ - public function hasMacrosCertificate() + public function hasMacrosCertificate(): bool { return $this->macrosCertificate !== null; } @@ -379,10 +370,8 @@ public function setUnparsedLoadedData(array $unparsedLoadedData): void * return the extension of a filename. Internal use for a array_map callback (php<5.3 don't like lambda function). * * @param mixed $path - * - * @return string */ - private function getExtensionOnly($path) + private function getExtensionOnly($path): string { $extension = pathinfo($path, PATHINFO_EXTENSION); @@ -429,20 +418,16 @@ public function getRibbonBinObjects($what = 'all') /** * This workbook have a custom UI ? - * - * @return bool */ - public function hasRibbon() + public function hasRibbon(): bool { return $this->ribbonXMLData !== null; } /** * This workbook have additionnal object for the ribbon ? - * - * @return bool */ - public function hasRibbonBinObjects() + public function hasRibbonBinObjects(): bool { return $this->ribbonBinObjects !== null; } @@ -451,10 +436,8 @@ public function hasRibbonBinObjects() * Check if a sheet with a specified code name already exists. * * @param string $codeName Name of the worksheet to check - * - * @return bool */ - public function sheetCodeNameExists($codeName) + public function sheetCodeNameExists($codeName): bool { return $this->getSheetByCodeName($codeName) !== null; } @@ -594,10 +577,8 @@ public function getActiveSheet() * Create sheet and add it to this workbook. * * @param null|int $sheetIndex Index where sheet should go (0,1,..., or null for last) - * - * @return Worksheet */ - public function createSheet($sheetIndex = null) + public function createSheet($sheetIndex = null): Worksheet { $newSheet = new Worksheet($this); $this->addSheet($newSheet, $sheetIndex); @@ -609,10 +590,8 @@ public function createSheet($sheetIndex = null) * Check if a sheet with a specified name already exists. * * @param string $worksheetName Name of the worksheet to check - * - * @return bool */ - public function sheetNameExists($worksheetName) + public function sheetNameExists($worksheetName): bool { return $this->getSheetByName($worksheetName) !== null; } @@ -622,10 +601,8 @@ public function sheetNameExists($worksheetName) * * @param Worksheet $worksheet The worksheet to add * @param null|int $sheetIndex Index where sheet should go (0,1,..., or null for last) - * - * @return Worksheet */ - public function addSheet(Worksheet $worksheet, $sheetIndex = null) + public function addSheet(Worksheet $worksheet, $sheetIndex = null): Worksheet { if ($this->sheetNameExists($worksheet->getTitle())) { throw new Exception( @@ -770,7 +747,7 @@ public function getIndex(Worksheet $worksheet) * * @return int New sheet index */ - public function setIndexByName($worksheetName, $newIndexPosition) + public function setIndexByName(string $worksheetName, $newIndexPosition) { $oldIndex = $this->getIndex($this->getSheetByNameOrThrow($worksheetName)); $worksheet = array_splice( @@ -790,10 +767,8 @@ public function setIndexByName($worksheetName, $newIndexPosition) /** * Get sheet count. - * - * @return int */ - public function getSheetCount() + public function getSheetCount(): int { return count($this->workSheetCollection); } @@ -836,7 +811,7 @@ public function setActiveSheetIndex($worksheetIndex) * * @return Worksheet */ - public function setActiveSheetIndexByName($worksheetName) + public function setActiveSheetIndexByName(string $worksheetName) { if (($worksheet = $this->getSheetByName($worksheetName)) instanceof Worksheet) { $this->setActiveSheetIndex($this->getIndex($worksheet)); @@ -852,7 +827,7 @@ public function setActiveSheetIndexByName($worksheetName) * * @return string[] */ - public function getSheetNames() + public function getSheetNames(): array { $returnValue = []; $worksheetCount = $this->getSheetCount(); @@ -868,10 +843,8 @@ public function getSheetNames() * * @param Worksheet $worksheet External sheet to add * @param null|int $sheetIndex Index where sheet should go (0,1,..., or null for last) - * - * @return Worksheet */ - public function addExternalSheet(Worksheet $worksheet, $sheetIndex = null) + public function addExternalSheet(Worksheet $worksheet, $sheetIndex = null): Worksheet { if ($this->sheetNameExists($worksheet->getTitle())) { throw new Exception("Workbook already contains a worksheet named '{$worksheet->getTitle()}'. Rename the external sheet first."); @@ -919,7 +892,7 @@ public function getNamedRanges(): array { return array_filter( $this->definedNames, - function (DefinedName $definedName) { + function (DefinedName $definedName): bool { return $definedName->isFormula() === self::DEFINED_NAME_IS_RANGE; } ); @@ -934,7 +907,7 @@ public function getNamedFormulae(): array { return array_filter( $this->definedNames, - function (DefinedName $definedName) { + function (DefinedName $definedName): bool { return $definedName->isFormula() === self::DEFINED_NAME_IS_FORMULA; } ); @@ -1130,20 +1103,16 @@ public function removeDefinedName(string $definedName, ?Worksheet $worksheet = n /** * Get worksheet iterator. - * - * @return Iterator */ - public function getWorksheetIterator() + public function getWorksheetIterator(): Iterator { return new Iterator($this); } /** * Copy workbook (!= clone!). - * - * @return Spreadsheet */ - public function copy() + public function copy(): self { $filename = File::temporaryFilename(); $writer = new XlsxWriter($this); @@ -1207,10 +1176,8 @@ public function getCellXfByHashCode($hashcode) /** * Check if style exists in style collection. - * - * @return bool */ - public function cellXfExists(Style $cellStyleIndex) + public function cellXfExists(Style $cellStyleIndex): bool { return in_array($cellStyleIndex, $this->cellXfCollection, true); } diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 68edfaca40..07fd71ebdd 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -181,10 +181,8 @@ public function getSharedComponent() * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { return ['alignment' => $array]; } @@ -207,7 +205,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray) + public function applyFromArray(array $styleArray): static { if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells()) @@ -260,7 +258,7 @@ public function getHorizontal() * * @return $this */ - public function setHorizontal(string $horizontalAlignment) + public function setHorizontal(string $horizontalAlignment): static { $horizontalAlignment = strtolower($horizontalAlignment); if ($horizontalAlignment === self::HORIZONTAL_CENTER_CONTINUOUS_LC) { @@ -298,7 +296,7 @@ public function getVertical() * * @return $this */ - public function setVertical($verticalAlignment) + public function setVertical($verticalAlignment): static { $verticalAlignment = strtolower($verticalAlignment); @@ -333,7 +331,7 @@ public function getTextRotation() * * @return $this */ - public function setTextRotation($angleInDegrees) + public function setTextRotation($angleInDegrees): static { // Excel2007 value 255 => PhpSpreadsheet value -165 if ($angleInDegrees == self::TEXTROTATION_STACK_EXCEL) { @@ -376,7 +374,7 @@ public function getWrapText() * * @return $this */ - public function setWrapText($wrapped) + public function setWrapText($wrapped): static { if ($wrapped == '') { $wrapped = false; @@ -412,7 +410,7 @@ public function getShrinkToFit() * * @return $this */ - public function setShrinkToFit($shrink) + public function setShrinkToFit($shrink): static { if ($shrink == '') { $shrink = false; @@ -448,7 +446,7 @@ public function getIndent() * * @return $this */ - public function setIndent($indent) + public function setIndent($indent): static { if ($indent > 0) { if ( @@ -491,7 +489,7 @@ public function getReadOrder() * * @return $this */ - public function setReadOrder($readOrder) + public function setReadOrder($readOrder): static { if ($readOrder < 0 || $readOrder > 2) { $readOrder = 0; diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 568e1e006a..ae34e04447 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -32,10 +32,8 @@ class Border extends Supervisor /** * Border color. - * - * @var Color */ - protected $color; + protected Color $color; /** * @var null|int @@ -99,10 +97,8 @@ public function getSharedComponent() * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { /** @var Style */ $parent = $this->parent; @@ -128,7 +124,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray) + public function applyFromArray(array $styleArray): static { if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray)); @@ -167,7 +163,7 @@ public function getBorderStyle() * * @return $this */ - public function setBorderStyle($style) + public function setBorderStyle($style): static { if (empty($style)) { $style = self::BORDER_NONE; @@ -200,7 +196,7 @@ public function getColor() * * @return $this */ - public function setColor(Color $color) + public function setColor(Color $color): static { // make sure parameter is a real color and not a supervisor $color = $color->getIsSupervisor() ? $color->getSharedComponent() : $color; diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index a1247e859d..814511faf4 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -14,45 +14,33 @@ class Borders extends Supervisor /** * Left. - * - * @var Border */ - protected $left; + protected Border $left; /** * Right. - * - * @var Border */ - protected $right; + protected Border $right; /** * Top. - * - * @var Border */ - protected $top; + protected Border $top; /** * Bottom. - * - * @var Border */ - protected $bottom; + protected Border $bottom; /** * Diagonal. - * - * @var Border */ - protected $diagonal; + protected Border $diagonal; /** * DiagonalDirection. - * - * @var int */ - protected $diagonalDirection; + protected int $diagonalDirection; /** * All borders pseudo-border. Only applies to supervisor. @@ -150,10 +138,8 @@ public function getSharedComponent() * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { return ['borders' => $array]; } @@ -197,7 +183,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray) + public function applyFromArray(array $styleArray): static { if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray)); @@ -372,7 +358,7 @@ public function getDiagonalDirection() * * @return $this */ - public function setDiagonalDirection($direction) + public function setDiagonalDirection($direction): static { if ($direction == '') { $direction = self::DIAGONAL_NONE; diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index 282defc0ce..16dc238c9f 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -163,10 +163,8 @@ public function getSharedComponent() * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { /** @var Style */ $parent = $this->parent; @@ -185,7 +183,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray) + public function applyFromArray(array $styleArray): static { if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray)); @@ -239,7 +237,7 @@ public function getARGB(): ?string * * @return $this */ - public function setARGB(?string $colorValue = self::COLOR_BLACK) + public function setARGB(?string $colorValue = self::COLOR_BLACK): static { $this->hasChanged = true; $colorValue = $this->validateColor($colorValue); @@ -276,7 +274,7 @@ public function getRGB(): string * * @return $this */ - public function setRGB(?string $colorValue = self::COLOR_BLACK) + public function setRGB(?string $colorValue = self::COLOR_BLACK): static { return $this->setARGB($colorValue); } @@ -291,7 +289,7 @@ public function setRGB(?string $colorValue = self::COLOR_BLACK) * * @return int|string The extracted colour component */ - private static function getColourComponent($rgbValue, $offset, $hex = true) + private static function getColourComponent($rgbValue, $offset, $hex = true): string|int { $colour = substr($rgbValue, $offset, 2) ?: ''; if (preg_match('/^[0-9a-f]{2}$/i', $colour) !== 1) { @@ -351,7 +349,7 @@ public static function getBlue($rgbValue, $hex = true) * * @return string The adjusted colour as an RGBA or RGB value (e.g. FF00CCCC or CCDDEE) */ - public static function changeBrightness($hexColourValue, $adjustPercentage) + public static function changeBrightness($hexColourValue, $adjustPercentage): string { $rgba = (strlen($hexColourValue) === 8); $adjustPercentage = max(-1.0, min(1.0, $adjustPercentage)); diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index 36069b00c8..7785f5cae9 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -110,10 +110,8 @@ class Conditional implements IComparable /** * Style. - * - * @var Style */ - private $style; + private Style $style; /** @var bool */ private $noFormatSet = false; @@ -156,7 +154,7 @@ public function getConditionType() * * @return $this */ - public function setConditionType($type) + public function setConditionType($type): static { $this->conditionType = $type; @@ -180,7 +178,7 @@ public function getOperatorType() * * @return $this */ - public function setOperatorType($type) + public function setOperatorType($type): static { $this->operatorType = $type; @@ -204,7 +202,7 @@ public function getText() * * @return $this */ - public function setText($text) + public function setText($text): static { $this->text = $text; @@ -228,7 +226,7 @@ public function getStopIfTrue() * * @return $this */ - public function setStopIfTrue($stopIfTrue) + public function setStopIfTrue($stopIfTrue): static { $this->stopIfTrue = $stopIfTrue; @@ -252,7 +250,7 @@ public function getConditions() * * @return $this */ - public function setConditions($conditions) + public function setConditions($conditions): static { if (!is_array($conditions)) { $conditions = [$conditions]; @@ -269,7 +267,7 @@ public function setConditions($conditions) * * @return $this */ - public function addCondition($condition) + public function addCondition($condition): static { $this->condition[] = $condition; @@ -291,7 +289,7 @@ public function getStyle() * * @return $this */ - public function setStyle(Style $style) + public function setStyle(Style $style): static { $this->style = $style; @@ -313,7 +311,7 @@ public function getDataBar() * * @return $this */ - public function setDataBar(ConditionalDataBar $dataBar) + public function setDataBar(ConditionalDataBar $dataBar): static { $this->dataBar = $dataBar; @@ -325,7 +323,7 @@ public function setDataBar(ConditionalDataBar $dataBar) * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->conditionType . diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php index 7ead9a5ccb..06c19e0123 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php @@ -30,20 +30,14 @@ class CellMatcher Conditional::CONDITION_UNIQUE => "COUNTIF('%s'!%s,%s)=1", ]; - /** - * @var Cell - */ - protected $cell; + protected Cell $cell; /** * @var int */ protected $cellRow; - /** - * @var Worksheet - */ - protected $worksheet; + protected Worksheet $worksheet; /** * @var int @@ -70,10 +64,7 @@ class CellMatcher */ protected $referenceColumn; - /** - * @var Calculation - */ - protected $engine; + protected Calculation $engine; public function __construct(Cell $cell, string $conditionalRange) { @@ -147,11 +138,9 @@ public function evaluateConditional(Conditional $conditional): bool } /** - * @param mixed $value - * * @return float|int|string */ - protected function wrapValue($value) + protected function wrapValue(mixed $value) { if (!is_numeric($value)) { if (is_bool($value)) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php index 4c000db32a..30f5c97296 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php @@ -8,15 +8,9 @@ class CellStyleAssessor { - /** - * @var CellMatcher - */ - protected $cellMatcher; + protected CellMatcher $cellMatcher; - /** - * @var StyleMerger - */ - protected $styleMerger; + protected StyleMerger $styleMerger; public function __construct(Cell $cell, string $conditionalRange) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBar.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBar.php index c5c36aeb32..c07c753b8b 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBar.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBar.php @@ -9,21 +9,13 @@ class ConditionalDataBar /** @var null|bool */ private $showValue; - /** children */ + private ?ConditionalFormatValueObject $minimumConditionalFormatValueObject = null; - /** @var ?ConditionalFormatValueObject */ - private $minimumConditionalFormatValueObject; + private ?ConditionalFormatValueObject $maximumConditionalFormatValueObject = null; - /** @var ?ConditionalFormatValueObject */ - private $maximumConditionalFormatValueObject; + private string $color = ''; - /** @var string */ - private $color; - - /** */ - - /** @var ?ConditionalFormattingRuleExtension */ - private $conditionalFormattingRuleExt; + private ?ConditionalFormattingRuleExtension $conditionalFormattingRuleExt = null; /** * @return null|bool diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php index 0cdbc36851..e19e6d5555 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php @@ -9,21 +9,15 @@ class ConditionalFormattingRuleExtension { const CONDITION_EXTENSION_DATABAR = 'dataBar'; - /** attributes */ - - /** @var string */ - private $id; + private string $id; /** @var string Conditional Formatting Rule */ - private $cfRule; - - /** children */ + private string $cfRule; - /** @var ConditionalDataBarExtension */ - private $dataBar; + private ConditionalDataBarExtension $dataBar; /** @var string Sequence of References */ - private $sqref; + private string $sqref = ''; /** * ConditionalFormattingRuleExtension constructor. @@ -124,8 +118,7 @@ private static function parseExtDataBarAttributesFromXml( } } - /** @param array|SimpleXMLElement $ns */ - private static function parseExtDataBarElementChildrenFromXml(ConditionalDataBarExtension $extDataBarObj, SimpleXMLElement $dataBarXml, $ns): void + private static function parseExtDataBarElementChildrenFromXml(ConditionalDataBarExtension $extDataBarObj, SimpleXMLElement $dataBarXml, array $ns): void { if ($dataBarXml->borderColor) { $attributes = $dataBarXml->borderColor->attributes(); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/StyleMerger.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/StyleMerger.php index 0ddc07f2a7..9388848e74 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/StyleMerger.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/StyleMerger.php @@ -10,10 +10,7 @@ class StyleMerger { - /** - * @var Style - */ - protected $baseStyle; + protected Style $baseStyle; public function __construct(Style $baseStyle) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php index d5d56a9a3d..69b524a636 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php @@ -24,10 +24,7 @@ class Wizard public const VALUE_TYPE_CELL = 'cell'; public const VALUE_TYPE_FORMULA = 'formula'; - /** - * @var string - */ - protected $cellRange; + protected string $cellRange; public function __construct(string $cellRange) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php index 14f30d39e1..aa2da2f1e2 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php @@ -26,10 +26,7 @@ class Blanks extends WizardAbstract implements WizardInterface Wizard::BLANKS => 'LEN(TRIM(%s))=0', ]; - /** - * @var bool - */ - protected $inverse; + protected bool $inverse; public function __construct(string $cellRange, bool $inverse = false) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php index 265b2419b9..d99e83551e 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php @@ -165,7 +165,7 @@ public static function fromConditional(Conditional $conditional, string $cellRan * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, $arguments): self + public function __call($methodName, array $arguments): self { if (!isset(self::MAGIC_OPERATIONS[$methodName]) && $methodName !== 'and') { throw new Exception('Invalid Operator for Cell Value CF Rule Wizard'); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php index 3f063fefd5..56ddd1eeb4 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php @@ -16,10 +16,7 @@ class Duplicates extends WizardAbstract implements WizardInterface 'unique' => true, ]; - /** - * @var bool - */ - protected $inverse; + protected bool $inverse; public function __construct(string $cellRange, bool $inverse = false) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php index 56b9086c8d..e5fb329d67 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php @@ -22,10 +22,7 @@ class Errors extends WizardAbstract implements WizardInterface Wizard::ERRORS => 'ISERROR(%s)', ]; - /** - * @var bool - */ - protected $inverse; + protected bool $inverse; public function __construct(string $cellRange, bool $inverse = false) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php index e6d29f7be9..5064df6a26 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php @@ -60,7 +60,7 @@ public static function fromConditional(Conditional $conditional, string $cellRan * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, $arguments): self + public function __call($methodName, array $arguments): self { if ($methodName !== 'formula') { throw new Exception('Invalid Operation for Expression CF Rule Wizard'); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php index 987cfbf8b9..91b8a0d1eb 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php @@ -145,7 +145,7 @@ public static function fromConditional(Conditional $conditional, string $cellRan * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, $arguments): self + public function __call($methodName, array $arguments): self { if (!isset(self::MAGIC_OPERATIONS[$methodName])) { throw new Exception('Invalid Operation for Text Value CF Rule Wizard'); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php index 5644aab456..e747cef4c9 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php @@ -19,10 +19,7 @@ abstract class WizardAbstract */ protected $expression; - /** - * @var string - */ - protected $cellRange; + protected string $cellRange; /** * @var string @@ -136,7 +133,7 @@ public static function reverseAdjustCellRef(string $condition, string $cellRange if ($i) { $value = (string) preg_replace_callback( '/' . Calculation::CALCULATION_REGEXP_CELLREF_RELATIVE . '/i', - function ($matches) use ($referenceColumnIndex, $referenceRow) { + function ($matches) use ($referenceColumnIndex, $referenceRow): string { return self::reverseCellAdjustment($matches, $referenceColumnIndex, $referenceRow); }, $value diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index 28af444a48..1d1c3df470 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -53,17 +53,13 @@ class Fill extends Supervisor /** * Start color. - * - * @var Color */ - protected $startColor; + protected Color $startColor; /** * End color. - * - * @var Color */ - protected $endColor; + protected Color $endColor; /** @var bool */ private $colorChanged = false; @@ -115,10 +111,8 @@ public function getSharedComponent() * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { return ['fill' => $array]; } @@ -145,7 +139,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray) + public function applyFromArray(array $styleArray): static { if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray)); @@ -192,7 +186,7 @@ public function getFillType() * * @return $this */ - public function setFillType($fillType) + public function setFillType($fillType): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['fillType' => $fillType]); @@ -225,7 +219,7 @@ public function getRotation() * * @return $this */ - public function setRotation($angleInDegrees) + public function setRotation($angleInDegrees): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['rotation' => $angleInDegrees]); @@ -252,7 +246,7 @@ public function getStartColor() * * @return $this */ - public function setStartColor(Color $color) + public function setStartColor(Color $color): static { $this->colorChanged = true; // make sure parameter is a real color and not a supervisor @@ -283,7 +277,7 @@ public function getEndColor() * * @return $this */ - public function setEndColor(Color $color) + public function setEndColor(Color $color): static { $this->colorChanged = true; // make sure parameter is a real color and not a supervisor diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index a8eeaa9861..45de032b27 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -97,10 +97,8 @@ class Font extends Supervisor /** * Foreground color. - * - * @var Color */ - protected $color; + protected Color $color; /** * @var null|int @@ -163,10 +161,8 @@ public function getSharedComponent() * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { return ['font' => $array]; } @@ -193,7 +189,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray) + public function applyFromArray(array $styleArray): static { if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray)); @@ -381,7 +377,7 @@ public function getSize() * * @return $this */ - public function setSize($sizeInPoints, bool $nullOk = false) + public function setSize($sizeInPoints, bool $nullOk = false): static { if (is_string($sizeInPoints) || is_int($sizeInPoints)) { $sizeInPoints = (float) $sizeInPoints; // $pValue = 0 if given string is not numeric @@ -426,7 +422,7 @@ public function getBold() * * @return $this */ - public function setBold($bold) + public function setBold($bold): static { if ($bold == '') { $bold = false; @@ -462,7 +458,7 @@ public function getItalic() * * @return $this */ - public function setItalic($italic) + public function setItalic($italic): static { if ($italic == '') { $italic = false; @@ -496,7 +492,7 @@ public function getSuperscript() * * @return $this */ - public function setSuperscript(bool $superscript) + public function setSuperscript(bool $superscript): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['superscript' => $superscript]); @@ -530,7 +526,7 @@ public function getSubscript() * * @return $this */ - public function setSubscript(bool $subscript) + public function setSubscript(bool $subscript): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['subscript' => $subscript]); @@ -671,7 +667,7 @@ public function getUnderline() * * @return $this */ - public function setUnderline($underlineStyle) + public function setUnderline($underlineStyle): static { if (is_bool($underlineStyle)) { $underlineStyle = ($underlineStyle) ? self::UNDERLINE_SINGLE : self::UNDERLINE_NONE; @@ -709,7 +705,7 @@ public function getStrikethrough() * * @return $this */ - public function setStrikethrough($strikethru) + public function setStrikethrough($strikethru): static { if ($strikethru == '') { $strikethru = false; @@ -740,7 +736,7 @@ public function getColor() * * @return $this */ - public function setColor(Color $color) + public function setColor(Color $color): static { // make sure parameter is a real color and not a supervisor $color = $color->getIsSupervisor() ? $color->getSharedComponent() : $color; diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index b605cff6e9..84634fbe62 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -157,10 +157,8 @@ public function getSharedComponent() * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { return ['numberFormat' => $array]; } @@ -180,7 +178,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray) + public function applyFromArray(array $styleArray): static { if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray)); @@ -217,7 +215,7 @@ public function getFormatCode() * * @return $this */ - public function setFormatCode(string $formatCode) + public function setFormatCode(string $formatCode): static { if ($formatCode == '') { $formatCode = self::FORMAT_GENERAL; @@ -255,7 +253,7 @@ public function getBuiltInFormatCode() * * @return $this */ - public function setBuiltInFormatCode(int $formatCodeIndex) + public function setBuiltInFormatCode(int $formatCodeIndex): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['formatCode' => self::builtInFormatCode($formatCodeIndex)]); diff --git a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php index 41a17151d3..06c131e68e 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php @@ -157,7 +157,7 @@ public static function toFormattedString($value, $format, $callBack = null) $format = (string) preg_replace_callback( '/(["])(?:(?=(\\\\?))\\2.)*?\\1/u', - function ($matches) { + function (array $matches): string { return str_replace('.', chr(0x00), $matches[0]); }, $format diff --git a/src/PhpSpreadsheet/Style/Protection.php b/src/PhpSpreadsheet/Style/Protection.php index 1c174e7266..dff5f359c3 100644 --- a/src/PhpSpreadsheet/Style/Protection.php +++ b/src/PhpSpreadsheet/Style/Protection.php @@ -11,17 +11,13 @@ class Protection extends Supervisor /** * Locked. - * - * @var string */ - protected $locked; + protected ?string $locked = null; /** * Hidden. - * - * @var string */ - protected $hidden; + protected ?string $hidden = null; /** * Create a new Protection. @@ -63,10 +59,8 @@ public function getSharedComponent() * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { return ['protection' => $array]; } @@ -87,7 +81,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray) + public function applyFromArray(array $styleArray): static { if ($this->isSupervisor) { $this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray)); @@ -105,10 +99,8 @@ public function applyFromArray(array $styleArray) /** * Get locked. - * - * @return string */ - public function getLocked() + public function getLocked(): ?string { if ($this->isSupervisor) { return $this->getSharedComponent()->getLocked(); @@ -124,7 +116,7 @@ public function getLocked() * * @return $this */ - public function setLocked($lockType) + public function setLocked($lockType): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['locked' => $lockType]); @@ -138,10 +130,8 @@ public function setLocked($lockType) /** * Get hidden. - * - * @return string */ - public function getHidden() + public function getHidden(): ?string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHidden(); @@ -157,7 +147,7 @@ public function getHidden() * * @return $this */ - public function setHidden($hiddenType) + public function setHidden($hiddenType): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['hidden' => $hiddenType]); diff --git a/src/PhpSpreadsheet/Style/RgbTint.php b/src/PhpSpreadsheet/Style/RgbTint.php index 582ae48397..9c0ce7f129 100644 --- a/src/PhpSpreadsheet/Style/RgbTint.php +++ b/src/PhpSpreadsheet/Style/RgbTint.php @@ -72,7 +72,7 @@ private static function rgbToHls(float $red, float $green, float $blue): array * * @return float[] */ - private static function hlsToRgb($hue, $luminance, $saturation): array + private static function hlsToRgb(float $hue, $luminance, $saturation): array { if ($saturation === self::$scrutinizerZeroPointZero) { return [$luminance, $luminance, $luminance]; diff --git a/src/PhpSpreadsheet/Style/Style.php b/src/PhpSpreadsheet/Style/Style.php index 9309830bfa..6a288b4e60 100644 --- a/src/PhpSpreadsheet/Style/Style.php +++ b/src/PhpSpreadsheet/Style/Style.php @@ -12,45 +12,33 @@ class Style extends Supervisor { /** * Font. - * - * @var Font */ - protected $font; + protected Font $font; /** * Fill. - * - * @var Fill */ - protected $fill; + protected Fill $fill; /** * Borders. - * - * @var Borders */ - protected $borders; + protected Borders $borders; /** * Alignment. - * - * @var Alignment */ - protected $alignment; + protected Alignment $alignment; /** * Number Format. - * - * @var NumberFormat */ - protected $numberFormat; + protected NumberFormat $numberFormat; /** * Protection. - * - * @var Protection */ - protected $protection; + protected Protection $protection; /** * Index of style in collection. Only used for real style. @@ -148,10 +136,8 @@ public function getParent(): Spreadsheet * Build style array from subcomponents. * * @param array $array - * - * @return array */ - public function getStyleArray($array) + public function getStyleArray($array): array { return ['quotePrefix' => $array]; } @@ -201,7 +187,7 @@ public function getStyleArray($array) * * @return $this */ - public function applyFromArray(array $styleArray, $advancedBorders = true) + public function applyFromArray(array $styleArray, $advancedBorders = true): static { if ($this->isSupervisor) { $pRange = $this->getSelectedCells(); @@ -583,7 +569,7 @@ public function getFont() * * @return $this */ - public function setFont(Font $font) + public function setFont(Font $font): static { $this->font = $font; @@ -625,7 +611,7 @@ public function getNumberFormat() * * @return Conditional[] */ - public function getConditionalStyles() + public function getConditionalStyles(): array { return $this->getActiveSheet()->getConditionalStyles($this->getActiveCell()); } @@ -637,7 +623,7 @@ public function getConditionalStyles() * * @return $this */ - public function setConditionalStyles(array $conditionalStyleArray) + public function setConditionalStyles(array $conditionalStyleArray): static { $this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $conditionalStyleArray); @@ -675,7 +661,7 @@ public function getQuotePrefix() * * @return $this */ - public function setQuotePrefix($quotePrefix) + public function setQuotePrefix($quotePrefix): static { if ($quotePrefix == '') { $quotePrefix = false; @@ -695,7 +681,7 @@ public function setQuotePrefix($quotePrefix) * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->fill->getHashCode() . diff --git a/src/PhpSpreadsheet/Theme.php b/src/PhpSpreadsheet/Theme.php index ab101f01ee..ac4dbe560c 100644 --- a/src/PhpSpreadsheet/Theme.php +++ b/src/PhpSpreadsheet/Theme.php @@ -4,11 +4,9 @@ class Theme { - /** @var string */ - private $themeColorName = 'Office'; + private string $themeColorName = 'Office'; - /** @var string */ - private $themeFontName = 'Office'; + private string $themeFontName = 'Office'; public const COLOR_SCHEME_2013_PLUS_NAME = 'Office 2013+'; public const COLOR_SCHEME_2013_PLUS = [ @@ -45,23 +43,17 @@ class Theme /** @var string[] */ private $themeColors = self::COLOR_SCHEME_2007_2010; - /** @var string */ - private $majorFontLatin = 'Cambria'; + private string $majorFontLatin = 'Cambria'; - /** @var string */ - private $majorFontEastAsian = ''; + private string $majorFontEastAsian = ''; - /** @var string */ - private $majorFontComplexScript = ''; + private string $majorFontComplexScript = ''; - /** @var string */ - private $minorFontLatin = 'Calibri'; + private string $minorFontLatin = 'Calibri'; - /** @var string */ - private $minorFontEastAsian = ''; + private string $minorFontEastAsian = ''; - /** @var string */ - private $minorFontComplexScript = ''; + private string $minorFontComplexScript = ''; /** * Map of Major (header) fonts to write. diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index 62347a2abf..2bdb288c11 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -17,17 +17,13 @@ class AutoFilter { /** * Autofilter Worksheet. - * - * @var null|Worksheet */ - private $workSheet; + private ?Worksheet $workSheet; /** * Autofilter Range. - * - * @var string */ - private $range = ''; + private string $range; /** * Autofilter Column Ruleset. @@ -63,7 +59,7 @@ public function __construct($range = '', ?Worksheet $worksheet = null) [, $range] = Worksheet::extractSheetTitle(Validations::validateCellRange($range), true); } - $this->range = $range; + $this->range = $range ?? ''; $this->workSheet = $worksheet; } @@ -82,7 +78,7 @@ public function getParent() * * @return $this */ - public function setParent(?Worksheet $worksheet = null) + public function setParent(?Worksheet $worksheet = null): static { $this->evaluated = false; $this->workSheet = $worksheet; @@ -172,7 +168,7 @@ public function getColumns() * * @return int The column offset within the autofilter range */ - public function testColumnInRange($column) + public function testColumnInRange($column): int { if (empty($this->range)) { throw new Exception('No autofilter range is defined.'); @@ -240,7 +236,7 @@ public function getColumnByOffset($columnOffset) * * @return $this */ - public function setColumn($columnObjectOrString) + public function setColumn($columnObjectOrString): static { $this->evaluated = false; if ((is_string($columnObjectOrString)) && (!empty($columnObjectOrString))) { @@ -270,7 +266,7 @@ public function setColumn($columnObjectOrString) * * @return $this */ - public function clearColumn($column) + public function clearColumn($column): static { $this->evaluated = false; $this->testColumnInRange($column); @@ -294,7 +290,7 @@ public function clearColumn($column) * * @return $this */ - public function shiftColumn($fromColumn, $toColumn) + public function shiftColumn($fromColumn, $toColumn): static { $this->evaluated = false; $fromColumn = strtoupper($fromColumn); @@ -321,7 +317,7 @@ public function shiftColumn($fromColumn, $toColumn) * * @return bool */ - protected static function filterTestInSimpleDataSet($cellValue, $dataSet) + protected static function filterTestInSimpleDataSet($cellValue, array $dataSet) { $dataSetValues = $dataSet['filterValues']; $blanks = $dataSet['blanks']; @@ -340,7 +336,7 @@ protected static function filterTestInSimpleDataSet($cellValue, $dataSet) * * @return bool */ - protected static function filterTestInDateGroupSet($cellValue, $dataSet) + protected static function filterTestInDateGroupSet($cellValue, array $dataSet) { $dateSet = $dataSet['filterValues']; $blanks = $dataSet['blanks']; @@ -381,10 +377,8 @@ protected static function filterTestInDateGroupSet($cellValue, $dataSet) * * @param mixed $cellValue * @param mixed[] $ruleSet - * - * @return bool */ - protected static function filterTestInCustomDataSet($cellValue, $ruleSet) + protected static function filterTestInCustomDataSet($cellValue, $ruleSet): bool { /** @var array[] */ $dataSet = $ruleSet['filterRules']; @@ -506,10 +500,8 @@ protected static function filterTestInCustomDataSet($cellValue, $ruleSet) * * @param mixed $cellValue * @param mixed[] $monthSet - * - * @return bool */ - protected static function filterTestInPeriodDateSet($cellValue, $monthSet) + protected static function filterTestInPeriodDateSet($cellValue, $monthSet): bool { // Blank cells are always ignored, so return a FALSE if (($cellValue == '') || ($cellValue === null)) { @@ -752,7 +744,7 @@ private static function dynamicYesterday(): array * * @return mixed[] */ - private function dynamicFilterDateRange($dynamicRuleType, AutoFilter\Column &$filterColumn) + private function dynamicFilterDateRange($dynamicRuleType, AutoFilter\Column &$filterColumn): array { $ruleValues = []; $callBack = [__CLASS__, self::DATE_FUNCTIONS[$dynamicRuleType]]; // What if not found? @@ -779,15 +771,12 @@ private function dynamicFilterDateRange($dynamicRuleType, AutoFilter\Column &$fi /** * Apply the AutoFilter rules to the AutoFilter Range. * - * @param string $columnID - * @param int $startRow - * @param int $endRow * @param ?string $ruleType * @param mixed $ruleValue * * @return mixed */ - private function calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, $ruleValue) + private function calculateTopTenValue(string $columnID, int $startRow, int $endRow, $ruleType, $ruleValue) { $range = $columnID . $startRow . ':' . $columnID . $endRow; $retVal = null; @@ -814,7 +803,7 @@ private function calculateTopTenValue($columnID, $startRow, $endRow, $ruleType, * * @return $this */ - public function showHideRows() + public function showHideRows(): static { if ($this->workSheet === null) { return $this; @@ -947,8 +936,7 @@ public function showHideRows() // Number (Average) based // Calculate the average $averageFormula = '=AVERAGE(' . $columnID . ($rangeStart[1] + 1) . ':' . $columnID . $rangeEnd[1] . ')'; - $spreadsheet = ($this->workSheet === null) ? null : $this->workSheet->getParent(); - $average = Calculation::getInstance($spreadsheet)->calculateFormula($averageFormula, null, $this->workSheet->getCell('A1')); + $average = Calculation::getInstance($this->workSheet->getParent())->calculateFormula($averageFormula, null, $this->workSheet->getCell('A1')); while (is_array($average)) { $average = array_pop($average); } @@ -1115,7 +1103,7 @@ public function __clone() * toString method replicates previous behavior by returning the range if object is * referenced as a property of its parent. */ - public function __toString() + public function __toString(): string { return (string) $this->range; } diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index 076292f37a..361ccf045b 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -48,10 +48,8 @@ class Column /** * Autofilter. - * - * @var null|AutoFilter */ - private $parent; + private ?AutoFilter $parent; /** * Autofilter Column Index. @@ -124,7 +122,7 @@ public function getColumnIndex() * * @return $this */ - public function setColumnIndex($column) + public function setColumnIndex($column): static { $this->setEvaluatedFalse(); // Uppercase coordinate @@ -153,7 +151,7 @@ public function getParent() * * @return $this */ - public function setParent(?AutoFilter $parent = null) + public function setParent(?AutoFilter $parent = null): static { $this->setEvaluatedFalse(); $this->parent = $parent; @@ -178,7 +176,7 @@ public function getFilterType() * * @return $this */ - public function setFilterType($filterType) + public function setFilterType($filterType): static { $this->setEvaluatedFalse(); if (!in_array($filterType, self::$filterTypes)) { @@ -210,7 +208,7 @@ public function getJoin() * * @return $this */ - public function setJoin($join) + public function setJoin($join): static { $this->setEvaluatedFalse(); // Lowercase And/Or @@ -231,7 +229,7 @@ public function setJoin($join) * * @return $this */ - public function setAttributes($attributes) + public function setAttributes($attributes): static { $this->setEvaluatedFalse(); $this->attributes = $attributes; @@ -247,7 +245,7 @@ public function setAttributes($attributes) * * @return $this */ - public function setAttribute($name, $value) + public function setAttribute($name, $value): static { $this->setEvaluatedFalse(); $this->attributes[$name] = $value; @@ -314,10 +312,8 @@ public function getRule($index) /** * Create a new AutoFilter Column Rule in the ruleset. - * - * @return Column\Rule */ - public function createRule() + public function createRule(): Column\Rule { $this->setEvaluatedFalse(); if ($this->filterType === self::AUTOFILTER_FILTERTYPE_CUSTOMFILTER && count($this->ruleset) >= 2) { @@ -333,7 +329,7 @@ public function createRule() * * @return $this */ - public function addRule(Column\Rule $rule) + public function addRule(Column\Rule $rule): static { $this->setEvaluatedFalse(); $rule->setParent($this); @@ -350,7 +346,7 @@ public function addRule(Column\Rule $rule) * * @return $this */ - public function deleteRule($index) + public function deleteRule($index): static { $this->setEvaluatedFalse(); if (isset($this->ruleset[$index])) { @@ -369,7 +365,7 @@ public function deleteRule($index) * * @return $this */ - public function clearRules() + public function clearRules(): static { $this->setEvaluatedFalse(); $this->ruleset = []; diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index 408dfb3f06..aed9561106 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -169,13 +169,10 @@ class Rule // Rule Operators (Date Special) which are translated to standard numeric operators with calculated values // const AUTOFILTER_COLUMN_RULE_BEFORE = 'lessThan'; // const AUTOFILTER_COLUMN_RULE_AFTER = 'greaterThan'; - /** * Autofilter Column. - * - * @var ?Column */ - private $parent; + private ?Column $parent; /** * Autofilter Rule Type. @@ -237,7 +234,7 @@ public function getRuleType() * * @return $this */ - public function setRuleType($ruleType) + public function setRuleType($ruleType): static { $this->setEvaluatedFalse(); if (!in_array($ruleType, self::RULE_TYPES)) { @@ -266,7 +263,7 @@ public function getValue() * * @return $this */ - public function setValue($value) + public function setValue($value): static { $this->setEvaluatedFalse(); if (is_array($value)) { @@ -309,7 +306,7 @@ public function getOperator() * * @return $this */ - public function setOperator($operator) + public function setOperator($operator): static { $this->setEvaluatedFalse(); if (empty($operator)) { @@ -343,7 +340,7 @@ public function getGrouping() * * @return $this */ - public function setGrouping($grouping) + public function setGrouping($grouping): static { $this->setEvaluatedFalse(); if ( @@ -368,7 +365,7 @@ public function setGrouping($grouping) * * @return $this */ - public function setRule($operator, $value, $grouping = null) + public function setRule($operator, $value, $grouping = null): static { $this->setEvaluatedFalse(); $this->setOperator($operator); @@ -398,7 +395,7 @@ public function getParent() * * @return $this */ - public function setParent(?Column $parent = null) + public function setParent(?Column $parent = null): static { $this->setEvaluatedFalse(); $this->parent = $parent; diff --git a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php index 0226e6852b..1d3635ddbc 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -5,6 +5,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Hyperlink; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; use PhpOffice\PhpSpreadsheet\IComparable; +use PhpOffice\PhpSpreadsheet\Worksheet\Drawing\Shadow; use SimpleXMLElement; class BaseDrawing implements IComparable @@ -20,10 +21,8 @@ class BaseDrawing implements IComparable /** * The editAs attribute, used only with two cell anchor. - * - * @var string */ - protected $editAs = ''; + protected string $editAs = ''; /** * Image counter. @@ -34,38 +33,28 @@ class BaseDrawing implements IComparable /** * Image index. - * - * @var int */ - private $imageIndex = 0; + private int $imageIndex; /** * Name. - * - * @var string */ - protected $name = ''; + protected string $name = ''; /** * Description. - * - * @var string */ - protected $description = ''; + protected string $description = ''; /** * Worksheet. - * - * @var null|Worksheet */ - protected $worksheet; + protected ?Worksheet $worksheet = null; /** * Coordinates. - * - * @var string */ - protected $coordinates = 'A1'; + protected string $coordinates = 'A1'; /** * Offset X. @@ -83,10 +72,8 @@ class BaseDrawing implements IComparable /** * Coordinates2. - * - * @var string */ - protected $coordinates2 = ''; + protected string $coordinates2 = ''; /** * Offset X2. @@ -146,17 +133,13 @@ class BaseDrawing implements IComparable /** * Shadow. - * - * @var Drawing\Shadow */ - protected $shadow; + protected Shadow $shadow; /** * Image hyperlink. - * - * @var null|Hyperlink */ - private $hyperlink; + private ?Hyperlink $hyperlink = null; /** * Image type. @@ -435,7 +418,7 @@ public function setShadow(?Drawing\Shadow $shadow = null): self * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->name . diff --git a/src/PhpSpreadsheet/Worksheet/Column.php b/src/PhpSpreadsheet/Worksheet/Column.php index 077ba5da94..d2bbffb3ac 100644 --- a/src/PhpSpreadsheet/Worksheet/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Column.php @@ -4,19 +4,12 @@ class Column { - /** - * \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet. - * - * @var Worksheet - */ - private $worksheet; + private ?Worksheet $worksheet; /** * Column index. - * - * @var string */ - private $columnIndex; + private string $columnIndex; /** * Create a new column. @@ -35,7 +28,6 @@ public function __construct(Worksheet $worksheet, $columnIndex = 'A') */ public function __destruct() { - // @phpstan-ignore-next-line $this->worksheet = null; } @@ -55,7 +47,7 @@ public function getColumnIndex(): string */ public function getCellIterator($startRow = 1, $endRow = null): ColumnCellIterator { - return new ColumnCellIterator($this->worksheet, $this->columnIndex, $startRow, $endRow); + return new ColumnCellIterator($this->getWorksheet(), $this->columnIndex, $startRow, $endRow); } /** @@ -116,6 +108,7 @@ public function isEmpty(int $definitionOfEmptyFlags = 0, $startRow = 1, $endRow */ public function getWorksheet(): Worksheet { + // @phpstan-ignore-next-line return $this->worksheet; } } diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index ed88d4ecaf..ba9312b499 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -13,17 +13,13 @@ class ColumnCellIterator extends CellIterator { /** * Current iterator position. - * - * @var int */ - private $currentRow; + private int $currentRow; /** * Column index. - * - * @var int */ - private $columnIndex; + private int $columnIndex; /** * Start position. @@ -47,7 +43,7 @@ class ColumnCellIterator extends CellIterator * @param int $startRow The row number at which to start iterating * @param int $endRow Optionally, the row number at which to stop iterating */ - public function __construct(Worksheet $worksheet, $columnIndex = 'A', $startRow = 1, $endRow = null) + public function __construct(Worksheet $worksheet, $columnIndex = 'A', int $startRow = 1, $endRow = null) { // Set subject $this->worksheet = $worksheet; @@ -64,7 +60,7 @@ public function __construct(Worksheet $worksheet, $columnIndex = 'A', $startRow * * @return $this */ - public function resetStart(int $startRow = 1) + public function resetStart(int $startRow = 1): static { $this->startRow = $startRow; $this->adjustForExistingOnlyRange(); @@ -80,7 +76,7 @@ public function resetStart(int $startRow = 1) * * @return $this */ - public function resetEnd($endRow = null) + public function resetEnd($endRow = null): static { $this->endRow = $endRow ?: $this->worksheet->getHighestRow(); $this->adjustForExistingOnlyRange(); @@ -95,7 +91,7 @@ public function resetEnd($endRow = null) * * @return $this */ - public function seek(int $row = 1) + public function seek(int $row = 1): static { if ( $this->onlyExistingCells && diff --git a/src/PhpSpreadsheet/Worksheet/ColumnDimension.php b/src/PhpSpreadsheet/Worksheet/ColumnDimension.php index 9393648283..07f7413426 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnDimension.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnDimension.php @@ -9,10 +9,8 @@ class ColumnDimension extends Dimension { /** * Column index. - * - * @var ?string */ - private $columnIndex; + private ?string $columnIndex; /** * Column width. @@ -106,7 +104,7 @@ public function getWidth(?string $unitOfMeasure = null): float * * @return $this */ - public function setWidth(float $width, ?string $unitOfMeasure = null) + public function setWidth(float $width, ?string $unitOfMeasure = null): static { $this->width = ($unitOfMeasure === null || $width < 0) ? $width @@ -128,7 +126,7 @@ public function getAutoSize(): bool * * @return $this */ - public function setAutoSize(bool $autosizeEnabled) + public function setAutoSize(bool $autosizeEnabled): static { $this->autoSize = $autosizeEnabled; diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index fffef12928..4910393c3f 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -47,7 +47,7 @@ class ColumnIterator implements NativeIterator * @param string $startColumn The column address at which to start iterating * @param string $endColumn Optionally, the column address at which to stop iterating */ - public function __construct(Worksheet $worksheet, $startColumn = 'A', $endColumn = null) + public function __construct(Worksheet $worksheet, string $startColumn = 'A', $endColumn = null) { // Set subject $this->worksheet = $worksheet; @@ -71,7 +71,7 @@ public function __destruct() * * @return $this */ - public function resetStart(string $startColumn = 'A') + public function resetStart(string $startColumn = 'A'): static { $startColumnIndex = Coordinate::columnIndexFromString($startColumn); if ($startColumnIndex > Coordinate::columnIndexFromString($this->worksheet->getHighestColumn())) { @@ -96,7 +96,7 @@ public function resetStart(string $startColumn = 'A') * * @return $this */ - public function resetEnd($endColumn = null) + public function resetEnd($endColumn = null): static { $endColumn = $endColumn ?: $this->worksheet->getHighestColumn(); $this->endColumnIndex = Coordinate::columnIndexFromString($endColumn); @@ -111,7 +111,7 @@ public function resetEnd($endColumn = null) * * @return $this */ - public function seek(string $column = 'A') + public function seek(string $column = 'A'): static { $column = Coordinate::columnIndexFromString($column); if (($column < $this->startColumnIndex) || ($column > $this->endColumnIndex)) { diff --git a/src/PhpSpreadsheet/Worksheet/Dimension.php b/src/PhpSpreadsheet/Worksheet/Dimension.php index 7f144063b7..8549b16954 100644 --- a/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -29,10 +29,8 @@ abstract class Dimension /** * Index to cellXf. Null value means row has no explicit cellXf format. - * - * @var null|int */ - private $xfIndex; + private ?int $xfIndex; /** * Create a new Dimension. diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index 7d957539ef..e9c2e80431 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -16,17 +16,13 @@ class Drawing extends BaseDrawing /** * Path. - * - * @var string */ - private $path; + private string $path; /** * Whether or not we are dealing with a URL. - * - * @var bool */ - private $isUrl; + private bool $isUrl; /** * Create a new Drawing. @@ -43,10 +39,8 @@ public function __construct() /** * Get Filename. - * - * @return string */ - public function getFilename() + public function getFilename(): string { return basename($this->path); } @@ -61,10 +55,8 @@ public function getIndexedFilename(): string /** * Get Extension. - * - * @return string */ - public function getExtension() + public function getExtension(): string { $exploded = explode('.', basename($this->path)); @@ -73,10 +65,8 @@ public function getExtension() /** * Get full filepath to store drawing in zip archive. - * - * @return string */ - public function getMediaFilename() + public function getMediaFilename(): string { if (!array_key_exists($this->type, self::IMAGE_TYPES_CONVERTION_MAP)) { throw new PhpSpreadsheetException('Unsupported image type in comment background. Supported types: PNG, JPEG, BMP, GIF.'); @@ -104,7 +94,7 @@ public function getPath() * * @return $this */ - public function setPath($path, $verifyFile = true, $zip = null) + public function setPath($path, $verifyFile = true, $zip = null): static { if ($verifyFile && preg_match('~^data:image/[a-z]+;base64,~', $path) !== 1) { // Check if a URL has been passed. https://stackoverflow.com/a/2058596/1252979 @@ -165,7 +155,7 @@ public function setIsURL(bool $isUrl): self * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->path . diff --git a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php index ca396d221d..5e16a9754d 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php @@ -19,56 +19,42 @@ class Shadow implements IComparable /** * Visible. - * - * @var bool */ - private $visible; + private bool $visible; /** * Blur radius. * * Defaults to 6 - * - * @var int */ - private $blurRadius; + private int $blurRadius; /** * Shadow distance. * * Defaults to 2 - * - * @var int */ - private $distance; + private int $distance; /** * Shadow direction (in degrees). - * - * @var int */ - private $direction; + private int $direction; /** * Shadow alignment. - * - * @var string */ - private $alignment; + private string $alignment; /** * Color. - * - * @var Color */ - private $color; + private Color $color; /** * Alpha. - * - * @var int */ - private $alpha; + private int $alpha; /** * Create a new Shadow. @@ -102,7 +88,7 @@ public function getVisible() * * @return $this */ - public function setVisible($visible) + public function setVisible($visible): static { $this->visible = $visible; @@ -126,7 +112,7 @@ public function getBlurRadius() * * @return $this */ - public function setBlurRadius($blurRadius) + public function setBlurRadius($blurRadius): static { $this->blurRadius = $blurRadius; @@ -150,7 +136,7 @@ public function getDistance() * * @return $this */ - public function setDistance($distance) + public function setDistance($distance): static { $this->distance = $distance; @@ -174,7 +160,7 @@ public function getDirection() * * @return $this */ - public function setDirection($direction) + public function setDirection($direction): static { $this->direction = $direction; @@ -198,7 +184,7 @@ public function getAlignment() * * @return $this */ - public function setAlignment($alignment) + public function setAlignment($alignment): static { $this->alignment = $alignment; @@ -220,7 +206,7 @@ public function getColor() * * @return $this */ - public function setColor(Color $color) + public function setColor(Color $color): static { $this->color = $color; @@ -244,7 +230,7 @@ public function getAlpha() * * @return $this */ - public function setAlpha($alpha) + public function setAlpha($alpha): static { $this->alpha = $alpha; @@ -256,7 +242,7 @@ public function setAlpha($alpha) * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( ($this->visible ? 't' : 'f') . diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index c3504d831b..5772afc608 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -174,7 +174,7 @@ public function getOddHeader() * * @return $this */ - public function setOddHeader($oddHeader) + public function setOddHeader($oddHeader): static { $this->oddHeader = $oddHeader; @@ -198,7 +198,7 @@ public function getOddFooter() * * @return $this */ - public function setOddFooter($oddFooter) + public function setOddFooter($oddFooter): static { $this->oddFooter = $oddFooter; @@ -222,7 +222,7 @@ public function getEvenHeader() * * @return $this */ - public function setEvenHeader($eventHeader) + public function setEvenHeader($eventHeader): static { $this->evenHeader = $eventHeader; @@ -246,7 +246,7 @@ public function getEvenFooter() * * @return $this */ - public function setEvenFooter($evenFooter) + public function setEvenFooter($evenFooter): static { $this->evenFooter = $evenFooter; @@ -270,7 +270,7 @@ public function getFirstHeader() * * @return $this */ - public function setFirstHeader($firstHeader) + public function setFirstHeader($firstHeader): static { $this->firstHeader = $firstHeader; @@ -294,7 +294,7 @@ public function getFirstFooter() * * @return $this */ - public function setFirstFooter($firstFooter) + public function setFirstFooter($firstFooter): static { $this->firstFooter = $firstFooter; @@ -318,7 +318,7 @@ public function getDifferentOddEven() * * @return $this */ - public function setDifferentOddEven($differentOddEvent) + public function setDifferentOddEven($differentOddEvent): static { $this->differentOddEven = $differentOddEvent; @@ -342,7 +342,7 @@ public function getDifferentFirst() * * @return $this */ - public function setDifferentFirst($differentFirst) + public function setDifferentFirst($differentFirst): static { $this->differentFirst = $differentFirst; @@ -366,7 +366,7 @@ public function getScaleWithDocument() * * @return $this */ - public function setScaleWithDocument($scaleWithDocument) + public function setScaleWithDocument($scaleWithDocument): static { $this->scaleWithDocument = $scaleWithDocument; @@ -390,7 +390,7 @@ public function getAlignWithMargins() * * @return $this */ - public function setAlignWithMargins($alignWithMargins) + public function setAlignWithMargins($alignWithMargins): static { $this->alignWithMargins = $alignWithMargins; @@ -404,7 +404,7 @@ public function setAlignWithMargins($alignWithMargins) * * @return $this */ - public function addImage(HeaderFooterDrawing $image, $location = self::IMAGE_HEADER_LEFT) + public function addImage(HeaderFooterDrawing $image, $location = self::IMAGE_HEADER_LEFT): static { $this->headerFooterImages[$location] = $image; @@ -418,7 +418,7 @@ public function addImage(HeaderFooterDrawing $image, $location = self::IMAGE_HEA * * @return $this */ - public function removeImage($location = self::IMAGE_HEADER_LEFT) + public function removeImage($location = self::IMAGE_HEADER_LEFT): static { if (isset($this->headerFooterImages[$location])) { unset($this->headerFooterImages[$location]); @@ -434,7 +434,7 @@ public function removeImage($location = self::IMAGE_HEADER_LEFT) * * @return $this */ - public function setImages(array $images) + public function setImages(array $images): static { $this->headerFooterImages = $images; @@ -446,7 +446,7 @@ public function setImages(array $images) * * @return HeaderFooterDrawing[] */ - public function getImages() + public function getImages(): array { // Sort array $images = []; diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php b/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php index b42c7324c1..67a270f293 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooterDrawing.php @@ -9,7 +9,7 @@ class HeaderFooterDrawing extends Drawing * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->getPath() . diff --git a/src/PhpSpreadsheet/Worksheet/Iterator.php b/src/PhpSpreadsheet/Worksheet/Iterator.php index dc082043e4..a56404642d 100644 --- a/src/PhpSpreadsheet/Worksheet/Iterator.php +++ b/src/PhpSpreadsheet/Worksheet/Iterator.php @@ -11,10 +11,8 @@ class Iterator implements \Iterator { /** * Spreadsheet to iterate. - * - * @var Spreadsheet */ - private $subject; + private Spreadsheet $subject; /** * Current iterator position. diff --git a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php index cf616eb751..c1dc3da21f 100644 --- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php @@ -28,34 +28,23 @@ class MemoryDrawing extends BaseDrawing /** * Image resource. - * - * @var null|GdImage|resource */ - private $imageResource; + private null|GdImage $imageResource = null; /** * Rendering function. - * - * @var string */ - private $renderingFunction; + private string $renderingFunction; /** * Mime type. - * - * @var string */ - private $mimeType; + private string $mimeType; /** * Unique name. - * - * @var string */ - private $uniqueName; - - /** @var null|resource */ - private $alwaysNull; + private string $uniqueName; /** * Create a new MemoryDrawing. @@ -66,7 +55,6 @@ public function __construct() $this->renderingFunction = self::RENDERING_DEFAULT; $this->mimeType = self::MIMETYPE_DEFAULT; $this->uniqueName = md5(mt_rand(0, 9999) . time() . mt_rand(0, 9999)); - $this->alwaysNull = null; // Initialize parent parent::__construct(); @@ -75,9 +63,8 @@ public function __construct() public function __destruct() { if ($this->imageResource) { - $rslt = @imagedestroy($this->imageResource); - // "Fix" for Scrutinizer - $this->imageResource = $rslt ? null : $this->alwaysNull; + @imagedestroy($this->imageResource); + $this->imageResource = null; } } @@ -253,10 +240,8 @@ private static function supportedMimeTypes(?string $mimeType = null): ?string /** * Get image resource. - * - * @return null|GdImage|resource */ - public function getImageResource() + public function getImageResource(): ?GdImage { return $this->imageResource; } @@ -264,11 +249,9 @@ public function getImageResource() /** * Set image resource. * - * @param GdImage|resource $value - * * @return $this */ - public function setImageResource($value) + public function setImageResource(?GdImage $value): static { $this->imageResource = $value; @@ -298,7 +281,7 @@ public function getRenderingFunction() * * @return $this */ - public function setRenderingFunction($value) + public function setRenderingFunction($value): static { $this->renderingFunction = $value; @@ -322,7 +305,7 @@ public function getMimeType() * * @return $this */ - public function setMimeType($value) + public function setMimeType($value): static { $this->mimeType = $value; @@ -346,7 +329,7 @@ public function getIndexedFilename(): string * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->renderingFunction . diff --git a/src/PhpSpreadsheet/Worksheet/PageBreak.php b/src/PhpSpreadsheet/Worksheet/PageBreak.php index 743cc58d69..5099d8be0d 100644 --- a/src/PhpSpreadsheet/Worksheet/PageBreak.php +++ b/src/PhpSpreadsheet/Worksheet/PageBreak.php @@ -8,14 +8,11 @@ class PageBreak { - /** @var int */ - private $breakType; + private int $breakType; - /** @var string */ - private $coordinate; + private string $coordinate; - /** @var int */ - private $maxColOrRow; + private int $maxColOrRow; /** @param array|CellAddress|string $coordinate */ public function __construct(int $breakType, $coordinate, int $maxColOrRow = -1) diff --git a/src/PhpSpreadsheet/Worksheet/PageMargins.php b/src/PhpSpreadsheet/Worksheet/PageMargins.php index d51023fcc1..8039cc3303 100644 --- a/src/PhpSpreadsheet/Worksheet/PageMargins.php +++ b/src/PhpSpreadsheet/Worksheet/PageMargins.php @@ -70,7 +70,7 @@ public function getLeft() * * @return $this */ - public function setLeft($left) + public function setLeft($left): static { $this->left = $left; @@ -94,7 +94,7 @@ public function getRight() * * @return $this */ - public function setRight($right) + public function setRight($right): static { $this->right = $right; @@ -118,7 +118,7 @@ public function getTop() * * @return $this */ - public function setTop($top) + public function setTop($top): static { $this->top = $top; @@ -142,7 +142,7 @@ public function getBottom() * * @return $this */ - public function setBottom($bottom) + public function setBottom($bottom): static { $this->bottom = $bottom; @@ -166,7 +166,7 @@ public function getHeader() * * @return $this */ - public function setHeader($header) + public function setHeader($header): static { $this->header = $header; @@ -190,7 +190,7 @@ public function getFooter() * * @return $this */ - public function setFooter($footer) + public function setFooter($footer): static { $this->footer = $footer; diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 72c8958c8b..96987bbe8e 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -291,7 +291,7 @@ public function getPaperSize() * * @return $this */ - public function setPaperSize($paperSize) + public function setPaperSize($paperSize): static { $this->paperSize = $paperSize; @@ -331,7 +331,7 @@ public function getOrientation() * * @return $this */ - public function setOrientation($orientation) + public function setOrientation($orientation): static { if ($orientation === self::ORIENTATION_LANDSCAPE || $orientation === self::ORIENTATION_PORTRAIT || $orientation === self::ORIENTATION_DEFAULT) { $this->orientation = $orientation; @@ -372,7 +372,7 @@ public function getScale() * * @return $this */ - public function setScale($scale, $update = true) + public function setScale($scale, $update = true): static { // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, // but it is apparently still able to handle any scale >= 0, where 0 results in 100 @@ -405,7 +405,7 @@ public function getFitToPage() * * @return $this */ - public function setFitToPage($fitToPage) + public function setFitToPage($fitToPage): static { $this->fitToPage = $fitToPage; @@ -430,7 +430,7 @@ public function getFitToHeight() * * @return $this */ - public function setFitToHeight($fitToHeight, $update = true) + public function setFitToHeight($fitToHeight, $update = true): static { $this->fitToHeight = $fitToHeight; if ($update) { @@ -458,7 +458,7 @@ public function getFitToWidth() * * @return $this */ - public function setFitToWidth($value, $update = true) + public function setFitToWidth($value, $update = true): static { $this->fitToWidth = $value; if ($update) { @@ -470,10 +470,8 @@ public function setFitToWidth($value, $update = true) /** * Is Columns to repeat at left set? - * - * @return bool */ - public function isColumnsToRepeatAtLeftSet() + public function isColumnsToRepeatAtLeftSet(): bool { if (!empty($this->columnsToRepeatAtLeft)) { if ($this->columnsToRepeatAtLeft[0] != '' && $this->columnsToRepeatAtLeft[1] != '') { @@ -501,7 +499,7 @@ public function getColumnsToRepeatAtLeft() * * @return $this */ - public function setColumnsToRepeatAtLeft(array $columnsToRepeatAtLeft) + public function setColumnsToRepeatAtLeft(array $columnsToRepeatAtLeft): static { $this->columnsToRepeatAtLeft = $columnsToRepeatAtLeft; @@ -516,7 +514,7 @@ public function setColumnsToRepeatAtLeft(array $columnsToRepeatAtLeft) * * @return $this */ - public function setColumnsToRepeatAtLeftByStartAndEnd($start, $end) + public function setColumnsToRepeatAtLeftByStartAndEnd($start, $end): static { $this->columnsToRepeatAtLeft = [$start, $end]; @@ -525,10 +523,8 @@ public function setColumnsToRepeatAtLeftByStartAndEnd($start, $end) /** * Is Rows to repeat at top set? - * - * @return bool */ - public function isRowsToRepeatAtTopSet() + public function isRowsToRepeatAtTopSet(): bool { if (!empty($this->rowsToRepeatAtTop)) { if ($this->rowsToRepeatAtTop[0] != 0 && $this->rowsToRepeatAtTop[1] != 0) { @@ -556,7 +552,7 @@ public function getRowsToRepeatAtTop() * * @return $this */ - public function setRowsToRepeatAtTop(array $rowsToRepeatAtTop) + public function setRowsToRepeatAtTop(array $rowsToRepeatAtTop): static { $this->rowsToRepeatAtTop = $rowsToRepeatAtTop; @@ -571,7 +567,7 @@ public function setRowsToRepeatAtTop(array $rowsToRepeatAtTop) * * @return $this */ - public function setRowsToRepeatAtTopByStartAndEnd($start, $end) + public function setRowsToRepeatAtTopByStartAndEnd($start, $end): static { $this->rowsToRepeatAtTop = [$start, $end]; @@ -595,7 +591,7 @@ public function getHorizontalCentered() * * @return $this */ - public function setHorizontalCentered($value) + public function setHorizontalCentered($value): static { $this->horizontalCentered = $value; @@ -619,7 +615,7 @@ public function getVerticalCentered() * * @return $this */ - public function setVerticalCentered($value) + public function setVerticalCentered($value): static { $this->verticalCentered = $value; @@ -656,10 +652,8 @@ public function getPrintArea($index = 0) * Default behaviour, or an index value of 0, will identify whether any print range is set * Otherwise, existence of the range identified by the value of $index will be returned * Print areas are numbered from 1 - * - * @return bool */ - public function isPrintAreaSet($index = 0) + public function isPrintAreaSet($index = 0): bool { if ($index == 0) { return $this->printArea !== null; @@ -679,7 +673,7 @@ public function isPrintAreaSet($index = 0) * * @return $this */ - public function clearPrintArea($index = 0) + public function clearPrintArea($index = 0): static { if ($index == 0) { $this->printArea = null; @@ -714,7 +708,7 @@ public function clearPrintArea($index = 0) * * @return $this */ - public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) + public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE): static { if (strpos($value, '!') !== false) { throw new PhpSpreadsheetException('Cell coordinate must not specify a worksheet.'); @@ -776,7 +770,7 @@ public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_O * * @return $this */ - public function addPrintArea($value, $index = -1) + public function addPrintArea($value, $index = -1): static { return $this->setPrintArea($value, $index, self::SETPRINTRANGE_INSERT); } @@ -804,7 +798,7 @@ public function addPrintArea($value, $index = -1) * * @return $this */ - public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE) + public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE): static { return $this->setPrintArea( Coordinate::stringFromColumnIndex($column1) . $row1 . ':' . Coordinate::stringFromColumnIndex($column2) . $row2, @@ -829,7 +823,7 @@ public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $in * * @return $this */ - public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1) + public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1): static { return $this->setPrintArea( Coordinate::stringFromColumnIndex($column1) . $row1 . ':' . Coordinate::stringFromColumnIndex($column2) . $row2, @@ -855,7 +849,7 @@ public function getFirstPageNumber() * * @return $this */ - public function setFirstPageNumber($value) + public function setFirstPageNumber($value): static { $this->firstPageNumber = $value; @@ -867,7 +861,7 @@ public function setFirstPageNumber($value) * * @return $this */ - public function resetFirstPageNumber() + public function resetFirstPageNumber(): static { return $this->setFirstPageNumber(null); } diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index 063a5cc2be..958a18dc6c 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -19,115 +19,83 @@ class Protection /** * Autofilters are locked when sheet is protected, default true. - * - * @var ?bool */ - private $autoFilter; + private ?bool $autoFilter = null; /** * Deleting columns is locked when sheet is protected, default true. - * - * @var ?bool */ - private $deleteColumns; + private ?bool $deleteColumns = null; /** * Deleting rows is locked when sheet is protected, default true. - * - * @var ?bool */ - private $deleteRows; + private ?bool $deleteRows = null; /** * Formatting cells is locked when sheet is protected, default true. - * - * @var ?bool */ - private $formatCells; + private ?bool $formatCells = null; /** * Formatting columns is locked when sheet is protected, default true. - * - * @var ?bool */ - private $formatColumns; + private ?bool $formatColumns = null; /** * Formatting rows is locked when sheet is protected, default true. - * - * @var ?bool */ - private $formatRows; + private ?bool $formatRows = null; /** * Inserting columns is locked when sheet is protected, default true. - * - * @var ?bool */ - private $insertColumns; + private ?bool $insertColumns = null; /** * Inserting hyperlinks is locked when sheet is protected, default true. - * - * @var ?bool */ - private $insertHyperlinks; + private ?bool $insertHyperlinks = null; /** * Inserting rows is locked when sheet is protected, default true. - * - * @var ?bool */ - private $insertRows; + private ?bool $insertRows = null; /** * Objects are locked when sheet is protected, default false. - * - * @var ?bool */ - private $objects; + private ?bool $objects = null; /** * Pivot tables are locked when the sheet is protected, default true. - * - * @var ?bool */ - private $pivotTables; + private ?bool $pivotTables = null; /** * Scenarios are locked when sheet is protected, default false. - * - * @var ?bool */ - private $scenarios; + private ?bool $scenarios = null; /** * Selection of locked cells is locked when sheet is protected, default false. - * - * @var ?bool */ - private $selectLockedCells; + private ?bool $selectLockedCells = null; /** * Selection of unlocked cells is locked when sheet is protected, default false. - * - * @var ?bool */ - private $selectUnlockedCells; + private ?bool $selectUnlockedCells = null; /** * Sheet is locked when sheet is protected, default false. - * - * @var ?bool */ - private $sheet; + private ?bool $sheet = null; /** * Sorting is locked when sheet is protected, default true. - * - * @var ?bool */ - private $sort; + private ?bool $sort = null; /** * Hashed password. @@ -138,17 +106,13 @@ class Protection /** * Algorithm name. - * - * @var string */ - private $algorithm = ''; + private string $algorithm = ''; /** * Salt value. - * - * @var string */ - private $salt = ''; + private string $salt = ''; /** * Spin count. @@ -399,7 +363,7 @@ public function getPassword() * * @return $this */ - public function setPassword($password, $alreadyHashed = false) + public function setPassword($password, $alreadyHashed = false): static { if (!$alreadyHashed) { $salt = $this->generateSalt(); diff --git a/src/PhpSpreadsheet/Worksheet/Row.php b/src/PhpSpreadsheet/Worksheet/Row.php index b5f08816b8..4d8ad57e38 100644 --- a/src/PhpSpreadsheet/Worksheet/Row.php +++ b/src/PhpSpreadsheet/Worksheet/Row.php @@ -4,12 +4,7 @@ class Row { - /** - * \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet. - * - * @var Worksheet - */ - private $worksheet; + private ?Worksheet $worksheet; /** * Row index. @@ -35,7 +30,7 @@ public function __construct(Worksheet $worksheet, $rowIndex = 1) */ public function __destruct() { - $this->worksheet = null; // @phpstan-ignore-line + $this->worksheet = null; } /** @@ -54,7 +49,7 @@ public function getRowIndex(): int */ public function getCellIterator($startColumn = 'A', $endColumn = null): RowCellIterator { - return new RowCellIterator($this->worksheet, $this->rowIndex, $startColumn, $endColumn); + return new RowCellIterator($this->getWorksheet(), $this->rowIndex, $startColumn, $endColumn); } /** @@ -115,6 +110,7 @@ public function isEmpty(int $definitionOfEmptyFlags = 0, $startColumn = 'A', $en */ public function getWorksheet(): Worksheet { + // @phpstan-ignore-next-line return $this->worksheet; } } diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 0df776f2af..4174fd2230 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -13,10 +13,8 @@ class RowCellIterator extends CellIterator { /** * Current iterator position. - * - * @var int */ - private $currentColumnIndex; + private int $currentColumnIndex; /** * Row index. @@ -47,7 +45,7 @@ class RowCellIterator extends CellIterator * @param string $startColumn The column address at which to start iterating * @param string $endColumn Optionally, the column address at which to stop iterating */ - public function __construct(Worksheet $worksheet, $rowIndex = 1, $startColumn = 'A', $endColumn = null) + public function __construct(Worksheet $worksheet, $rowIndex = 1, string $startColumn = 'A', $endColumn = null) { // Set subject and row index $this->worksheet = $worksheet; @@ -64,7 +62,7 @@ public function __construct(Worksheet $worksheet, $rowIndex = 1, $startColumn = * * @return $this */ - public function resetStart(string $startColumn = 'A') + public function resetStart(string $startColumn = 'A'): static { $this->startColumnIndex = Coordinate::columnIndexFromString($startColumn); $this->adjustForExistingOnlyRange(); @@ -80,7 +78,7 @@ public function resetStart(string $startColumn = 'A') * * @return $this */ - public function resetEnd($endColumn = null) + public function resetEnd($endColumn = null): static { $endColumn = $endColumn ?: $this->worksheet->getHighestColumn(); $this->endColumnIndex = Coordinate::columnIndexFromString($endColumn); @@ -96,7 +94,7 @@ public function resetEnd($endColumn = null) * * @return $this */ - public function seek(string $column = 'A') + public function seek(string $column = 'A'): static { $columnId = Coordinate::columnIndexFromString($column); if ($this->onlyExistingCells && !($this->cellCollection->has($column . $this->rowIndex))) { diff --git a/src/PhpSpreadsheet/Worksheet/RowDimension.php b/src/PhpSpreadsheet/Worksheet/RowDimension.php index a5e0f98b79..b3c213a96b 100644 --- a/src/PhpSpreadsheet/Worksheet/RowDimension.php +++ b/src/PhpSpreadsheet/Worksheet/RowDimension.php @@ -8,10 +8,8 @@ class RowDimension extends Dimension { /** * Row index. - * - * @var ?int */ - private $rowIndex; + private ?int $rowIndex; /** * Row height (in pt). @@ -56,7 +54,7 @@ public function getRowIndex(): ?int * * @return $this */ - public function setRowIndex(int $index) + public function setRowIndex(int $index): static { $this->rowIndex = $index; @@ -87,7 +85,7 @@ public function getRowHeight(?string $unitOfMeasure = null) * * @return $this */ - public function setRowHeight($height, ?string $unitOfMeasure = null) + public function setRowHeight($height, ?string $unitOfMeasure = null): static { $this->height = ($unitOfMeasure === null || $height < 0) ? $height @@ -109,7 +107,7 @@ public function getZeroHeight(): bool * * @return $this */ - public function setZeroHeight(bool $zeroHeight) + public function setZeroHeight(bool $zeroHeight): static { $this->zeroHeight = $zeroHeight; diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index af2bda25a6..27723d9dd6 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -45,7 +45,7 @@ class RowIterator implements NativeIterator * @param int $startRow The row number at which to start iterating * @param int $endRow Optionally, the row number at which to stop iterating */ - public function __construct(Worksheet $subject, $startRow = 1, $endRow = null) + public function __construct(Worksheet $subject, int $startRow = 1, $endRow = null) { // Set subject $this->subject = $subject; @@ -65,7 +65,7 @@ public function __destruct() * * @return $this */ - public function resetStart(int $startRow = 1) + public function resetStart(int $startRow = 1): static { if ($startRow > $this->subject->getHighestRow()) { throw new PhpSpreadsheetException( @@ -89,7 +89,7 @@ public function resetStart(int $startRow = 1) * * @return $this */ - public function resetEnd($endRow = null) + public function resetEnd($endRow = null): static { $this->endRow = $endRow ?: $this->subject->getHighestRow(); @@ -103,7 +103,7 @@ public function resetEnd($endRow = null) * * @return $this */ - public function seek(int $row = 1) + public function seek(int $row = 1): static { if (($row < $this->startRow) || ($row > $this->endRow)) { throw new PhpSpreadsheetException("Row $row is out of range ({$this->startRow} - {$this->endRow})"); diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index 697f11c2ae..f61fe6a690 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -79,7 +79,7 @@ public function getZoomScale() * * @return $this */ - public function setZoomScale($zoomScale) + public function setZoomScale($zoomScale): static { // Microsoft Office Excel 2007 only allows setting a scale between 10 and 400 via the user interface, // but it is apparently still able to handle any scale >= 1 @@ -110,7 +110,7 @@ public function getZoomScaleNormal() * * @return $this */ - public function setZoomScaleNormal($zoomScaleNormal) + public function setZoomScaleNormal($zoomScaleNormal): static { if ($zoomScaleNormal === null || $zoomScaleNormal >= 1) { $this->zoomScaleNormal = $zoomScaleNormal; @@ -161,7 +161,7 @@ public function getView() * * @return $this */ - public function setView($sheetViewType) + public function setView($sheetViewType): static { // MS Excel 2007 allows setting the view to 'normal', 'pageLayout' or 'pageBreakPreview' via the user interface if ($sheetViewType === null) { diff --git a/src/PhpSpreadsheet/Worksheet/Table.php b/src/PhpSpreadsheet/Worksheet/Table.php index af70024fba..9a48632d03 100644 --- a/src/PhpSpreadsheet/Worksheet/Table.php +++ b/src/PhpSpreadsheet/Worksheet/Table.php @@ -14,10 +14,8 @@ class Table { /** * Table Name. - * - * @var string */ - private $name; + private string $name; /** * Show Header Row. @@ -35,17 +33,13 @@ class Table /** * Table Range. - * - * @var string */ - private $range = ''; + private string $range = ''; /** * Table Worksheet. - * - * @var null|Worksheet */ - private $workSheet; + private ?Worksheet $workSheet = null; /** * Table allow filter. @@ -63,17 +57,13 @@ class Table /** * Table Style. - * - * @var TableStyle */ - private $style; + private TableStyle $style; /** * Table AutoFilter. - * - * @var AutoFilter */ - private $autoFilter; + private AutoFilter $autoFilter; /** * Create a new Table. @@ -170,7 +160,7 @@ private function checkForDuplicateTableNames(string $name, ?Worksheet $worksheet private function updateStructuredReferences(string $name): void { - if ($this->workSheet === null || $this->name === null || $this->name === '') { + if (!$this->workSheet || !$this->name) { return; } @@ -412,7 +402,7 @@ public function isColumnInRange(string $column): int * * @return int The offset of the specified column within the table range */ - public function getColumnOffset($column): int + public function getColumnOffset(string $column): int { return $this->isColumnInRange($column); } @@ -586,7 +576,7 @@ public function __clone() * toString method replicates previous behavior by returning the range if object is * referenced as a property of its worksheet. */ - public function __toString() + public function __toString(): string { return (string) $this->range; } diff --git a/src/PhpSpreadsheet/Worksheet/Table/Column.php b/src/PhpSpreadsheet/Worksheet/Table/Column.php index 32dd4c4f83..f697423894 100644 --- a/src/PhpSpreadsheet/Worksheet/Table/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Table/Column.php @@ -12,10 +12,8 @@ class Column { /** * Table Column Index. - * - * @var string */ - private $columnIndex = ''; + private string $columnIndex = ''; /** * Show Filter Button. @@ -26,38 +24,28 @@ class Column /** * Total Row Label. - * - * @var string */ - private $totalsRowLabel; + private ?string $totalsRowLabel = null; /** * Total Row Function. - * - * @var string */ - private $totalsRowFunction; + private ?string $totalsRowFunction = null; /** * Total Row Formula. - * - * @var string */ - private $totalsRowFormula; + private ?string $totalsRowFormula = null; /** * Column Formula. - * - * @var string */ - private $columnFormula; + private ?string $columnFormula = null; /** * Table. - * - * @var null|Table */ - private $table; + private ?Table $table; /** * Create a new Column. diff --git a/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php b/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php index 78643c729e..c0744c995b 100644 --- a/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php +++ b/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php @@ -70,10 +70,8 @@ class TableStyle /** * Theme. - * - * @var string */ - private $theme; + private string $theme; /** * Show First Column. @@ -105,10 +103,8 @@ class TableStyle /** * Table. - * - * @var null|Table */ - private $table; + private ?Table $table = null; /** * Create a new Table Style. diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index a904c8f62b..1a20a9ec44 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -67,17 +67,13 @@ class Worksheet implements IComparable /** * Parent spreadsheet. - * - * @var ?Spreadsheet */ - private $parent; + private ?Spreadsheet $parent; /** * Collection of cells. - * - * @var Cells */ - private $cellCollection; + private ?Cells $cellCollection; /** * Collection of row dimensions. @@ -88,10 +84,8 @@ class Worksheet implements IComparable /** * Default row dimension. - * - * @var RowDimension */ - private $defaultRowDimension; + private RowDimension $defaultRowDimension; /** * Collection of column dimensions. @@ -102,31 +96,29 @@ class Worksheet implements IComparable /** * Default column dimension. - * - * @var ColumnDimension */ - private $defaultColumnDimension; + private ColumnDimension $defaultColumnDimension; /** * Collection of drawings. * * @var ArrayObject */ - private $drawingCollection; + private ArrayObject $drawingCollection; /** * Collection of Chart objects. * * @var ArrayObject */ - private $chartCollection; + private ArrayObject $chartCollection; /** * Collection of Table objects. * * @var ArrayObject */ - private $tableCollection; + private ArrayObject $tableCollection; /** * Worksheet title. @@ -144,38 +136,28 @@ class Worksheet implements IComparable /** * Page setup. - * - * @var PageSetup */ - private $pageSetup; + private PageSetup $pageSetup; /** * Page margins. - * - * @var PageMargins */ - private $pageMargins; + private PageMargins $pageMargins; /** * Page header/footer. - * - * @var HeaderFooter */ - private $headerFooter; + private HeaderFooter $headerFooter; /** * Sheet view. - * - * @var SheetView */ - private $sheetView; + private SheetView $sheetView; /** * Protection. - * - * @var Protection */ - private $protection; + private Protection $protection; /** * Collection of styles. @@ -221,10 +203,8 @@ class Worksheet implements IComparable /** * Autofilter Range and selection. - * - * @var AutoFilter */ - private $autoFilter; + private AutoFilter $autoFilter; /** * Freeze pane. @@ -428,7 +408,6 @@ public function disconnectCells(): void { if ($this->cellCollection !== null) { $this->cellCollection->unsetWorksheetCells(); - // @phpstan-ignore-next-line $this->cellCollection = null; } // detach ourself from the workbook, so that it can then delete this worksheet successfully @@ -454,6 +433,7 @@ public function __destruct() */ public function getCellCollection() { + // @phpstan-ignore-next-line return $this->cellCollection; } @@ -474,7 +454,7 @@ public static function getInvalidCharacters() * * @return string The valid string */ - private static function checkSheetCodeName($sheetCodeName) + private static function checkSheetCodeName($sheetCodeName): string { $charCount = Shared\StringHelper::countCharacters($sheetCodeName); if ($charCount == 0) { @@ -504,7 +484,7 @@ private static function checkSheetCodeName($sheetCodeName) * * @return string The valid string */ - private static function checkSheetTitle($sheetTitle) + private static function checkSheetTitle($sheetTitle): string { // Some of the printable ASCII characters are invalid: * : / \ ? [ ] if (str_replace(self::$invalidCharacters, '', $sheetTitle) !== $sheetTitle) { @@ -526,7 +506,7 @@ private static function checkSheetTitle($sheetTitle) * * @return string[] */ - public function getCoordinates($sorted = true) + public function getCoordinates($sorted = true): array { if ($this->cellCollection == null) { return []; @@ -612,10 +592,8 @@ public function getChartCollection() * Add chart. * * @param null|int $chartIndex Index where chart should go (0,1,..., or null for last) - * - * @return Chart */ - public function addChart(Chart $chart, $chartIndex = null) + public function addChart(Chart $chart, $chartIndex = null): Chart { $chart->setWorksheet($this); if ($chartIndex === null) { @@ -634,7 +612,7 @@ public function addChart(Chart $chart, $chartIndex = null) * * @return int The number of charts */ - public function getChartCount() + public function getChartCount(): int { return count($this->chartCollection); } @@ -667,7 +645,7 @@ public function getChartByIndex($index) * * @return string[] The names of charts */ - public function getChartNames() + public function getChartNames(): array { $chartNames = []; foreach ($this->chartCollection as $chart) { @@ -700,7 +678,7 @@ public function getChartByName($chartName) * * @return $this */ - public function refreshColumnDimensions() + public function refreshColumnDimensions(): static { $newColumnDimensions = []; foreach ($this->getColumnDimensions() as $objColumnDimension) { @@ -717,7 +695,7 @@ public function refreshColumnDimensions() * * @return $this */ - public function refreshRowDimensions() + public function refreshRowDimensions(): static { $newRowDimensions = []; foreach ($this->getRowDimensions() as $objRowDimension) { @@ -734,7 +712,7 @@ public function refreshRowDimensions() * * @return string String containing the dimension of this worksheet */ - public function calculateWorksheetDimension() + public function calculateWorksheetDimension(): string { // Return return 'A1:' . $this->getHighestColumn() . $this->getHighestRow(); @@ -745,7 +723,7 @@ public function calculateWorksheetDimension() * * @return string String containing the dimension of this worksheet that actually contain data */ - public function calculateWorksheetDataDimension() + public function calculateWorksheetDataDimension(): string { // Return return 'A1:' . $this->getHighestDataColumn() . $this->getHighestDataRow(); @@ -756,7 +734,7 @@ public function calculateWorksheetDataDimension() * * @return $this */ - public function calculateColumnWidths() + public function calculateColumnWidths(): static { // initialize $autoSizes array $autoSizes = []; @@ -782,9 +760,9 @@ public function calculateColumnWidths() foreach ($this->getCoordinates(false) as $coordinate) { $cell = $this->getCellOrNull($coordinate); - if ($cell !== null && isset($autoSizes[$this->cellCollection->getCurrentColumn()])) { + if ($cell !== null && isset($autoSizes[$this->getCellCollection()->getCurrentColumn()])) { //Determine if cell is in merge range - $isMerged = isset($isMergeCell[$this->cellCollection->getCurrentCoordinate()]); + $isMerged = isset($isMergeCell[$this->getCellCollection()->getCurrentCoordinate()]); //By default merged cells should be ignored $isMergedButProceed = false; @@ -825,8 +803,8 @@ public function calculateColumnWidths() ); if ($cellValue !== null && $cellValue !== '') { - $autoSizes[$this->cellCollection->getCurrentColumn()] = max( - $autoSizes[$this->cellCollection->getCurrentColumn()], + $autoSizes[$this->getCellCollection()->getCurrentColumn()] = max( + $autoSizes[$this->getCellCollection()->getCurrentColumn()], round( Shared\Font::calculateColumnWidth( $this->getParentOrThrow()->getCellXfByIndex($cell->getXfIndex())->getFont(), @@ -882,7 +860,7 @@ public function getParentOrThrow(): Spreadsheet * * @return $this */ - public function rebindParent(Spreadsheet $parent) + public function rebindParent(Spreadsheet $parent): static { if ($this->parent !== null) { $definedNames = $this->parent->getDefinedNames(); @@ -923,7 +901,7 @@ public function getTitle() * * @return $this */ - public function setTitle($title, $updateFormulaCellReferences = true, $validate = true) + public function setTitle($title, $updateFormulaCellReferences = true, $validate = true): static { // Is this a 'rename' or not? if ($this->getTitle() == $title) { @@ -998,7 +976,7 @@ public function getSheetState() * * @return $this */ - public function setSheetState($value) + public function setSheetState($value): static { $this->sheetState = $value; @@ -1020,7 +998,7 @@ public function getPageSetup() * * @return $this */ - public function setPageSetup(PageSetup $pageSetup) + public function setPageSetup(PageSetup $pageSetup): static { $this->pageSetup = $pageSetup; @@ -1042,7 +1020,7 @@ public function getPageMargins() * * @return $this */ - public function setPageMargins(PageMargins $pageMargins) + public function setPageMargins(PageMargins $pageMargins): static { $this->pageMargins = $pageMargins; @@ -1064,7 +1042,7 @@ public function getHeaderFooter() * * @return $this */ - public function setHeaderFooter(HeaderFooter $headerFooter) + public function setHeaderFooter(HeaderFooter $headerFooter): static { $this->headerFooter = $headerFooter; @@ -1086,7 +1064,7 @@ public function getSheetView() * * @return $this */ - public function setSheetView(SheetView $sheetView) + public function setSheetView(SheetView $sheetView): static { $this->sheetView = $sheetView; @@ -1108,7 +1086,7 @@ public function getProtection() * * @return $this */ - public function setProtection(Protection $protection) + public function setProtection(Protection $protection): static { $this->protection = $protection; $this->dirty = true; @@ -1143,7 +1121,7 @@ public function getHighestColumn($row = null) */ public function getHighestDataColumn($row = null) { - return $this->cellCollection->getHighestColumn($row); + return $this->getCellCollection()->getHighestColumn($row); } /** @@ -1173,7 +1151,7 @@ public function getHighestRow($column = null) */ public function getHighestDataRow($column = null) { - return $this->cellCollection->getHighestRow($column); + return $this->getCellCollection()->getHighestRow($column); } /** @@ -1181,9 +1159,9 @@ public function getHighestDataRow($column = null) * * @return array Highest column name and highest row number */ - public function getHighestRowAndColumn() + public function getHighestRowAndColumn(): array { - return $this->cellCollection->getHighestRowAndColumn(); + return $this->getCellCollection()->getHighestRowAndColumn(); } /** @@ -1196,7 +1174,7 @@ public function getHighestRowAndColumn() * * @return $this */ - public function setCellValue($coordinate, $value, ?IValueBinder $binder = null) + public function setCellValue($coordinate, $value, ?IValueBinder $binder = null): static { $cellAddress = Functions::trimSheetFromCellReference(Validations::validateCellAddress($coordinate)); $this->getCell($cellAddress)->setValue($value, $binder); @@ -1219,7 +1197,7 @@ public function setCellValue($coordinate, $value, ?IValueBinder $binder = null) * * @return $this */ - public function setCellValueByColumnAndRow($columnIndex, $row, $value, ?IValueBinder $binder = null) + public function setCellValueByColumnAndRow($columnIndex, $row, $value, ?IValueBinder $binder = null): static { $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValue($value, $binder); @@ -1243,7 +1221,7 @@ public function setCellValueByColumnAndRow($columnIndex, $row, $value, ?IValueBi * * @return $this */ - public function setCellValueExplicit($coordinate, $value, $dataType) + public function setCellValueExplicit($coordinate, $value, string $dataType): static { $cellAddress = Functions::trimSheetFromCellReference(Validations::validateCellAddress($coordinate)); $this->getCell($cellAddress)->setValueExplicit($value, $dataType); @@ -1273,7 +1251,7 @@ public function setCellValueExplicit($coordinate, $value, $dataType) * * @return $this */ - public function setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, $dataType) + public function setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, string $dataType): static { $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValueExplicit($value, $dataType); @@ -1298,16 +1276,16 @@ public function getCell($coordinate): Cell $cellAddress = Functions::trimSheetFromCellReference(Validations::validateCellAddress($coordinate)); // Shortcut for increased performance for the vast majority of simple cases - if ($this->cellCollection->has($cellAddress)) { + if ($this->getCellCollection()->has($cellAddress)) { /** @var Cell $cell */ - $cell = $this->cellCollection->get($cellAddress); + $cell = $this->getCellCollection()->get($cellAddress); return $cell; } /** @var Worksheet $sheet */ [$sheet, $finalCoordinate] = $this->getWorksheetAndCoordinate($cellAddress); - $cell = $sheet->cellCollection->get($finalCoordinate); + $cell = $sheet->getCellCollection()->get($finalCoordinate); return $cell ?? $sheet->createNewCell($finalCoordinate); } @@ -1375,8 +1353,8 @@ private function getWorksheetAndCoordinate(string $coordinate): array private function getCellOrNull($coordinate): ?Cell { // Check cell collection - if ($this->cellCollection->has($coordinate)) { - return $this->cellCollection->get($coordinate); + if ($this->getCellCollection()->has($coordinate)) { + return $this->getCellCollection()->get($coordinate); } return null; @@ -1417,11 +1395,11 @@ public function getCellByColumnAndRow($columnIndex, $row): Cell * the "active" cell, and any previous assignment becomes a disconnected reference because * the active cell has changed. */ - public function createNewCell($coordinate): Cell + public function createNewCell(string $coordinate): Cell { [$column, $row, $columnString] = Coordinate::indexesFromString($coordinate); $cell = new Cell(null, DataType::TYPE_NULL, $this); - $this->cellCollection->add($coordinate, $cell); + $this->getCellCollection()->add($coordinate, $cell); // Coordinates if ($column > $this->cachedHighestColumn) { @@ -1465,10 +1443,9 @@ public function createNewCell($coordinate): Cell public function cellExists($coordinate): bool { $cellAddress = Validations::validateCellAddress($coordinate); - /** @var Worksheet $sheet */ [$sheet, $finalCoordinate] = $this->getWorksheetAndCoordinate($cellAddress); - return $sheet->cellCollection->has($finalCoordinate); + return $sheet->getCellCollection()->has($finalCoordinate); } /** @@ -1586,10 +1563,8 @@ public function getStyle($cellCoordinate): Style * @param int $row1 Numeric row coordinate of the cell * @param null|int $columnIndex2 Numeric column coordinate of the range cell * @param null|int $row2 Numeric row coordinate of the range cell - * - * @return Style */ - public function getStyleByColumnAndRow($columnIndex1, $row1, $columnIndex2 = null, $row2 = null) + public function getStyleByColumnAndRow($columnIndex1, $row1, $columnIndex2 = null, $row2 = null): Style { if ($columnIndex2 !== null && $row2 !== null) { $cellRange = new CellRange( @@ -1677,7 +1652,7 @@ public function conditionalStylesExists($coordinate): bool * * @return $this */ - public function removeConditionalStyles($coordinate) + public function removeConditionalStyles($coordinate): static { unset($this->conditionalStylesCollection[strtoupper($coordinate)]); @@ -1702,7 +1677,7 @@ public function getConditionalStylesCollection() * * @return $this */ - public function setConditionalStyles($coordinate, $styles) + public function setConditionalStyles($coordinate, $styles): static { $this->conditionalStylesCollection[strtoupper($coordinate)] = $styles; @@ -1719,7 +1694,7 @@ public function setConditionalStyles($coordinate, $styles) * * @return $this */ - public function duplicateStyle(Style $style, $range) + public function duplicateStyle(Style $style, string $range): static { // Add the style to the workbook if necessary $workbook = $this->getParentOrThrow(); @@ -1762,7 +1737,7 @@ public function duplicateStyle(Style $style, $range) * * @return $this */ - public function duplicateConditionalStyle(array $styles, $range = '') + public function duplicateConditionalStyle(array $styles, string $range = ''): static { foreach ($styles as $cellStyle) { if (!($cellStyle instanceof Conditional)) { @@ -1799,7 +1774,7 @@ public function duplicateConditionalStyle(array $styles, $range = '') * * @return $this */ - public function setBreak($coordinate, $break, int $max = -1) + public function setBreak($coordinate, $break, int $max = -1): static { $cellAddress = Functions::trimSheetFromCellReference(Validations::validateCellAddress($coordinate)); @@ -1828,7 +1803,7 @@ public function setBreak($coordinate, $break, int $max = -1) * * @return $this */ - public function setBreakByColumnAndRow($columnIndex, $row, $break) + public function setBreakByColumnAndRow($columnIndex, $row, $break): static { return $this->setBreak(Coordinate::stringFromColumnIndex($columnIndex) . $row, $break); } @@ -1838,7 +1813,7 @@ public function setBreakByColumnAndRow($columnIndex, $row, $break) * * @return int[] */ - public function getBreaks() + public function getBreaks(): array { $breaks = []; /** @var callable */ @@ -1915,7 +1890,7 @@ public function getColumnBreaks() * * @return $this */ - public function mergeCells($range, $behaviour = self::MERGE_CELL_CONTENT_EMPTY) + public function mergeCells($range, $behaviour = self::MERGE_CELL_CONTENT_EMPTY): static { $range = Functions::trimSheetFromCellReference(Validations::validateCellRange($range)); @@ -2047,7 +2022,7 @@ public function mergeCellBehaviour(Cell $cell, string $upperLeft, string $behavi * * @return $this */ - public function mergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2, $behaviour = self::MERGE_CELL_CONTENT_EMPTY) + public function mergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2, $behaviour = self::MERGE_CELL_CONTENT_EMPTY): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2066,7 +2041,7 @@ public function mergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $r * * @return $this */ - public function unmergeCells($range) + public function unmergeCells($range): static { $range = Functions::trimSheetFromCellReference(Validations::validateCellRange($range)); @@ -2099,7 +2074,7 @@ public function unmergeCells($range) * * @return $this */ - public function unmergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2) + public function unmergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2127,7 +2102,7 @@ public function getMergeCells() * * @return $this */ - public function setMergeCells(array $mergeCells) + public function setMergeCells(array $mergeCells): static { $this->mergeCells = $mergeCells; @@ -2145,7 +2120,7 @@ public function setMergeCells(array $mergeCells) * * @return $this */ - public function protectCells($range, $password, $alreadyHashed = false) + public function protectCells($range, $password, $alreadyHashed = false): static { $range = Functions::trimSheetFromCellReference(Validations::validateCellOrCellRange($range)); @@ -2175,7 +2150,7 @@ public function protectCells($range, $password, $alreadyHashed = false) * * @return $this */ - public function protectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2, $password, $alreadyHashed = false) + public function protectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2, $password, $alreadyHashed = false): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2194,7 +2169,7 @@ public function protectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, * * @return $this */ - public function unprotectCells($range) + public function unprotectCells($range): static { $range = Functions::trimSheetFromCellReference(Validations::validateCellOrCellRange($range)); @@ -2223,7 +2198,7 @@ public function unprotectCells($range) * * @return $this */ - public function unprotectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2) + public function unprotectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2263,7 +2238,7 @@ public function getAutoFilter() * * @return $this */ - public function setAutoFilter($autoFilterOrRange) + public function setAutoFilter($autoFilterOrRange): static { if (is_object($autoFilterOrRange) && ($autoFilterOrRange instanceof AutoFilter)) { $this->autoFilter = $autoFilterOrRange; @@ -2292,7 +2267,7 @@ public function setAutoFilter($autoFilterOrRange) * * @return $this */ - public function setAutoFilterByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2) + public function setAutoFilterByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2442,7 +2417,7 @@ public function getFreezePane() * * @return $this */ - public function freezePane($coordinate, $topLeftCell = null, bool $frozenSplit = false) + public function freezePane($coordinate, $topLeftCell = null, bool $frozenSplit = false): static { $this->panes = [ 'bottomRight' => null, @@ -2511,7 +2486,7 @@ public function setTopLeftCell(string $topLeftCell): self * * @return $this */ - public function freezePaneByColumnAndRow($columnIndex, $row) + public function freezePaneByColumnAndRow($columnIndex, $row): static { return $this->freezePane(Coordinate::stringFromColumnIndex($columnIndex) . $row); } @@ -2521,7 +2496,7 @@ public function freezePaneByColumnAndRow($columnIndex, $row) * * @return $this */ - public function unfreezePane() + public function unfreezePane(): static { return $this->freezePane(null); } @@ -2646,7 +2621,7 @@ public function setPaneState(string $paneState): self * * @return $this */ - public function insertNewRowBefore(int $before, int $numberOfRows = 1) + public function insertNewRowBefore(int $before, int $numberOfRows = 1): static { if ($before >= 1) { $objReferenceHelper = ReferenceHelper::getInstance(); @@ -2666,7 +2641,7 @@ public function insertNewRowBefore(int $before, int $numberOfRows = 1) * * @return $this */ - public function insertNewColumnBefore(string $before, int $numberOfColumns = 1) + public function insertNewColumnBefore(string $before, int $numberOfColumns = 1): static { if (!is_numeric($before)) { $objReferenceHelper = ReferenceHelper::getInstance(); @@ -2686,7 +2661,7 @@ public function insertNewColumnBefore(string $before, int $numberOfColumns = 1) * * @return $this */ - public function insertNewColumnBeforeByIndex(int $beforeColumnIndex, int $numberOfColumns = 1) + public function insertNewColumnBeforeByIndex(int $beforeColumnIndex, int $numberOfColumns = 1): static { if ($beforeColumnIndex >= 1) { return $this->insertNewColumnBefore(Coordinate::stringFromColumnIndex($beforeColumnIndex), $numberOfColumns); @@ -2703,7 +2678,7 @@ public function insertNewColumnBeforeByIndex(int $beforeColumnIndex, int $number * * @return $this */ - public function removeRow(int $row, int $numberOfRows = 1) + public function removeRow(int $row, int $numberOfRows = 1): static { if ($row < 1) { throw new Exception('Rows to be deleted should at least start from row 1.'); @@ -2759,7 +2734,7 @@ private function removeRowDimensions(int $row, int $numberOfRows): array * * @return $this */ - public function removeColumn(string $column, int $numberOfColumns = 1) + public function removeColumn(string $column, int $numberOfColumns = 1): static { if (is_numeric($column)) { throw new Exception('Column references should not be numeric.'); @@ -2821,7 +2796,7 @@ private function removeColumnDimensions(int $pColumnIndex, int $numberOfColumns) * * @return $this */ - public function removeColumnByIndex(int $columnIndex, int $numColumns = 1) + public function removeColumnByIndex(int $columnIndex, int $numColumns = 1): static { if ($columnIndex >= 1) { return $this->removeColumn(Coordinate::stringFromColumnIndex($columnIndex), $numColumns); @@ -3064,7 +3039,7 @@ public function getSelectedCells() * * @return $this */ - public function setSelectedCell($coordinate) + public function setSelectedCell($coordinate): static { return $this->setSelectedCells($coordinate); } @@ -3078,7 +3053,7 @@ public function setSelectedCell($coordinate) * * @return $this */ - public function setSelectedCells($coordinate) + public function setSelectedCells($coordinate): static { if (is_string($coordinate)) { $coordinate = Validations::definedNameToCoordinate($coordinate, $this); @@ -3129,7 +3104,7 @@ private function setSelectedCellsActivePane(): void * * @return $this */ - public function setSelectedCellByColumnAndRow($columnIndex, $row) + public function setSelectedCellByColumnAndRow($columnIndex, $row): static { return $this->setSelectedCells(Coordinate::stringFromColumnIndex($columnIndex) . $row); } @@ -3151,7 +3126,7 @@ public function getRightToLeft() * * @return $this */ - public function setRightToLeft($value) + public function setRightToLeft($value): static { $this->rightToLeft = $value; @@ -3168,7 +3143,7 @@ public function setRightToLeft($value) * * @return $this */ - public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $strictNullComparison = false) + public function fromArray(array $source, $nullValue = null, $startCell = 'A1', $strictNullComparison = false): static { // Convert a 1-D array to 2-D (for ease of looping) if (!is_array(end($source))) { @@ -3278,7 +3253,7 @@ public function rangeToArray( $columnRef = $returnCellRef ? $col : ++$c; // Using getCell() will create a new cell if it doesn't already exist. We don't want that to happen // so we test and retrieve directly against cellCollection - $cell = $this->cellCollection->get("{$col}{$row}"); + $cell = $this->getCellCollection()->get("{$col}{$row}"); $returnValue[$rowRef][$columnRef] = $nullValue; if ($cell !== null) { $returnValue[$rowRef][$columnRef] = $this->cellToArray($cell, $calculateFormulas, $formatData, $nullValue); @@ -3393,10 +3368,8 @@ public function toArray( * * @param int $startRow The row number at which to start iterating * @param int $endRow The row number at which to stop iterating - * - * @return RowIterator */ - public function getRowIterator($startRow = 1, $endRow = null) + public function getRowIterator($startRow = 1, $endRow = null): RowIterator { return new RowIterator($this, $startRow, $endRow); } @@ -3406,10 +3379,8 @@ public function getRowIterator($startRow = 1, $endRow = null) * * @param string $startColumn The column address at which to start iterating * @param string $endColumn The column address at which to stop iterating - * - * @return ColumnIterator */ - public function getColumnIterator($startColumn = 'A', $endColumn = null) + public function getColumnIterator($startColumn = 'A', $endColumn = null): ColumnIterator { return new ColumnIterator($this, $startColumn, $endColumn); } @@ -3419,13 +3390,13 @@ public function getColumnIterator($startColumn = 'A', $endColumn = null) * * @return $this */ - public function garbageCollect() + public function garbageCollect(): static { // Flush cache - $this->cellCollection->get('A1'); + $this->getCellCollection()->get('A1'); // Lookup highest column and highest row if cells are cleaned - $colRow = $this->cellCollection->getHighestRowAndColumn(); + $colRow = $this->getCellCollection()->getHighestRowAndColumn(); $highestRow = $colRow['row']; $highestColumn = Coordinate::columnIndexFromString($colRow['column']); @@ -3479,9 +3450,9 @@ public function getHashCode() * @param string $range Range to extract title from * @param bool $returnRange Return range? (see example) * - * @return mixed + * @return ($range is non-empty-string ? ($returnRange is true ? array{0: string, 1: string} : string) : ($returnRange is true ? array{0: null, 1: null} : null)) */ - public static function extractSheetTitle($range, $returnRange = false) + public static function extractSheetTitle($range, $returnRange = false): array|null|string { if (empty($range)) { return $returnRange ? [null, null] : null; @@ -3526,7 +3497,7 @@ public function getHyperlink($cellCoordinate) * * @return $this */ - public function setHyperlink($cellCoordinate, ?Hyperlink $hyperlink = null) + public function setHyperlink($cellCoordinate, ?Hyperlink $hyperlink = null): static { if ($hyperlink === null) { unset($this->hyperlinkCollection[$cellCoordinate]); @@ -3541,10 +3512,8 @@ public function setHyperlink($cellCoordinate, ?Hyperlink $hyperlink = null) * Hyperlink at a specific coordinate exists? * * @param string $coordinate eg: 'A1' - * - * @return bool */ - public function hyperlinkExists($coordinate) + public function hyperlinkExists($coordinate): bool { return isset($this->hyperlinkCollection[$coordinate]); } @@ -3586,7 +3555,7 @@ public function getDataValidation($cellCoordinate) * * @return $this */ - public function setDataValidation($cellCoordinate, ?DataValidation $dataValidation = null) + public function setDataValidation($cellCoordinate, ?DataValidation $dataValidation = null): static { if ($dataValidation === null) { unset($this->dataValidationCollection[$cellCoordinate]); @@ -3601,10 +3570,8 @@ public function setDataValidation($cellCoordinate, ?DataValidation $dataValidati * Data validation at a specific coordinate exists? * * @param string $coordinate eg: 'A1' - * - * @return bool */ - public function dataValidationExists($coordinate) + public function dataValidationExists($coordinate): bool { return isset($this->dataValidationCollection[$coordinate]); } @@ -3626,7 +3593,7 @@ public function getDataValidationCollection() * * @return string Adjusted range value */ - public function shrinkRangeToFit($range) + public function shrinkRangeToFit($range): string { $maxCol = $this->getHighestColumn(); $maxRow = $this->getHighestRow(); @@ -3674,7 +3641,7 @@ public function getTabColor() * * @return $this */ - public function resetTabColor() + public function resetTabColor(): static { $this->tabColor = null; @@ -3683,20 +3650,16 @@ public function resetTabColor() /** * Tab color set? - * - * @return bool */ - public function isTabColorSet() + public function isTabColorSet(): bool { return $this->tabColor !== null; } /** * Copy worksheet (!= clone!). - * - * @return static */ - public function copy() + public function copy(): static { return clone $this; } @@ -3774,7 +3737,7 @@ public function __clone() if (is_object($val) || (is_array($val))) { if ($key == 'cellCollection') { - $newCollection = $this->cellCollection->cloneCellCollection($this); + $newCollection = $this->getCellCollection()->cloneCellCollection($this); $this->cellCollection = $newCollection; } elseif ($key == 'drawingCollection') { $currentCollection = $this->drawingCollection; @@ -3806,7 +3769,7 @@ public function __clone() * * @return $this */ - public function setCodeName($codeName, $validate = true) + public function setCodeName($codeName, $validate = true): static { // Is this a 'rename' or not? if ($this->getCodeName() == $codeName) { @@ -3866,10 +3829,8 @@ public function getCodeName() /** * Sheet has a code name ? - * - * @return bool */ - public function hasCodeName() + public function hasCodeName(): bool { return $this->codeName !== null; } diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index 8f0ceda358..1099ffbc56 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -9,24 +9,18 @@ class Csv extends BaseWriter { /** * PhpSpreadsheet object. - * - * @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; /** * Delimiter. - * - * @var string */ - private $delimiter = ','; + private string $delimiter = ','; /** * Enclosure. - * - * @var string */ - private $enclosure = '"'; + private string $enclosure = '"'; /** * Line ending. @@ -66,10 +60,8 @@ class Csv extends BaseWriter /** * Output encoding. - * - * @var string */ - private $outputEncoding = ''; + private string $outputEncoding = ''; /** * Create a new CSV. diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 9e1df0dc16..22af8bcdf8 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -33,10 +33,8 @@ class Html extends BaseWriter { /** * Spreadsheet object. - * - * @var Spreadsheet */ - protected $spreadsheet; + protected Spreadsheet $spreadsheet; /** * Sheet index to write. @@ -89,10 +87,8 @@ class Html extends BaseWriter /** * Default font. - * - * @var Font */ - private $defaultFont; + private Font $defaultFont; /** * Flag whether spans have been calculated. @@ -237,10 +233,8 @@ public function setEditHtmlCallback(?callable $callback): void * Map VAlign. * * @param string $vAlign Vertical alignment - * - * @return string */ - private function mapVAlign($vAlign) + private function mapVAlign($vAlign): string { return Alignment::VERTICAL_ALIGNMENT_FOR_HTML[$vAlign] ?? ''; } @@ -249,10 +243,8 @@ private function mapVAlign($vAlign) * Map HAlign. * * @param string $hAlign Horizontal alignment - * - * @return string */ - private function mapHAlign($hAlign) + private function mapHAlign($hAlign): string { return Alignment::HORIZONTAL_ALIGNMENT_FOR_HTML[$hAlign] ?? ''; } @@ -276,10 +268,8 @@ private function mapHAlign($hAlign) * Map border style. * * @param int|string $borderStyle Sheet index - * - * @return string */ - private function mapBorderStyle($borderStyle) + private function mapBorderStyle($borderStyle): string { return array_key_exists($borderStyle, self::BORDER_ARR) ? self::BORDER_ARR[$borderStyle] : '1px solid'; } @@ -299,7 +289,7 @@ public function getSheetIndex(): ?int * * @return $this */ - public function setSheetIndex($sheetIndex) + public function setSheetIndex($sheetIndex): static { $this->sheetIndex = $sheetIndex; @@ -323,7 +313,7 @@ public function getGenerateSheetNavigationBlock() * * @return $this */ - public function setGenerateSheetNavigationBlock($generateSheetNavigationBlock) + public function setGenerateSheetNavigationBlock($generateSheetNavigationBlock): static { $this->generateSheetNavigationBlock = (bool) $generateSheetNavigationBlock; @@ -335,7 +325,7 @@ public function setGenerateSheetNavigationBlock($generateSheetNavigationBlock) * * @return $this */ - public function writeAllSheets() + public function writeAllSheets(): static { $this->sheetIndex = null; @@ -363,10 +353,8 @@ private static function generateMeta(?string $val, string $desc): string * Generate HTML header. * * @param bool $includeStyles Include styles? - * - * @return string */ - public function generateHTMLHeader($includeStyles = false) + public function generateHTMLHeader($includeStyles = false): string { // Construct HTML $properties = $this->spreadsheet->getProperties(); @@ -474,10 +462,8 @@ private function generateSheetTags(int $row, int $theadStart, int $theadEnd, int /** * Generate sheet data. - * - * @return string */ - public function generateSheetData() + public function generateSheetData(): string { $sheets = $this->generateSheetPrep(); @@ -541,10 +527,8 @@ public function generateSheetData() /** * Generate sheet tabs. - * - * @return string */ - public function generateNavigation() + public function generateNavigation(): string { // Fetch sheets $sheets = []; @@ -581,10 +565,8 @@ public function generateNavigation() * Chart/32_Chart_read_write_PDF.php. * * @param int $row Row to check for charts - * - * @return array */ - private function extendRowsForCharts(Worksheet $worksheet, int $row) + private function extendRowsForCharts(Worksheet $worksheet, int $row): array { $rowMax = $row; $colMax = 'A'; @@ -674,10 +656,8 @@ public static function winFileToUrl($filename, bool $mpdf = false) * * @param Worksheet $worksheet \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet * @param string $coordinates Cell coordinates - * - * @return string */ - private function writeImageInCell(Worksheet $worksheet, $coordinates) + private function writeImageInCell(Worksheet $worksheet, string $coordinates): string { // Construct HTML $html = ''; @@ -794,10 +774,8 @@ private function writeChartInCell(Worksheet $worksheet, string $coordinates): st * Generate CSS styles. * * @param bool $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>) - * - * @return string */ - public function generateStyles($generateSurroundingHTML = true) + public function generateStyles($generateSurroundingHTML = true): string { // Build CSS $css = $this->buildCSS($generateSurroundingHTML); @@ -1002,10 +980,8 @@ public function buildCSS($generateSurroundingHTML = true) /** * Create CSS style. - * - * @return array */ - private function createCSSStyle(Style $style) + private function createCSSStyle(Style $style): array { // Create CSS return array_merge( @@ -1018,10 +994,8 @@ private function createCSSStyle(Style $style) /** * Create CSS style. - * - * @return array */ - private function createCSSStyleAlignment(Alignment $alignment) + private function createCSSStyleAlignment(Alignment $alignment): array { // Construct CSS $css = []; @@ -1052,10 +1026,8 @@ private function createCSSStyleAlignment(Alignment $alignment) /** * Create CSS style. - * - * @return array */ - private function createCSSStyleFont(Font $font) + private function createCSSStyleFont(Font $font): array { // Construct CSS $css = []; @@ -1086,10 +1058,8 @@ private function createCSSStyleFont(Font $font) * Create CSS style. * * @param Borders $borders Borders - * - * @return array */ - private function createCSSStyleBorders(Borders $borders) + private function createCSSStyleBorders(Borders $borders): array { // Construct CSS $css = []; @@ -1190,7 +1160,7 @@ private function generateTableTag(Worksheet $worksheet, string $id, string &$htm * * @return string */ - private function generateTableHeader(Worksheet $worksheet, $showid = true) + private function generateTableHeader(Worksheet $worksheet, bool $showid = true) { $sheetIndex = $worksheet->getParentOrThrow()->getIndex($worksheet); @@ -1234,10 +1204,8 @@ private function generateTableFooter(): string * * @param int $sheetIndex Sheet index (0-based) * @param int $row row number - * - * @return string */ - private function generateRowStart(Worksheet $worksheet, $sheetIndex, $row) + private function generateRowStart(Worksheet $worksheet, $sheetIndex, int $row): string { $html = ''; if (count($worksheet->getBreaks()) > 0) { @@ -1492,10 +1460,8 @@ private function generateRowWriteCell(string &$html, Worksheet $worksheet, strin * @param array $values Array containing cells in a row * @param int $row Row number (0-based) * @param string $cellType eg: 'td' - * - * @return string */ - private function generateRow(Worksheet $worksheet, array $values, $row, $cellType) + private function generateRow(Worksheet $worksheet, array $values, int $row, string $cellType): string { // Sheet index $sheetIndex = $worksheet->getParentOrThrow()->getIndex($worksheet); @@ -1552,10 +1518,8 @@ private function generateRow(Worksheet $worksheet, array $values, $row, $cellTyp /** * Takes array where of CSS properties / values and converts to CSS string. - * - * @return string */ - private function assembleCSS(array $values = []) + private function assembleCSS(array $values = []): string { $pairs = []; foreach ($values as $property => $value) { @@ -1583,7 +1547,7 @@ public function getImagesRoot() * * @return $this */ - public function setImagesRoot($imagesRoot) + public function setImagesRoot($imagesRoot): static { $this->imagesRoot = $imagesRoot; @@ -1607,7 +1571,7 @@ public function getEmbedImages() * * @return $this */ - public function setEmbedImages($embedImages) + public function setEmbedImages($embedImages): static { $this->embedImages = $embedImages; @@ -1631,7 +1595,7 @@ public function getUseInlineCss() * * @return $this */ - public function setUseInlineCss($useInlineCss) + public function setUseInlineCss($useInlineCss): static { $this->useInlineCss = $useInlineCss; @@ -1663,7 +1627,7 @@ public function getUseEmbeddedCSS() * * @deprecated no longer used */ - public function setUseEmbeddedCSS($useEmbeddedCSS) + public function setUseEmbeddedCSS($useEmbeddedCSS): static { $this->useEmbeddedCSS = $useEmbeddedCSS; @@ -1675,10 +1639,8 @@ public function setUseEmbeddedCSS($useEmbeddedCSS) * * @param string $value Plain formatted value without color * @param string $format Format code - * - * @return string */ - public function formatColor($value, $format) + public function formatColor($value, $format): string { // Color information, e.g. [Red] is always at the beginning $color = null; // initialize @@ -1803,12 +1765,8 @@ private function calculateSpansOmitRows(Worksheet $sheet, int $sheetIndex, array * Write a comment in the same format as LibreOffice. * * @see https://github.com/LibreOffice/core/blob/9fc9bf3240f8c62ad7859947ab8a033ac1fe93fa/sc/source/filter/html/htmlexp.cxx#L1073-L1092 - * - * @param string $coordinate - * - * @return string */ - private function writeComment(Worksheet $worksheet, $coordinate) + private function writeComment(Worksheet $worksheet, string $coordinate): string { $result = ''; if (!$this->isPdf && isset($worksheet->getComments()[$coordinate])) { @@ -1836,12 +1794,8 @@ public function getOrientation(): ?string /** * Generate @page declarations. - * - * @param bool $generateSurroundingHTML - * - * @return string */ - private function generatePageDeclarations($generateSurroundingHTML) + private function generatePageDeclarations(bool $generateSurroundingHTML): string { // Ensure that Spans have been calculated? $this->calculateSpans(); diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index c9e0ba839f..37e02563e8 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -23,40 +23,19 @@ class Ods extends BaseWriter */ private $spreadSheet; - /** - * @var Content - */ - private $writerPartContent; + private Content $writerPartContent; - /** - * @var Meta - */ - private $writerPartMeta; + private Meta $writerPartMeta; - /** - * @var MetaInf - */ - private $writerPartMetaInf; + private MetaInf $writerPartMetaInf; - /** - * @var Mimetype - */ - private $writerPartMimetype; + private Mimetype $writerPartMimetype; - /** - * @var Settings - */ - private $writerPartSettings; + private Settings $writerPartSettings; - /** - * @var Styles - */ - private $writerPartStyles; + private Styles $writerPartStyles; - /** - * @var Thumbnails - */ - private $writerPartThumbnails; + private Thumbnails $writerPartThumbnails; /** * Create a new Ods. @@ -146,10 +125,8 @@ public function save($filename, int $flags = 0): void /** * Create zip object. - * - * @return ZipStream */ - private function createZip() + private function createZip(): ZipStream { // Try opening the ZIP file if (!is_resource($this->fileHandle)) { @@ -177,7 +154,7 @@ public function getSpreadsheet() * * @return $this */ - public function setSpreadsheet(Spreadsheet $spreadsheet) + public function setSpreadsheet(Spreadsheet $spreadsheet): static { $this->spreadSheet = $spreadsheet; diff --git a/src/PhpSpreadsheet/Writer/Ods/AutoFilters.php b/src/PhpSpreadsheet/Writer/Ods/AutoFilters.php index 996ec1a545..2debda89d2 100644 --- a/src/PhpSpreadsheet/Writer/Ods/AutoFilters.php +++ b/src/PhpSpreadsheet/Writer/Ods/AutoFilters.php @@ -9,15 +9,9 @@ class AutoFilters { - /** - * @var XMLWriter - */ - private $objWriter; + private XMLWriter $objWriter; - /** - * @var Spreadsheet - */ - private $spreadsheet; + private Spreadsheet $spreadsheet; public function __construct(XMLWriter $objWriter, Spreadsheet $spreadsheet) { diff --git a/src/PhpSpreadsheet/Writer/Ods/Cell/Style.php b/src/PhpSpreadsheet/Writer/Ods/Cell/Style.php index 4d46a5e140..0fee9a9648 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Cell/Style.php +++ b/src/PhpSpreadsheet/Writer/Ods/Cell/Style.php @@ -19,8 +19,7 @@ class Style public const ROW_STYLE_PREFIX = 'ro'; public const TABLE_STYLE_PREFIX = 'ta'; - /** @var XMLWriter */ - private $writer; + private XMLWriter $writer; public function __construct(XMLWriter $writer) { diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index 3a5cdbd7a7..de452107d5 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -22,8 +22,7 @@ class Content extends WriterPart const NUMBER_COLS_REPEATED_MAX = 1024; const NUMBER_ROWS_REPEATED_MAX = 1048576; - /** @var Formula */ - private $formulaConvertor; + private Formula $formulaConvertor; /** * Set parent Ods writer. @@ -194,7 +193,7 @@ private function writeCells(XMLWriter $objWriter, RowCellIterator $cells): void $numberColsRepeated = self::NUMBER_COLS_REPEATED_MAX; $prevColumn = -1; foreach ($cells as $cell) { - /** @var \PhpOffice\PhpSpreadsheet\Cell\Cell $cell */ + /** @var Cell $cell */ $column = Coordinate::columnIndexFromString($cell->getColumn()) - 1; $this->writeCellSpan($objWriter, $column, $prevColumn); @@ -289,11 +288,8 @@ private function writeCells(XMLWriter $objWriter, RowCellIterator $cells): void /** * Write span. - * - * @param int $curColumn - * @param int $prevColumn */ - private function writeCellSpan(XMLWriter $objWriter, $curColumn, $prevColumn): void + private function writeCellSpan(XMLWriter $objWriter, int $curColumn, int $prevColumn): void { $diff = $curColumn - $prevColumn - 1; if (1 === $diff) { diff --git a/src/PhpSpreadsheet/Writer/Ods/NamedExpressions.php b/src/PhpSpreadsheet/Writer/Ods/NamedExpressions.php index e309dab117..6cc5e7555d 100644 --- a/src/PhpSpreadsheet/Writer/Ods/NamedExpressions.php +++ b/src/PhpSpreadsheet/Writer/Ods/NamedExpressions.php @@ -10,14 +10,11 @@ class NamedExpressions { - /** @var XMLWriter */ - private $objWriter; + private XMLWriter $objWriter; - /** @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; - /** @var Formula */ - private $formulaConvertor; + private Formula $formulaConvertor; public function __construct(XMLWriter $objWriter, Spreadsheet $spreadsheet, Formula $formulaConvertor) { diff --git a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php index 17d5d16931..67b0f6b717 100644 --- a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php @@ -8,10 +8,8 @@ abstract class WriterPart { /** * Parent Ods object. - * - * @var Ods */ - private $parentWriter; + private Ods $parentWriter; /** * Get Ods writer. diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index 493bbba3e5..e74bb8f38a 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -11,10 +11,8 @@ abstract class Pdf extends Html { /** * Temporary storage directory. - * - * @var string */ - protected $tempDir = ''; + protected string $tempDir; /** * Font. @@ -25,10 +23,8 @@ abstract class Pdf extends Html /** * Orientation (Over-ride). - * - * @var ?string */ - protected $orientation; + protected ?string $orientation = null; /** * Paper size (Over-ride). diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index d781483eb0..3e9e94ebeb 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -91,10 +91,8 @@ public function save($filename, int $flags = 0): void * Convert inches to mm. * * @param float $inches - * - * @return float */ - private function inchesToMm($inches) + private function inchesToMm($inches): float { return $inches * 25.4; } diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 25533a3105..d18a44059b 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -31,10 +31,8 @@ class Xls extends BaseWriter { /** * PhpSpreadsheet object. - * - * @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; /** * Total number of shared strings in workbook. @@ -66,10 +64,8 @@ class Xls extends BaseWriter /** * Formula parser. - * - * @var Parser */ - private $parser; + private Parser $parser; /** * Identifier clusters for drawings. Used in MSODRAWINGGROUP record. @@ -571,10 +567,8 @@ private function buildWorkbookEscher(): void /** * Build the OLE Part for DocumentSummary Information. - * - * @return string */ - private function writeDocumentSummaryInformation() + private function writeDocumentSummaryInformation(): string { // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) $data = pack('v', 0xFFFE); @@ -812,10 +806,8 @@ private function writeSummaryProp(string $dataProp, int &$dataSection_NumProps, /** * Build the OLE Part for Summary Information. - * - * @return string */ - private function writeSummaryInformation() + private function writeSummaryInformation(): string { // offset: 0; size: 2; must be 0xFE 0xFF (UTF-16 LE byte order mark) $data = pack('v', 0xFFFE); diff --git a/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php b/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php index 0f78b8c5df..0ef7e9a367 100644 --- a/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php +++ b/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php @@ -9,10 +9,8 @@ class ConditionalHelper { /** * Formula parser. - * - * @var Parser */ - protected $parser; + protected Parser $parser; /** * @var mixed @@ -24,15 +22,9 @@ class ConditionalHelper */ protected $cellRange; - /** - * @var null|string - */ - protected $tokens; + protected ?string $tokens = null; - /** - * @var int - */ - protected $size; + protected int $size; public function __construct(Parser $parser) { diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index 1923200dbd..e3b7923a48 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -8,17 +8,13 @@ class Font { /** * Color index. - * - * @var int */ - private $colorIndex; + private int $colorIndex; /** * Font. - * - * @var \PhpOffice\PhpSpreadsheet\Style\Font */ - private $font; + private \PhpOffice\PhpSpreadsheet\Style\Font $font; /** * Constructor. @@ -44,10 +40,8 @@ public function setColorIndex($colorIndex): void /** * Get font record data. - * - * @return string */ - public function writeFont() + public function writeFont(): string { $font_outline = self::$notImplemented; $font_shadow = self::$notImplemented; diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index f195ac782b..dd7d585e00 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -63,10 +63,8 @@ class Parser /** * The formula to parse. - * - * @var string */ - private $formula; + private string $formula; /** * The character ahead of the current char. @@ -84,10 +82,8 @@ class Parser /** * Array of external sheets. - * - * @var array */ - private $externalSheets; + private array $externalSheets; /** * Array of sheet references in the form of REF structures. @@ -469,8 +465,7 @@ class Parser 'BAHTTEXT' => [368, 1, 0, 0], ]; - /** @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; /** * The class constructor. @@ -491,11 +486,11 @@ public function __construct(Spreadsheet $spreadsheet) /** * Convert a token to the proper ptg value. * - * @param mixed $token the token to convert + * @param string $token the token to convert * - * @return mixed the converted token on success + * @return string the converted token on success */ - private function convert($token) + private function convert(string $token): string { if (preg_match('/"([^"]|""){0,255}"/', $token)) { return $this->convertString($token); @@ -562,10 +557,8 @@ private function convert($token) * Convert a number token to ptgInt or ptgNum. * * @param mixed $num an integer or double for conversion to its ptg value - * - * @return string */ - private function convertNumber($num) + private function convertNumber($num): string { // Integer in the range 0..2**16-1 if ((preg_match('/^\\d+$/', $num)) && ($num <= 65535)) { @@ -590,9 +583,9 @@ private function convertBool(int $num): string * * @param string $string a string for conversion to its ptg value * - * @return mixed the converted token on success + * @return string the converted token */ - private function convertString($string) + private function convertString($string): string { // chop away beggining and ending quotes $string = substr($string, 1, -1); @@ -612,7 +605,7 @@ private function convertString($string) * * @return string The packed ptg for the function */ - private function convertFunction($token, $num_args) + private function convertFunction($token, $num_args): string { $args = $this->functions[$token][1]; @@ -630,10 +623,8 @@ private function convertFunction($token, $num_args) * * @param string $range An Excel range in the A1:A2 * @param int $class - * - * @return string */ - private function convertRange2d($range, $class = 0) + private function convertRange2d($range, $class = 0): string { // TODO: possible class value 0,1,2 check Formula.pm // Split the range into 2 cell refs @@ -668,18 +659,18 @@ private function convertRange2d($range, $class = 0) * * @param string $token an Excel range in the Sheet1!A1:A2 format * - * @return mixed the packed ptgArea3d token on success + * @return string the packed ptgArea3d token on success */ - private function convertRange3d($token) + private function convertRange3d($token): string { // Split the ref at the ! symbol [$ext_ref, $range] = PhpspreadsheetWorksheet::extractSheetTitle($token, true); // Convert the external reference part (different for BIFF8) - $ext_ref = $this->getRefIndex($ext_ref); + $ext_ref = $this->getRefIndex($ext_ref ?? ''); // Split the range into 2 cell refs - [$cell1, $cell2] = explode(':', $range); + [$cell1, $cell2] = explode(':', $range ?? ''); // Convert the cell references if (preg_match('/^(\$)?[A-Ia-i]?[A-Za-z](\$)?(\\d+)$/', $cell1)) { @@ -702,7 +693,7 @@ private function convertRange3d($token) * * @return string The cell in packed() format with the corresponding ptg */ - private function convertRef2d($cell) + private function convertRef2d($cell): string { // Convert the cell reference $cell_array = $this->cellToPackedRowcol($cell); @@ -720,18 +711,18 @@ private function convertRef2d($cell) * * @param string $cell An Excel cell reference * - * @return mixed the packed ptgRef3d token on success + * @return string the packed ptgRef3d token on success */ - private function convertRef3d($cell) + private function convertRef3d($cell): string { // Split the ref at the ! symbol [$ext_ref, $cell] = PhpspreadsheetWorksheet::extractSheetTitle($cell, true); // Convert the external reference part (different for BIFF8) - $ext_ref = $this->getRefIndex($ext_ref); + $ext_ref = $this->getRefIndex($ext_ref ?? ''); // Convert the cell reference part - [$row, $col] = $this->cellToPackedRowcol($cell); + [$row, $col] = $this->cellToPackedRowcol($cell ?? ''); // The ptg value depends on the class of the ptg. $ptgRef = pack('C', $this->ptg['ptgRef3dA']); @@ -746,7 +737,7 @@ private function convertRef3d($cell) * * @return string The error code ptgErr */ - private function convertError($errorCode) + private function convertError($errorCode): string { switch ($errorCode) { case '#NULL!': @@ -803,9 +794,9 @@ private function convertDefinedName(string $name): string * * @param string $ext_ref The name of the external reference * - * @return mixed The reference index in packed() format on success + * @return string The reference index in packed() format on success */ - private function getRefIndex($ext_ref) + private function getRefIndex($ext_ref): string { $ext_ref = (string) preg_replace(["/^'/", "/'$/"], ['', ''], $ext_ref); // Remove leading and trailing ' if any. $ext_ref = str_replace('\'\'', '\'', $ext_ref); // Replace escaped '' with ' @@ -865,7 +856,7 @@ private function getRefIndex($ext_ref) * * @return int The sheet index, -1 if the sheet was not found */ - private function getSheetIndex($sheet_name) + private function getSheetIndex(string $sheet_name) { if (!isset($this->externalSheets[$sheet_name])) { return -1; @@ -882,7 +873,7 @@ private function getSheetIndex($sheet_name) * @param string $name The name of the worksheet being added * @param int $index The index of the worksheet being added * - * @see \PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook::addWorksheet() + * @see Workbook::addWorksheet */ public function setExtSheet($name, $index): void { @@ -896,7 +887,7 @@ public function setExtSheet($name, $index): void * * @return array Array containing the row and column in packed() format */ - private function cellToPackedRowcol($cell) + private function cellToPackedRowcol($cell): array { $cell = strtoupper($cell); [$row, $col, $row_rel, $col_rel] = $this->cellToRowcol($cell); @@ -925,7 +916,7 @@ private function cellToPackedRowcol($cell) * * @return array Array containing (row1,col1,row2,col2) in packed() format */ - private function rangeToPackedRange($range) + private function rangeToPackedRange(string $range): array { preg_match('/(\$)?(\d+)\:(\$)?(\d+)/', $range, $match); // return absolute rows if there is a $ in the ref @@ -963,10 +954,8 @@ private function rangeToPackedRange($range) * whether the row or column are relative references. * * @param string $cell the Excel cell reference in A1 format - * - * @return array */ - private function cellToRowcol($cell) + private function cellToRowcol(string $cell): array { preg_match('/(\$)?([A-I]?[A-Z])(\$)?(\d+)/', $cell, $match); // return absolute column if there is a $ in the ref @@ -1034,17 +1023,16 @@ private function advance(): void } ++$i; } - //die("Lexical error ".$this->currentCharacter); } /** * Checks if it's a valid token. * - * @param mixed $token the token to check + * @param string $token the token to check * - * @return mixed The checked token or false on failure + * @return string The checked token or empty string on failure */ - private function match($token) + private function match(string $token): string { switch ($token) { case '+': @@ -1144,9 +1132,9 @@ private function match($token) * @param string $formula the formula to parse, without the initial equal * sign (=) * - * @return mixed true on success + * @return bool true on success */ - public function parse($formula) + public function parse($formula): bool { $this->currentCharacter = 0; $this->formula = (string) $formula; @@ -1273,7 +1261,7 @@ private function expression() * * @see fact() */ - private function parenthesizedExpression() + private function parenthesizedExpression(): array { return $this->createTree('ptgParen', $this->expression(), ''); } @@ -1461,7 +1449,7 @@ private function func() * * @return array A tree */ - private function createTree($value, $left, $right) + private function createTree($value, $left, $right): array { return ['value' => $value, 'left' => $left, 'right' => $right]; } @@ -1493,7 +1481,7 @@ private function createTree($value, $left, $right) * * @return string The tree in reverse polish notation */ - public function toReversePolish($tree = []) + public function toReversePolish($tree = []): string { $polish = ''; // the string we are going to return if (empty($tree)) { // If it's the first call use parseTree diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index 3c68847aa9..329279f16e 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -49,24 +49,20 @@ class Workbook extends BIFFwriter { /** * Formula parser. - * - * @var \PhpOffice\PhpSpreadsheet\Writer\Xls\Parser */ - private $parser; + private Parser $parser; /** * The BIFF file size for the workbook. Not currently used. * - * @var int - * * @see calcSheetOffsets() */ - private $biffSize; // @phpstan-ignore-line + private int $biffSize; // @phpstan-ignore-line /** * XF Writers. * - * @var \PhpOffice\PhpSpreadsheet\Writer\Xls\Xf[] + * @var Xf[] */ private $xfWriters = []; @@ -79,24 +75,18 @@ class Workbook extends BIFFwriter /** * The codepage indicates the text encoding used for strings. - * - * @var int */ - private $codepage; + private int $codepage; /** * The country code used for localization. - * - * @var int */ - private $countryCode; + private int $countryCode; /** * Workbook. - * - * @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; /** * Fonts writers. @@ -170,10 +160,8 @@ class Workbook extends BIFFwriter /** * Escher object corresponding to MSODRAWINGGROUP. - * - * @var null|\PhpOffice\PhpSpreadsheet\Shared\Escher */ - private $escher; + private ?\PhpOffice\PhpSpreadsheet\Shared\Escher $escher = null; /** @var mixed */ private static $scrutinizerFalse = false; @@ -233,7 +221,7 @@ public function __construct(Spreadsheet $spreadsheet, &$str_total, &$str_unique, * * @return int Index to XF record */ - public function addXfWriter(Style $style, $isStyleXf = false) + public function addXfWriter(Style $style, $isStyleXf = false): int { $xfWriter = new Xf($style); $xfWriter->setIsStyleXf($isStyleXf); @@ -417,7 +405,7 @@ private function setPaletteXl97(): void * * @return string Binary data for workbook stream */ - public function writeWorkbook(array $worksheetSizes) + public function writeWorkbook(array $worksheetSizes): string { $this->worksheetSizes = $worksheetSizes; @@ -731,7 +719,7 @@ private function writeAllDefinedNamesBiff8(): string * * @return string Complete binary record data */ - private function writeDefinedNameBiff8($name, $formulaData, $sheetIndex = 0, $isBuiltIn = false) + private function writeDefinedNameBiff8($name, string $formulaData, int $sheetIndex = 0, bool $isBuiltIn = false): string { $record = 0x0018; @@ -760,14 +748,12 @@ private function writeDefinedNameBiff8($name, $formulaData, $sheetIndex = 0, $is /** * Write a short NAME record. * - * @param string $name * @param int $sheetIndex 1-based sheet index the defined name applies to. 0 = global * @param int[][] $rangeBounds range boundaries - * @param bool $isHidden * * @return string Complete binary record data * */ - private function writeShortNameBiff8($name, $sheetIndex, $rangeBounds, $isHidden = false) + private function writeShortNameBiff8(string $name, int $sheetIndex, array $rangeBounds, bool $isHidden = false): string { $record = 0x0018; @@ -941,7 +927,7 @@ private function writeStyle(): void * @param string $format Custom format string * @param int $ifmt Format index code */ - private function writeNumberFormat($format, $ifmt): void + private function writeNumberFormat(string $format, $ifmt): void { $record = 0x041E; // Record identifier @@ -1042,7 +1028,7 @@ private function writePalette(): void * * @return string Binary data */ - private function writeSharedStringsTable() + private function writeSharedStringsTable(): string { // maximum size of record data (excluding record header) $continue_limit = 8224; diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index aeedd08e77..c2aedbbab1 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -12,7 +12,6 @@ use PhpOffice\PhpSpreadsheet\Shared\StringHelper; use PhpOffice\PhpSpreadsheet\Shared\Xls; use PhpOffice\PhpSpreadsheet\Style\Border; -use PhpOffice\PhpSpreadsheet\Style\Color; use PhpOffice\PhpSpreadsheet\Style\Conditional; use PhpOffice\PhpSpreadsheet\Style\Protection; use PhpOffice\PhpSpreadsheet\Worksheet\PageSetup; @@ -63,10 +62,8 @@ class Worksheet extends BIFFwriter /** * Formula parser. - * - * @var \PhpOffice\PhpSpreadsheet\Writer\Xls\Parser */ - private $parser; + private Parser $parser; /** * Array containing format information for columns. @@ -77,40 +74,30 @@ class Worksheet extends BIFFwriter /** * The active pane for the worksheet. - * - * @var int */ - private $activePane; + private int $activePane; /** * Whether to use outline. - * - * @var bool */ - private $outlineOn; + private bool $outlineOn; /** * Auto outline styles. - * - * @var bool */ - private $outlineStyle; + private bool $outlineStyle; /** * Whether to have outline summary below. * Not currently used. - * - * @var bool */ - private $outlineBelow; //* @phpstan-ignore-line + private bool $outlineBelow; //* @phpstan-ignore-line /** * Whether to have outline summary at the right. * Not currently used. - * - * @var bool */ - private $outlineRight; //* @phpstan-ignore-line + private bool $outlineRight; //* @phpstan-ignore-line /** * Reference to the total number of strings in the workbook. @@ -142,31 +129,23 @@ class Worksheet extends BIFFwriter /** * Index of first used row (at least 0). - * - * @var int */ - private $firstRowIndex; + private int $firstRowIndex; /** * Index of last used row. (no used rows means -1). - * - * @var int */ - private $lastRowIndex; + private int $lastRowIndex; /** * Index of first used column (at least 0). - * - * @var int */ - private $firstColumnIndex; + private int $firstColumnIndex; /** * Index of last used column (no used columns means -1). - * - * @var int */ - private $lastColumnIndex; + private int $lastColumnIndex; /** * Sheet object. @@ -177,10 +156,8 @@ class Worksheet extends BIFFwriter /** * Escher object corresponding to MSODRAWING. - * - * @var null|\PhpOffice\PhpSpreadsheet\Shared\Escher */ - private $escher; + private ?\PhpOffice\PhpSpreadsheet\Shared\Escher $escher = null; /** * Array of font hashes associated to FONT records index. @@ -194,10 +171,7 @@ class Worksheet extends BIFFwriter */ private $preCalculateFormulas; - /** - * @var int - */ - private $printHeaders; + private int $printHeaders; /** * Constructor. @@ -259,7 +233,7 @@ public function __construct(&$str_total, &$str_unique, &$str_table, &$colors, Pa * Add data to the beginning of the workbook (note the reverse order) * and to the end of the workbook. * - * @see \PhpOffice\PhpSpreadsheet\Writer\Xls\Workbook::storeWorkbook() + * @see Workbook::storeWorkbook */ public function close(): void { @@ -584,7 +558,7 @@ private function writeConditionalFormatting(): void * * @return string Binary data */ - private function writeBIFF8CellRangeAddressFixed($range) + private function writeBIFF8CellRangeAddressFixed($range): string { $explodes = explode(':', $range); @@ -662,11 +636,9 @@ public function setOutline($visible = true, $symbols_below = true, $symbols_righ * @param int $row Zero indexed row * @param int $col Zero indexed column * @param float $num The number to write - * @param mixed $xfIndex The optional XF format - * - * @return int + * @param int $xfIndex The optional XF format */ - private function writeNumber($row, $col, $num, $xfIndex) + private function writeNumber(int $row, int $col, $num, int $xfIndex): int { $record = 0x0203; // Record identifier $length = 0x000E; // Number of bytes to follow @@ -691,7 +663,7 @@ private function writeNumber($row, $col, $num, $xfIndex) * @param string $str The string * @param int $xfIndex Index to XF record */ - private function writeString($row, $col, $str, $xfIndex): void + private function writeString(int $row, int $col, $str, int $xfIndex): void { $this->writeLabelSst($row, $col, $str, $xfIndex); } @@ -706,7 +678,7 @@ private function writeString($row, $col, $str, $xfIndex): void * @param int $xfIndex The XF format index for the cell * @param array $arrcRun Index to Font record and characters beginning */ - private function writeRichTextString($row, $col, $str, $xfIndex, $arrcRun): void + private function writeRichTextString(int $row, int $col, string $str, int $xfIndex, array $arrcRun): void { $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow @@ -731,9 +703,9 @@ private function writeRichTextString($row, $col, $str, $xfIndex, $arrcRun): void * @param int $row Zero indexed row * @param int $col Zero indexed column * @param string $str The string to write - * @param mixed $xfIndex The XF format index for the cell + * @param int $xfIndex The XF format index for the cell */ - private function writeLabelSst($row, $col, $str, $xfIndex): void + private function writeLabelSst(int $row, int $col, $str, int $xfIndex): void { $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow @@ -765,11 +737,9 @@ private function writeLabelSst($row, $col, $str, $xfIndex): void * * @param int $row Zero indexed row * @param int $col Zero indexed column - * @param mixed $xfIndex The XF format index - * - * @return int + * @param int $xfIndex The XF format index */ - public function writeBlank($row, $col, $xfIndex) + public function writeBlank($row, $col, $xfIndex): int { $record = 0x0201; // Record identifier $length = 0x0006; // Number of bytes to follow @@ -788,11 +758,8 @@ public function writeBlank($row, $col, $xfIndex) * @param int $col Column index (0-based) * @param int $value * @param int $isError Error or Boolean? - * @param int $xfIndex - * - * @return int */ - private function writeBoolErr($row, $col, $value, $isError, $xfIndex) + private function writeBoolErr(int $row, int $col, $value, int $isError, int $xfIndex): int { $record = 0x0205; $length = 8; @@ -835,12 +802,12 @@ public static function getAllowThrow(): bool * @param int $row Zero indexed row * @param int $col Zero indexed column * @param string $formula The formula text string - * @param mixed $xfIndex The XF format index + * @param int $xfIndex The XF format index * @param mixed $calculatedValue Calculated value * * @return int */ - private function writeFormula($row, $col, $formula, $xfIndex, $calculatedValue) + private function writeFormula(int $row, int $col, string $formula, int $xfIndex, $calculatedValue) { $record = 0x0006; // Record identifier // Initialize possible additional value for STRING record that should be written after the FORMULA record? @@ -922,10 +889,8 @@ private function writeFormula($row, $col, $formula, $xfIndex, $calculatedValue) /** * Write a STRING record. This. - * - * @param string $stringValue */ - private function writeStringRecord($stringValue): void + private function writeStringRecord(string $stringValue): void { $record = 0x0207; // Record identifier $data = StringHelper::UTF8toBIFF8UnicodeLong($stringValue); @@ -951,7 +916,7 @@ private function writeStringRecord($stringValue): void * @param int $col Column * @param string $url URL string */ - private function writeUrl($row, $col, $url): void + private function writeUrl(int $row, int $col, $url): void { // Add start row and col to arg list $this->writeUrlRange($row, $col, $row, $col, $url); @@ -971,7 +936,7 @@ private function writeUrl($row, $col, $url): void * * @see writeUrl() */ - private function writeUrlRange($row1, $col1, $row2, $col2, $url): void + private function writeUrlRange(int $row1, int $col1, int $row2, int $col2, $url): void { // Check for internal/external sheet links or default to web link if (preg_match('[^internal:]', $url)) { @@ -1039,7 +1004,7 @@ public function writeUrlWeb($row1, $col1, $row2, $col2, $url): void * * @see writeUrl() */ - private function writeUrlInternal($row1, $col1, $row2, $col2, $url): void + private function writeUrlInternal(int $row1, int $col1, int $row2, int $col2, $url): void { $record = 0x01B8; // Record identifier @@ -1087,7 +1052,7 @@ private function writeUrlInternal($row1, $col1, $row2, $col2, $url): void * * @see writeUrl() */ - private function writeUrlExternal($row1, $col1, $row2, $col2, $url): void + private function writeUrlExternal(int $row1, int $col1, int $row2, int $col2, $url): void { // Network drives are different. We will handle them separately // MS/Novell network drives and shares start with \\ @@ -1178,7 +1143,7 @@ private function writeUrlExternal($row1, $col1, $row2, $col2, $url): void * @param bool $hidden The optional hidden attribute * @param int $level The optional outline level for row, in range [0,7] */ - private function writeRow($row, $height, $xfIndex, $hidden = false, $level = 0): void + private function writeRow(int $row, int $height, int $xfIndex, bool $hidden = false, $level = 0): void { $record = 0x0208; // Record identifier $length = 0x0010; // Number of bytes to follow @@ -2184,17 +2149,17 @@ private function writePassword(): void * * @param int $row The row we are going to insert the bitmap into * @param int $col The column we are going to insert the bitmap into - * @param mixed $bitmap The bitmap filename or GD-image resource + * @param GdImage|string $bitmap The bitmap filename or GD-image resource * @param int $x the horizontal position (offset) of the image inside the cell * @param int $y the vertical position (offset) of the image inside the cell * @param float $scale_x The horizontal scale * @param float $scale_y The vertical scale */ - public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1): void + public function insertBitmap($row, $col, GdImage|string $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1): void { - $bitmap_array = (is_resource($bitmap) || $bitmap instanceof GdImage + $bitmap_array = $bitmap instanceof GdImage ? $this->processBitmapGd($bitmap) - : $this->processBitmap($bitmap)); + : $this->processBitmap($bitmap); [$width, $height, $size, $data] = $bitmap_array; // Scale the frame of the image. @@ -2332,7 +2297,7 @@ public function positionImage($col_start, $row_start, $x1, $y1, $width, $height) * @param int $rwB Row containing bottom right corner of object * @param int $dyB Distance from bottom of cell */ - private function writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dyB): void + private function writeObjPicture(int $colL, int $dxL, int $rwT, int|float $dyT, int $colR, int $dxR, int $rwB, int $dyB): void { $record = 0x005d; // Record identifier $length = 0x003c; // Bytes to follow @@ -2400,11 +2365,11 @@ private function writeObjPicture($colL, $dxL, $rwT, $dyT, $colR, $dxR, $rwB, $dy /** * Convert a GD-image into the internal format. * - * @param GdImage|resource $image The image to process + * @param GdImage $image The image to process * * @return array Array with data and properties of the bitmap */ - public function processBitmapGd($image) + public function processBitmapGd(GdImage $image): array { $width = imagesx($image); $height = imagesy($image); @@ -2438,7 +2403,7 @@ public function processBitmapGd($image) * * @return array Array with data and properties of the bitmap */ - public function processBitmap($bitmap) + public function processBitmap($bitmap): array { // Open file. $bmp_fd = @fopen($bitmap, 'rb'); diff --git a/src/PhpSpreadsheet/Writer/Xls/Xf.php b/src/PhpSpreadsheet/Writer/Xls/Xf.php index 7ac26665cb..3560031883 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -48,85 +48,58 @@ class Xf { /** * Style XF or a cell XF ? - * - * @var bool */ - private $isStyleXf; + private bool $isStyleXf; /** * Index to the FONT record. Index 4 does not exist. - * - * @var int */ - private $fontIndex; + private int $fontIndex; /** * An index (2 bytes) to a FORMAT record (number format). - * - * @var int */ - private $numberFormatIndex; + private int $numberFormatIndex; /** * 1 bit, apparently not used. - * - * @var int */ - private $textJustLast; + private int $textJustLast; /** * The cell's foreground color. - * - * @var int */ - private $foregroundColor; + private int $foregroundColor; /** * The cell's background color. - * - * @var int */ - private $backgroundColor; + private int $backgroundColor; /** * Color of the bottom border of the cell. - * - * @var int */ - private $bottomBorderColor; + private int $bottomBorderColor; /** * Color of the top border of the cell. - * - * @var int */ - private $topBorderColor; + private int $topBorderColor; /** * Color of the left border of the cell. - * - * @var int */ - private $leftBorderColor; + private int $leftBorderColor; /** * Color of the right border of the cell. - * - * @var int */ - private $rightBorderColor; + private int $rightBorderColor; //private $diag; // theoretically int, not yet implemented + private int $diagColor; - /** - * @var int - */ - private $diagColor; - - /** - * @var Style - */ - private $style; + private Style $style; /** * Constructor. @@ -160,7 +133,7 @@ public function __construct(Style $style) * * @return string The XF record */ - public function writeXf() + public function writeXf(): string { // Set the type of the XF record and some of the attributes. if ($this->isStyleXf) { @@ -386,13 +359,11 @@ private static function mapTextRotation($textRotation) /** * Map locked values. * - * @param string $locked - * - * @return int + * @param ?string $locked */ - private static function mapLocked($locked) + private static function mapLocked($locked): int { - return array_key_exists($locked, self::LOCK_ARRAY) ? self::LOCK_ARRAY[$locked] : 1; + return $locked !== null && array_key_exists($locked, self::LOCK_ARRAY) ? self::LOCK_ARRAY[$locked] : 1; } private const HIDDEN_ARRAY = [ @@ -404,12 +375,10 @@ private static function mapLocked($locked) /** * Map hidden. * - * @param string $hidden - * - * @return int + * @param ?string $hidden */ - private static function mapHidden($hidden) + private static function mapHidden($hidden): int { - return array_key_exists($hidden, self::HIDDEN_ARRAY) ? self::HIDDEN_ARRAY[$hidden] : 0; + return $hidden !== null && array_key_exists($hidden, self::HIDDEN_ARRAY) ? self::HIDDEN_ARRAY[$hidden] : 0; } } diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 6ed12d4aa1..e49cb8d76e 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -61,49 +61,49 @@ class Xlsx extends BaseWriter * * @var HashTable */ - private $stylesConditionalHashTable; + private HashTable $stylesConditionalHashTable; /** * Private unique Style HashTable. * * @var HashTable<\PhpOffice\PhpSpreadsheet\Style\Style> */ - private $styleHashTable; + private HashTable $styleHashTable; /** * Private unique Fill HashTable. * * @var HashTable */ - private $fillHashTable; + private HashTable $fillHashTable; /** * Private unique \PhpOffice\PhpSpreadsheet\Style\Font HashTable. * * @var HashTable */ - private $fontHashTable; + private HashTable $fontHashTable; /** * Private unique Borders HashTable. * * @var HashTable */ - private $bordersHashTable; + private HashTable $bordersHashTable; /** * Private unique NumberFormat HashTable. * * @var HashTable */ - private $numFmtHashTable; + private HashTable $numFmtHashTable; /** * Private unique \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet\BaseDrawing HashTable. * * @var HashTable */ - private $drawingHashTable; + private HashTable $drawingHashTable; /** * Private handle for zip stream. @@ -112,75 +112,33 @@ class Xlsx extends BaseWriter */ private $zip; - /** - * @var Chart - */ - private $writerPartChart; + private Chart $writerPartChart; - /** - * @var Comments - */ - private $writerPartComments; + private Comments $writerPartComments; - /** - * @var ContentTypes - */ - private $writerPartContentTypes; + private ContentTypes $writerPartContentTypes; - /** - * @var DocProps - */ - private $writerPartDocProps; + private DocProps $writerPartDocProps; - /** - * @var Drawing - */ - private $writerPartDrawing; + private Drawing $writerPartDrawing; - /** - * @var Rels - */ - private $writerPartRels; + private Rels $writerPartRels; - /** - * @var RelsRibbon - */ - private $writerPartRelsRibbon; + private RelsRibbon $writerPartRelsRibbon; - /** - * @var RelsVBA - */ - private $writerPartRelsVBA; + private RelsVBA $writerPartRelsVBA; - /** - * @var StringTable - */ - private $writerPartStringTable; + private StringTable $writerPartStringTable; - /** - * @var Style - */ - private $writerPartStyle; + private Style $writerPartStyle; - /** - * @var Theme - */ - private $writerPartTheme; + private Theme $writerPartTheme; - /** - * @var Table - */ - private $writerPartTable; + private Table $writerPartTable; - /** - * @var Workbook - */ - private $writerPartWorkbook; + private Workbook $writerPartWorkbook; - /** - * @var Worksheet - */ - private $writerPartWorksheet; + private Worksheet $writerPartWorksheet; /** * Create a new Xlsx Writer. @@ -576,7 +534,7 @@ public function getSpreadsheet() * * @return $this */ - public function setSpreadsheet(Spreadsheet $spreadsheet) + public function setSpreadsheet(Spreadsheet $spreadsheet): static { $this->spreadSheet = $spreadsheet; @@ -680,7 +638,7 @@ public function getOffice2003Compatibility() * * @return $this */ - public function setOffice2003Compatibility($office2003compatibility) + public function setOffice2003Compatibility($office2003compatibility): static { $this->office2003compatibility = $office2003compatibility; @@ -705,10 +663,7 @@ private function addZipFiles(array $zipContent): void } } - /** - * @return mixed - */ - private function processDrawing(WorksheetDrawing $drawing) + private function processDrawing(WorksheetDrawing $drawing): string|null|false { $data = null; $filename = $drawing->getPath(); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 6d302aac4a..b4733dc43b 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -506,11 +506,9 @@ private function writeDataLabels(XMLWriter $objWriter, ?Layout $chartLayout = nu /** * Write Category Axis. * - * @param string $id1 - * @param string $id2 * @param bool $isMultiLevelSeries */ - private function writeCategoryAxis(XMLWriter $objWriter, ?Title $xAxisLabel, $id1, $id2, $isMultiLevelSeries, Axis $yAxis): void + private function writeCategoryAxis(XMLWriter $objWriter, ?Title $xAxisLabel, string $id1, string $id2, $isMultiLevelSeries, Axis $yAxis): void { // N.B. writeCategoryAxis may be invoked with the last parameter($yAxis) using $xAxis for ScatterChart, etc // In that case, xAxis may contain values like the yAxis, or it may be a date axis (LINECHART). @@ -726,11 +724,9 @@ private function writeCategoryAxis(XMLWriter $objWriter, ?Title $xAxisLabel, $id * Write Value Axis. * * @param null|string $groupType Chart type - * @param string $id1 - * @param string $id2 * @param bool $isMultiLevelSeries */ - private function writeValueAxis(XMLWriter $objWriter, ?Title $yAxisLabel, $groupType, $id1, $id2, $isMultiLevelSeries, Axis $xAxis): void + private function writeValueAxis(XMLWriter $objWriter, ?Title $yAxisLabel, $groupType, string $id1, string $id2, $isMultiLevelSeries, Axis $xAxis): void { $objWriter->startElement('c:' . Axis::AXIS_TYPE_VALUE); $majorGridlines = $xAxis->getMajorGridlines(); @@ -1368,7 +1364,7 @@ private function writePlotSeriesLabel(?DataSeriesValues $plotSeriesLabel, XMLWri * @param string $groupType Type of plot for dataseries * @param string $dataType Datatype of series values */ - private function writePlotSeriesValues(?DataSeriesValues $plotSeriesValues, XMLWriter $objWriter, $groupType, $dataType = 'str'): void + private function writePlotSeriesValues(?DataSeriesValues $plotSeriesValues, XMLWriter $objWriter, string $groupType, string $dataType = 'str'): void { if ($plotSeriesValues === null) { return; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index 91973884cb..f2b118b7c5 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -161,7 +161,7 @@ public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $ * @param string $cellReference Cell reference, eg: 'A1' * @param Comment $comment Comment */ - private function writeVMLComment(XMLWriter $objWriter, $cellReference, Comment $comment): void + private function writeVMLComment(XMLWriter $objWriter, string $cellReference, Comment $comment): void { // Metadata [$column, $row] = Coordinate::indexesFromString($cellReference); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index d399fa5b94..8faa3ffc2d 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -217,7 +217,7 @@ public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = fal * * @return string Mime Type */ - private function getImageMimeType($filename) + private function getImageMimeType($filename): string { if (File::fileExists($filename)) { $image = getimagesize($filename); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/DefinedNames.php b/src/PhpSpreadsheet/Writer/Xlsx/DefinedNames.php index f83280c5a3..54f5af4ad2 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/DefinedNames.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/DefinedNames.php @@ -12,11 +12,9 @@ class DefinedNames { - /** @var XMLWriter */ - private $objWriter; + private XMLWriter $objWriter; - /** @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; public function __construct(XMLWriter $objWriter, Spreadsheet $spreadsheet) { @@ -114,7 +112,7 @@ private function writeNamedRangeForAutofilter(ActualWorksheet $worksheet, int $w // Strip any worksheet ref so we can make the cell ref absolute [, $range[0]] = ActualWorksheet::extractSheetTitle($range[0], true); - $range[0] = Coordinate::absoluteCoordinate($range[0]); + $range[0] = Coordinate::absoluteCoordinate($range[0] ?? ''); if (count($range) > 1) { $range[1] = Coordinate::absoluteCoordinate($range[1]); } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index 5a5775882c..6763b508f2 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -501,7 +501,7 @@ public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet\W * * @param string $reference Reference */ - private function writeVMLHeaderFooterImage(XMLWriter $objWriter, $reference, HeaderFooterDrawing $image): void + private function writeVMLHeaderFooterImage(XMLWriter $objWriter, string $reference, HeaderFooterDrawing $image): void { // Calculate object id preg_match('{(\d+)}', md5($reference), $m); @@ -540,7 +540,7 @@ private function writeVMLHeaderFooterImage(XMLWriter $objWriter, $reference, Hea * * @return BaseDrawing[] All drawings in PhpSpreadsheet */ - public function allDrawings(Spreadsheet $spreadsheet) + public function allDrawings(Spreadsheet $spreadsheet): array { // Get an array of all drawings $aDrawings = []; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index 70146a5002..1e288d3788 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -459,7 +459,7 @@ public function writeVMLDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet * @param string $target Relationship target * @param string $targetMode Relationship target mode */ - private function writeRelationship(XMLWriter $objWriter, $id, $type, $target, $targetMode = ''): void + private function writeRelationship(XMLWriter $objWriter, $id, string $type, $target, string $targetMode = ''): void { if ($type != '' && $target != '') { // Write relationship diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 29e95eb2fe..016c4a74df 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -21,7 +21,7 @@ class StringTable extends WriterPart * * @return string[] String table for worksheet */ - public function createStringTable(ActualWorksheet $worksheet, $existingTable = null) + public function createStringTable(ActualWorksheet $worksheet, $existingTable = null): array { // Create string lookup table $aStringTable = []; @@ -205,7 +205,7 @@ public function writeRichText(XMLWriter $objWriter, RichText $richText, $prefix * @param RichText|string $richText text string or Rich text * @param string $prefix Optional Namespace prefix */ - public function writeRichTextForCharts(XMLWriter $objWriter, $richText = null, $prefix = ''): void + public function writeRichTextForCharts(XMLWriter $objWriter, $richText = null, string $prefix = ''): void { if (!($richText instanceof RichText)) { $textRun = $richText; @@ -324,10 +324,8 @@ private function writeChartTextColor(XMLWriter $objWriter, ?ChartColor $underlin * Flip string table (for index searching). * * @param array $stringTable Stringtable - * - * @return array */ - public function flipStringTable(array $stringTable) + public function flipStringTable(array $stringTable): array { // Return value $returnValue = []; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index baafdc334d..fbded4d52f 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -567,7 +567,7 @@ private function writeCellStyleDxf(XMLWriter $objWriter, \PhpOffice\PhpSpreadshe * * @param string $name Element name */ - private function writeBorderPr(XMLWriter $objWriter, $name, Border $border): void + private function writeBorderPr(XMLWriter $objWriter, string $name, Border $border): void { // Write BorderPr if ($border->getBorderStyle() === Border::BORDER_OMIT) { @@ -592,7 +592,7 @@ private function writeBorderPr(XMLWriter $objWriter, $name, Border $border): voi * * @param int $id Number Format identifier */ - private function writeNumFmt(XMLWriter $objWriter, ?NumberFormat $numberFormat, $id = 0): void + private function writeNumFmt(XMLWriter $objWriter, ?NumberFormat $numberFormat, int $id = 0): void { // Translate formatcode $formatCode = ($numberFormat === null) ? null : $numberFormat->getFormatCode(); @@ -621,7 +621,7 @@ public function allStyles(Spreadsheet $spreadsheet) * * @return Conditional[] All conditional styles in PhpSpreadsheet */ - public function allConditionalStyles(Spreadsheet $spreadsheet) + public function allConditionalStyles(Spreadsheet $spreadsheet): array { // Get an array of all styles $aStyles = []; @@ -673,7 +673,7 @@ public function allFills(Spreadsheet $spreadsheet) * * @return Font[] All fonts in PhpSpreadsheet */ - public function allFonts(Spreadsheet $spreadsheet) + public function allFonts(Spreadsheet $spreadsheet): array { // Get an array of unique fonts $aFonts = []; @@ -694,7 +694,7 @@ public function allFonts(Spreadsheet $spreadsheet) * * @return Borders[] All borders in PhpSpreadsheet */ - public function allBorders(Spreadsheet $spreadsheet) + public function allBorders(Spreadsheet $spreadsheet): array { // Get an array of unique borders $aBorders = []; @@ -715,7 +715,7 @@ public function allBorders(Spreadsheet $spreadsheet) * * @return NumberFormat[] All number formats in PhpSpreadsheet */ - public function allNumberFormats(Spreadsheet $spreadsheet) + public function allNumberFormats(Spreadsheet $spreadsheet): array { // Get an array of unique number formats $aNumFmts = []; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index f2a8678219..971771f6e1 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -195,7 +195,7 @@ private function writeSheets(XMLWriter $objWriter, Spreadsheet $spreadsheet): vo * @param int $relId Relationship ID * @param string $sheetState Sheet state (visible, hidden, veryHidden) */ - private function writeSheet(XMLWriter $objWriter, $worksheetName, $worksheetId = 1, $relId = 1, $sheetState = 'visible'): void + private function writeSheet(XMLWriter $objWriter, string $worksheetName, int $worksheetId = 1, $relId = 1, $sheetState = 'visible'): void { if ($worksheetName != '') { // Write sheet diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 0e72c5d123..e36b853147 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -39,7 +39,7 @@ class Worksheet extends WriterPart * * @return string XML Output */ - public function writeWorksheet(PhpspreadsheetWorksheet $worksheet, $stringTable = [], $includeCharts = false) + public function writeWorksheet(PhpspreadsheetWorksheet $worksheet, array $stringTable = [], $includeCharts = false) { $this->numberStoredAsText = ''; $this->formula = ''; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php index 0bfb356d83..9dbd904556 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php @@ -8,10 +8,8 @@ abstract class WriterPart { /** * Parent Xlsx object. - * - * @var Xlsx */ - private $parentWriter; + private Xlsx $parentWriter; /** * Get parent Xlsx object. diff --git a/tests/PhpSpreadsheetTests/A1LocaleGeneratorTest.php b/tests/PhpSpreadsheetTests/A1LocaleGeneratorTest.php index 64da066391..243705c36b 100644 --- a/tests/PhpSpreadsheetTests/A1LocaleGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/A1LocaleGeneratorTest.php @@ -1,5 +1,7 @@ _calculateFormulaValue($formula); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Calculation/ArrayTest.php b/tests/PhpSpreadsheetTests/Calculation/ArrayTest.php index 60c336cf18..77b5251a7a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/ArrayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/ArrayTest.php @@ -1,5 +1,7 @@ setLocale($locale)); diff --git a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php index 548e133e47..403ae86065 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CalculationTest.php @@ -1,5 +1,7 @@ _calculateFormulaValue($formula); @@ -358,9 +350,6 @@ public function testBranchPruningFormulaParsingInequalitiesConditionsCase(): voi } /** - * @param mixed $expectedResult - * @param mixed $dataArray - * @param string $formula * @param string $cellCoordinates where to put the formula * @param string[] $shouldBeSetInCacheCells coordinates of cells that must * be set in cache @@ -370,12 +359,12 @@ public function testBranchPruningFormulaParsingInequalitiesConditionsCase(): voi * @dataProvider dataProviderBranchPruningFullExecution */ public function testFullExecutionDataPruning( - $expectedResult, - $dataArray, - $formula, - $cellCoordinates, - $shouldBeSetInCacheCells = [], - $shouldNotBeSetInCacheCells = [] + mixed $expectedResult, + mixed $dataArray, + string $formula, + string $cellCoordinates, + array $shouldBeSetInCacheCells = [], + array $shouldNotBeSetInCacheCells = [] ): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/CyclicTest.php b/tests/PhpSpreadsheetTests/Calculation/CyclicTest.php index c754520bd0..2357c0bc92 100644 --- a/tests/PhpSpreadsheetTests/Calculation/CyclicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/CyclicTest.php @@ -1,5 +1,7 @@ spreadSheet->getActiveSheet(); $workSheet->setCellValue('H1', $formula); diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/StructuredReferenceSlashTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/StructuredReferenceSlashTest.php index 8b652999b6..bd94002f9c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Engine/StructuredReferenceSlashTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/StructuredReferenceSlashTest.php @@ -1,5 +1,7 @@ getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/FormulaParserTest.php b/tests/PhpSpreadsheetTests/Calculation/FormulaParserTest.php index a913333d9c..10ce2cd488 100644 --- a/tests/PhpSpreadsheetTests/Calculation/FormulaParserTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/FormulaParserTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DAVERAGE', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountATest.php index 0bbd0372af..6ddcfd6cbb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountATest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DCOUNTA', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountTest.php index a986e70048..ded350b937 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DCountTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DCOUNT', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DGetTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DGetTest.php index 24394c7d9a..0522616045 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DGetTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DGetTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DGET', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMaxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMaxTest.php index a4dc9f9e74..2689fa3cf3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMaxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMaxTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DMAX', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMinTest.php index c3257d2722..c1e553dc18 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DMinTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DMIN', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DProductTest.php index 6aca35b62c..57590ee253 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DProductTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DPRODUCT', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevPTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevPTest.php index 1c73535732..bb80b211bb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevPTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevPTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DSTDEVP', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevTest.php index 7698e73ec4..73eb7a4108 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DStDevTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DSTDEV', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DSumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DSumTest.php index 6f16c3e658..3589e89595 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DSumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DSumTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DSUM', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarPTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarPTest.php index 3e12fd0a6a..c880bb62e7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarPTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarPTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DVARP', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarTest.php index da8c31c3d8..7a0e923f99 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/DVarTest.php @@ -1,5 +1,7 @@ prepareWorksheetWithFormula('DVAR', $database, $field, $criteria); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/SetupTeardownDatabases.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/SetupTeardownDatabases.php index 9c79d9ae13..c280b6725b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/SetupTeardownDatabases.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/SetupTeardownDatabases.php @@ -1,5 +1,7 @@ sheet; } - /** - * @param int|string $field - */ - public function prepareWorksheetWithFormula(string $functionName, array $database, $field, array $criteria): void + public function prepareWorksheetWithFormula(string $functionName, array $database, null|int|string $field, array $criteria): void { $sheet = $this->getSheet(); $maxCol = ''; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php index d4218c4e91..260a563cf1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -1,5 +1,7 @@ returnDateType); } - private function expectationIsTemplate(string $expectedResult): bool + private function expectationIsTemplate(mixed $expectedResult): bool { return is_string($expectedResult) && substr($expectedResult, 0, 2) === 'Y-'; } @@ -57,10 +53,8 @@ private function parseTemplatedExpectation(string $expectedResult): string /** * @dataProvider providerDATEVALUE - * - * @param mixed $expectedResult */ - public function testDirectCallToDATEVALUE($expectedResult, ...$args): void + public function testDirectCallToDATEVALUE(mixed $expectedResult, mixed ...$args): void { if ($this->expectationIsTemplate($expectedResult)) { $expectedResult = $this->parseTemplatedExpectation($expectedResult); @@ -73,10 +67,8 @@ public function testDirectCallToDATEVALUE($expectedResult, ...$args): void /** * @dataProvider providerDATEVALUE - * - * @param mixed $expectedResult */ - public function testDATEVALUEAsFormula($expectedResult, ...$args): void + public function testDATEVALUEAsFormula(mixed $expectedResult, mixed ...$args): void { if ($this->expectationIsTemplate($expectedResult)) { $expectedResult = $this->parseTemplatedExpectation($expectedResult); @@ -93,10 +85,8 @@ public function testDATEVALUEAsFormula($expectedResult, ...$args): void /** * @dataProvider providerDATEVALUE - * - * @param mixed $expectedResult */ - public function testDATEVALUEInWorksheet($expectedResult, ...$args): void + public function testDATEVALUEInWorksheet(mixed $expectedResult, mixed ...$args): void { if ($this->expectationIsTemplate($expectedResult)) { $expectedResult = $this->parseTemplatedExpectation($expectedResult); @@ -134,7 +124,7 @@ public function testRefArgNull(): void /** * @dataProvider providerUnhappyDATEVALUE */ - public function testDATEVALUEUnhappyPath(string $expectedException, ...$args): void + public function testDATEVALUEUnhappyPath(string $expectedException, mixed ...$args): void { $arguments = new FormulaArguments(...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php index feeab4672f..6270ac0888 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DayTest.php @@ -1,5 +1,7 @@ format('Y'), DateParts::year($result)); self::assertEquals($dtStart->format('m'), DateParts::month($result)); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php index b74af2c481..f440ecaef7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/SecondTest.php @@ -1,5 +1,7 @@ format('Y'), DateParts::year($result)); self::assertEquals($dtStart->format('m'), DateParts::month($result)); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php index 90974215a0..cf487bfd0e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/WeekDayTest.php @@ -1,5 +1,7 @@ runTestCase('ACCRINTM', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php index af87ddaefd..97bd742df1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AccrintTest.php @@ -1,15 +1,15 @@ runTestCase('ACCRINT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AllSetupTeardown.php index 12fafa0b21..6fd236934b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AllSetupTeardown.php @@ -1,5 +1,7 @@ expectException(CalcException::class); } } - /** - * @param mixed $value - */ - protected function setCell(string $cell, $value): void + protected function setCell(string $cell, mixed $value): void { if ($value !== null) { if (is_string($value) && is_numeric($value)) { @@ -98,11 +91,8 @@ protected function getSheet(): Worksheet /** * Adjust result if it is close enough to expected by ratio * rather than offset. - * - * @param mixed $result - * @param mixed $expectedResult */ - protected function adjustResult(&$result, $expectedResult): void + protected function adjustResult(mixed &$result, mixed $expectedResult): void { if (is_numeric($result) && is_numeric($expectedResult)) { if ($expectedResult != 0) { @@ -114,10 +104,7 @@ protected function adjustResult(&$result, $expectedResult): void } } - /** - * @param mixed $expectedResult - */ - public function runTestCase(string $functionName, $expectedResult, array $args): void + public function runTestCase(string $functionName, mixed $expectedResult, array $args): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorDegRcTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorDegRcTest.php index 2798844427..459b7674ac 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorDegRcTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorDegRcTest.php @@ -1,15 +1,15 @@ runTestCase('AMORDEGRC', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorLincTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorLincTest.php index ddd7186430..95db9bc190 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorLincTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AmorLincTest.php @@ -1,15 +1,15 @@ runTestCase('AMORLINC', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDayBsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDayBsTest.php index 6423b7a469..15633fd8e0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDayBsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDayBsTest.php @@ -1,15 +1,15 @@ runTestCase('COUPDAYBS', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDaysNcTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDaysNcTest.php index 83e9dbbb93..7696f61f85 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDaysNcTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDaysNcTest.php @@ -1,15 +1,15 @@ runTestCase('COUPDAYSNC', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDaysTest.php index 2baed24299..f7ba0e7be0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupDaysTest.php @@ -1,15 +1,15 @@ runTestCase('COUPDAYS', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupNcdTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupNcdTest.php index 6fa58197f3..f3f04792f0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupNcdTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupNcdTest.php @@ -1,15 +1,15 @@ runTestCase('COUPNCD', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupNumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupNumTest.php index a4d962af0c..86360ecb33 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupNumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupNumTest.php @@ -1,15 +1,15 @@ runTestCase('COUPNUM', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupPcdTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupPcdTest.php index e7d460f7b6..8c02ea048c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupPcdTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CoupPcdTest.php @@ -1,15 +1,15 @@ runTestCase('COUPPCD', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumIpmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumIpmtTest.php index 26450faac0..a27724ab8b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumIpmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumIpmtTest.php @@ -1,15 +1,15 @@ runTestCase('CUMIPMT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumPrincTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumPrincTest.php index 2cc19fd695..b241c29406 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumPrincTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/CumPrincTest.php @@ -1,15 +1,15 @@ runTestCase('CUMPRINC', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DbTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DbTest.php index 2ac986e761..13856c048b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DbTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DbTest.php @@ -1,15 +1,15 @@ runTestCase('DB', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DdbTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DdbTest.php index b2ef69a92d..5e513ed646 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DdbTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DdbTest.php @@ -1,15 +1,15 @@ runTestCase('DDB', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DiscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DiscTest.php index d983ad0920..317854edc1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DiscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DiscTest.php @@ -1,15 +1,15 @@ runTestCase('DISC', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarDeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarDeTest.php index 56bb681a1e..c379377401 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarDeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarDeTest.php @@ -1,5 +1,7 @@ runTestCase('DOLLARDE', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php index adbbaea7a9..992b5a64eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/DollarFrTest.php @@ -1,15 +1,15 @@ runTestCase('DOLLARFR', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/EffectTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/EffectTest.php index 249a5f1124..4811c64c3c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/EffectTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/EffectTest.php @@ -1,15 +1,15 @@ runTestCase('EFFECT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvScheduleTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvScheduleTest.php index 9080a38ab2..bb72492f52 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvScheduleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvScheduleTest.php @@ -1,16 +1,15 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php index 5f221940c3..1dbfee1af2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/FvTest.php @@ -1,15 +1,15 @@ runTestCase('FV', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/HelpersTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/HelpersTest.php index ed132b7e27..6cceaf423d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/HelpersTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/HelpersTest.php @@ -1,5 +1,7 @@ runTestCase('IPMT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IntRateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IntRateTest.php index 9827182f5b..fc111f1cd7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IntRateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IntRateTest.php @@ -1,15 +1,15 @@ runTestCase('INTRATE', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IrrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IrrTest.php index 608d8d2616..08d09c5875 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IrrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IrrTest.php @@ -1,16 +1,15 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IsPmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IsPmtTest.php index cfb4a9efed..ea085fb50c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IsPmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/IsPmtTest.php @@ -1,15 +1,15 @@ runTestCase('ISPMT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MirrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MirrTest.php index c2412b8e00..d2a65dd068 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MirrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MirrTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MovedFunctionsTest.php index 4429c522c2..e23def8569 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MovedFunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MovedFunctionsTest.php @@ -1,5 +1,7 @@ runTestCase('NPER', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NominalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NominalTest.php index fd6f5710bc..302d5a0c17 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NominalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NominalTest.php @@ -1,15 +1,15 @@ runTestCase('NOMINAL', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NpvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NpvTest.php index ed3126ae57..c43d819bdc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NpvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/NpvTest.php @@ -1,15 +1,15 @@ runTestCase('NPV', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php index 475ac3bfb8..7c31158e14 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PDurationTest.php @@ -1,15 +1,15 @@ runTestCase('PDURATION', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php index 2868b9dc3a..ae3f6ea9fe 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PmtTest.php @@ -1,15 +1,15 @@ runTestCase('PMT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PpmtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PpmtTest.php index a373dab636..820d315d8c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PpmtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PpmtTest.php @@ -1,15 +1,15 @@ runTestCase('PPMT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceDiscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceDiscTest.php index ac6dca08d0..2abb6effbc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceDiscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceDiscTest.php @@ -1,15 +1,15 @@ runTestCase('PRICEDISC', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceMatTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceMatTest.php index 23a0633871..a30c196b83 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceMatTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceMatTest.php @@ -1,15 +1,15 @@ runTestCase('PRICEMAT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceTest.php index 43f5b10c84..56328f882a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PriceTest.php @@ -1,15 +1,15 @@ runTestCase('PRICE', $expectedResult, $args); } @@ -21,10 +21,8 @@ public static function providerPRICE(): array /** * @dataProvider providerPRICE3 - * - * @param mixed $expectedResult */ - public function testPRICE3($expectedResult, ...$args): void + public function testPRICE3(mixed $expectedResult, mixed ...$args): void { // These results (PRICE function with basis codes 2 and 3) // agree with published algorithm, LibreOffice, and Gnumeric. diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php index fdee2f9d55..ffdb1e25b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/PvTest.php @@ -1,15 +1,15 @@ runTestCase('PV', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RateTest.php index 4943aed0e4..f36437395e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RateTest.php @@ -1,15 +1,15 @@ runTestCase('RATE', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/ReceivedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/ReceivedTest.php index 648c62a6bd..d5ac3000b2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/ReceivedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/ReceivedTest.php @@ -1,15 +1,15 @@ runTestCase('RECEIVED', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php index 97175014ed..ccfd7587b3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/RriTest.php @@ -1,15 +1,15 @@ runTestCase('RRI', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SlnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SlnTest.php index acce9b3de9..abe5a7a9cf 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SlnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SlnTest.php @@ -1,15 +1,15 @@ runTestCase('SLN', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SydTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SydTest.php index 3cc228b45d..6b8561771c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SydTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/SydTest.php @@ -1,15 +1,15 @@ runTestCase('SYD', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillEqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillEqTest.php index bf19947859..d18aa52852 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillEqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillEqTest.php @@ -1,15 +1,15 @@ runTestCase('TBILLEQ', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillPriceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillPriceTest.php index 2beb00966d..c8778fc28b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillPriceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillPriceTest.php @@ -1,15 +1,15 @@ runTestCase('TBILLPRICE', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillYieldTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillYieldTest.php index bdfa5a5bb0..30d58c3277 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillYieldTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/TBillYieldTest.php @@ -1,15 +1,15 @@ runTestCase('TBILLYIELD', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php index 8eeb78fc9b..91714a169e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/UsDollarTest.php @@ -1,15 +1,15 @@ runTestCase('USDOLLAR', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XNpvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XNpvTest.php index a147d71d48..a94a9210d3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XNpvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XNpvTest.php @@ -1,18 +1,15 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XirrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XirrTest.php index d454de37be..d48bd1b610 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XirrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/XirrTest.php @@ -1,18 +1,15 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldDiscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldDiscTest.php index ec3d964191..32f8431747 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldDiscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldDiscTest.php @@ -1,15 +1,15 @@ runTestCase('YIELDDISC', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldMatTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldMatTest.php index 89f9b891ea..28c5540607 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldMatTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/YieldMatTest.php @@ -1,15 +1,15 @@ runTestCase('YIELDMAT', $expectedResult, $args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/FormulaArguments.php b/tests/PhpSpreadsheetTests/Calculation/Functions/FormulaArguments.php index eea1ac3dbd..d40cb1c436 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/FormulaArguments.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/FormulaArguments.php @@ -1,5 +1,7 @@ args = $args; } @@ -27,7 +26,7 @@ public function populateWorksheet(Worksheet $worksheet): string foreach ($this->args as $value) { if (is_array($value)) { // We need to set a matrix in the worksheet - $worksheet->fromArray($value, null, $cellAddress, true); + $worksheet->fromArray($value, null, (string) $cellAddress, true); $from = (string) $cellAddress; $columns = is_array($value[0]) ? count($value[0]) : count($value); $rows = is_array($value[0]) ? count($value) : 1; @@ -45,10 +44,7 @@ public function populateWorksheet(Worksheet $worksheet): string return implode(',', $cells); } - /** - * @param mixed $value - */ - private function matrixRows($value): string + private function matrixRows(array $value): string { $columns = []; foreach ($value as $column) { @@ -58,10 +54,7 @@ private function matrixRows($value): string return implode(',', $columns); } - /** - * @param mixed $value - */ - private function makeMatrix($value): string + private function makeMatrix(array $value): string { $matrix = []; foreach ($value as $row) { @@ -75,10 +68,7 @@ private function makeMatrix($value): string return implode(';', $matrix); } - /** - * @param mixed $value - */ - private function stringify($value): string + private function stringify(mixed $value): string { if (is_array($value)) { return '{' . $this->makeMatrix($value) . '}'; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/DeprecatedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/DeprecatedFunctionsTest.php index ca7c75d7d0..864faf58ab 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Information/DeprecatedFunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Information/DeprecatedFunctionsTest.php @@ -1,5 +1,7 @@ expectException(CalcException::class); } } - /** - * @param mixed $value - */ - protected function setCell(string $cell, $value): void + protected function setCell(string $cell, mixed $value): void { if ($value !== null) { if (is_string($value) && is_numeric($value)) { @@ -95,11 +88,7 @@ protected function getSheet(): Worksheet return $this->sheet; } - /** - * @param mixed $expectedResult - * @param array $args - */ - protected function runTestCase(string $functionName, $expectedResult, ...$args): void + protected function runTestCase(string $functionName, mixed $expectedResult, mixed ...$args): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php index b9ad5bbe11..c9dacefd2a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AndTest.php @@ -1,15 +1,15 @@ runTestCase('AND', $expectedResult, ...$args); } @@ -21,11 +21,8 @@ public static function providerAND(): array /** * @dataProvider providerANDLiteral - * - * @param mixed $expectedResult - * @param string $formula */ - public function testANDLiteral($expectedResult, $formula): void + public function testANDLiteral(mixed $expectedResult, mixed $formula): void { $sheet = $this->getSheet(); $sheet->getCell('A1')->setValue("=AND($formula)"); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/DeprecatedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/DeprecatedFunctionsTest.php index 11b1beaf9a..4d0c1a8144 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/DeprecatedFunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/DeprecatedFunctionsTest.php @@ -1,5 +1,7 @@ runTestCase('IFERROR', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php index eab9410386..a629bd7ab1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfNaTest.php @@ -1,5 +1,7 @@ runTestCase('IFNA', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php index 914f50fd75..fc631043ae 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfTest.php @@ -1,15 +1,15 @@ runTestCase('IF', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php index a1ca9a2658..eeb38b9a28 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/IfsTest.php @@ -1,5 +1,7 @@ runTestCase('IFS', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php index 0d408ff7f3..db53b38949 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/NotTest.php @@ -1,5 +1,7 @@ runTestCase('NOT', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php index 4b6368358e..6f369f5737 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/OrTest.php @@ -1,15 +1,15 @@ runTestCase('OR', $expectedResult, ...$args); } @@ -21,11 +21,8 @@ public static function providerOR(): array /** * @dataProvider providerORLiteral - * - * @param mixed $expectedResult - * @param string $formula */ - public function testORLiteral($expectedResult, $formula): void + public function testORLiteral(mixed $expectedResult, mixed $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 7b9c92df53..1ef186060f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/SwitchTest.php @@ -1,5 +1,7 @@ runTestCase('SWITCH', $expectedResult, ...$args); } @@ -23,12 +23,8 @@ public static function providerSwitch(): array /** * @dataProvider providerSwitchArray - * - * @param mixed $expression - * @param mixed $value1 - * @param mixed $value2 */ - public function testIfsArray(array $expectedResult, $expression, $value1, string $result1, $value2, string $result2, string $default): void + public function testIfsArray(array $expectedResult, mixed $expression, mixed $value1, string $result1, mixed $value2, string $result2, string $default): void { $calculation = Calculation::getInstance(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php index 5ce4517026..0c61e4390e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/TrueTest.php @@ -1,5 +1,7 @@ runTestCase('XOR', $expectedResult, ...$args); } @@ -21,11 +21,8 @@ public static function providerXOR(): array /** * @dataProvider providerXORLiteral - * - * @param mixed $expectedResult - * @param string $formula */ - public function xtestXORLiteral($expectedResult, $formula): void + public function xtestXORLiteral(mixed $expectedResult, string $formula): void { $sheet = $this->getSheet(); $sheet->getCell('A1')->setValue("=XOR($formula)"); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressInternationalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressInternationalTest.php index 3f2539d206..d7aa9101c6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressInternationalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AddressInternationalTest.php @@ -1,5 +1,7 @@ expectException(CalcException::class); } } - /** - * @param mixed $value - */ - protected function setCell(string $cell, $value): void + protected function setCell(string $cell, mixed $value): void { if ($value !== null) { if (is_string($value) && is_numeric($value)) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php index 76421f2527..7a495a5ca3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ChooseTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php index 75e7a4ed21..9b007b0a93 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php index c3bdad29e6..641119a9d7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/ColumnsTest.php @@ -1,5 +1,7 @@ getSheet(); $reference = 'A1'; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php index 57c7caf507..682a12e021 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HLookupTest.php @@ -1,5 +1,7 @@ getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HyperlinkTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HyperlinkTest.php index 6ebd05384a..5eaf7d35eb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/HyperlinkTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -42,10 +42,8 @@ public function testHYPERLINK($expectedResult, ?string $linkUrl, ?string $descri /** * @dataProvider providerHYPERLINK - * - * @param array|string $expectedResult */ - public function testHYPERLINKcellRef($expectedResult, ?string $linkUrl, ?string $description): void + public function testHYPERLINKcellRef(array|string $expectedResult, ?string $linkUrl, ?string $description): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexOnSpreadsheetTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexOnSpreadsheetTest.php index abae76d186..e893fc7f3f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexOnSpreadsheetTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexOnSpreadsheetTest.php @@ -1,17 +1,15 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php index 6d2ee6bad5..9b3f5de2ec 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndexTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -135,11 +133,9 @@ public function testDeprecatedCall(): void } /** - * @param null|int|string $expectedResult - * * @dataProvider providerRelative */ - public function testR1C1Relative($expectedResult, string $address): void + public function testR1C1Relative(string|int|null $expectedResult, string $address): void { $sheet = $this->getSheet(); $sheet->fromArray([ diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php index fbc593f107..7194fe3806 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/LookupTest.php @@ -1,5 +1,7 @@ setOpenOffice(); if (is_array($expectedResult)) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatrixHelperFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatrixHelperFunctionsTest.php index 60952babdd..62e3b03578 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatrixHelperFunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MatrixHelperFunctionsTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowTest.php index 48d6cf08c3..fbc4c12d6b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php index 74dcb9c6b8..11781aabc5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/RowsTest.php @@ -1,5 +1,7 @@ getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php index 411131713e..e16a05d77f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AbsTest.php @@ -1,5 +1,7 @@ getSheet(); $this->mightHaveException($expectedResult); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php index e945801787..8ba2e2a3a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcosTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php index b4bbacf0b3..98ca3353cc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcoshTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php index 326ec400d3..eabdd51154 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcotTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php index def904eac3..3935a32e98 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AcothTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AllSetupTeardown.php index f54ecaad9e..a73de31c0f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AllSetupTeardown.php @@ -1,5 +1,7 @@ expectException(CalcException::class); } } - /** - * @param mixed $value - */ - protected function setCell(string $cell, $value): void + protected function setCell(string $cell, mixed $value): void { if ($value !== null) { if (is_string($value) && is_numeric($value)) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php index 2c80a07e4a..d5fd394a73 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ArabicTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php index 98f66957d3..6024504c4c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php index 53b9777aa6..019ffb5507 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AsinhTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php index 2fb7c0f5c4..be37fdd241 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Atan2Test.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php index 3de5f1ab64..d4156d6c2e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php index 3e7cdb2ab6..0433535e3e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AtanhTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php index 90360305f3..77b661c669 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/BaseTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php index 1ae3c83e9a..384600d5b5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingMathTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php index 00bb6e1b1e..d6e60e5294 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingPreciseTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php index c12040cc8a..ba246a03e3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CeilingTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php index 260d6d20ea..bc3d41ba81 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinATest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php index f7fcfed741..6c4cdfa26c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CombinTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php index 4f07320173..0f5513d2da 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CosTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php index caabfdd761..0239c1ee6f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CoshTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php index 5fd56b0b11..d7c71af594 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CotTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php index a14f9b40fc..1527ef764b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CothTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php index f64cef3a55..2b64c71a8a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CscTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php index b6d0297666..9f2bf9050b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/CschTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php index 42bdc17029..14d3d72bd4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/DegreesTest.php @@ -1,5 +1,7 @@ getSheet(); $this->mightHaveException($expectedResult); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php index 275c8f4ef5..88166169e7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/EvenTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php index 38c9e88abd..7af6b3b095 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ExpTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php index 441579ba2c..e405c5d0f5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactDoubleTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php index 69cefc4d4a..1b1dbdb5c3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FactTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -37,11 +36,8 @@ public static function providerFACT(): array /** * @dataProvider providerFACTGnumeric - * - * @param mixed $expectedResult - * @param mixed $arg1 */ - public function testFACTGnumeric($expectedResult, $arg1): void + public function testFACTGnumeric(mixed $expectedResult, mixed $arg1): void { $this->mightHaveException($expectedResult); self::setGnumeric(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php index e37023e921..f91076a239 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorMathTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php index 8573af868f..3a43822e94 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorPreciseTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php index f4d5529586..3d56fb3282 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/FloorTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php index 01f2b21f06..e7684ba14a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/GcdTest.php @@ -1,15 +1,15 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php index a861ac80ee..7f551e3430 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/IntTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php index a798ce2a12..13d3b99402 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LcmTest.php @@ -1,15 +1,15 @@ getSheet(); $row = 0; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php index 49305d1434..ca7eb78e86 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LnTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php index 4424565470..63ff4e9521 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/Log10Test.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php index f4baf1b725..69cd275be2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/LogTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php index b704bc5f89..63c118572f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MInverseTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MUnitTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MUnitTest.php index 9ac68ee5e9..5d1abe126f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MUnitTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MUnitTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php index f1fc1ea255..f33b886509 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ModTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MovedFunctionsTest.php index 646fd634b2..91e0a92f87 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MovedFunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MovedFunctionsTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php index 7b3a4ab859..de4522368a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/OddTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php index db3411f522..0bf42f09a8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/PowerTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php index fb64446330..7b4bc296e3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/ProductTest.php @@ -1,15 +1,15 @@ getSheet(); $row = 0; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php index 90878696b0..84c2856be4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/QuotientTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php index d39c3615ba..fb3c784eb1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RadiansTest.php @@ -1,5 +1,7 @@ getSheet(); $this->mightHaveException($expectedResult); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php index 6fffb31c77..3b5f730258 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandTest.php index 989c4883b4..f1cd7cc70b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php index 1d9d2b6027..b65da3627c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundDownTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php index dbea38efc2..b9d776242f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php index f360c2ee44..5ad00d36ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RoundUpTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php index 4cd608c7ec..4485b566f0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SecTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php index 9260179419..7605f95fc5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SechTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php index a3cd1c37a6..4db230ece0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php @@ -1,5 +1,7 @@ getSheet(); if ($arg1 !== null) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php index a62804681d..436d0fe02b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SignTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php index 62f0355916..83bc295f80 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php index 045d32768e..0ad727757e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SinhTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php index b04b512f3d..e6a1e783d3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtPiTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php index 6dc39d6cc1..4bd348ffc7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SqrtTest.php @@ -1,5 +1,7 @@ getSheet(); $this->mightHaveException($expectedResult); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php index 7ac398c414..b93b7f2609 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SubTotalTest.php @@ -1,16 +1,15 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -29,11 +28,8 @@ public static function providerSUBTOTAL(): array /** * @dataProvider providerSUBTOTAL - * - * @param mixed $expectedResult - * @param mixed $type expect an integer */ - public function testSubtotalColumnHidden($expectedResult, $type): void + public function testSubtotalColumnHidden(mixed $expectedResult, mixed $type): void { // Hidden columns don't affect calculation, only hidden rows $this->mightHaveException($expectedResult); @@ -66,11 +62,8 @@ public function testSubtotalColumnHidden($expectedResult, $type): void /** * @dataProvider providerSUBTOTALHIDDEN - * - * @param mixed $expectedResult - * @param mixed $type expect an integer */ - public function testSubtotalRowHidden($expectedResult, $type): void + public function testSubtotalRowHidden(mixed $expectedResult, mixed $type): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php index a42153ad44..1f61aa8632 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfTest.php @@ -1,16 +1,15 @@ mightHaveException($expectedResult); if ($expectedResult === 'incomplete') { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php index aecb777711..eca29781f2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumIfsTest.php @@ -1,5 +1,7 @@ getSheet(); $row = 0; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php index 2b8ed93e8c..41b3e4c61f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumSqTest.php @@ -1,15 +1,15 @@ mightHaveException($expectedResult); $maxRow = 0; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumTest.php index e51662f985..5c9bd238d8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumTest.php @@ -1,5 +1,7 @@ getSheet(); $row = 0; @@ -31,10 +31,8 @@ public static function providerSUM(): array /** * @dataProvider providerSUMLiterals - * - * @param mixed $expectedResult */ - public function testSUMLiterals($expectedResult, string $args): void + public function testSUMLiterals(mixed $expectedResult, string $args): void { $sheet = $this->getSheet(); $sheet->getCell('B1')->setValue("=SUM($args)"); @@ -49,10 +47,8 @@ public static function providerSUMLiterals(): array /** * @dataProvider providerSUMWITHINDEXMATCH - * - * @param mixed $expectedResult */ - public function testSumWithIndexMatch($expectedResult, string $formula): void + public function testSumWithIndexMatch(mixed $expectedResult, string $formula): void { $spreadsheet = new Spreadsheet(); $sheet1 = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php index 2872f734d1..c7d1bf8c2b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2MY2Test.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php index 08f30dfb3c..b75ea02dfc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumX2PY2Test.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php index 3e5c31dc84..4cce0ada0e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SumXMY2Test.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php index f20aa5c24f..c21d451a1b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php index e2c4f56114..8de5d6803e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TanhTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php index 445e3ae94b..beaf0a8313 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/TruncTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php index f5186c6318..da8038189a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php @@ -1,5 +1,7 @@ expectException(CalcException::class); } } - /** - * @param mixed $value - */ - protected function setCell(string $cell, $value): void + protected function setCell(string $cell, mixed $value): void { if ($value !== null) { if (is_string($value) && is_numeric($value)) { @@ -99,11 +92,8 @@ protected function getSheet(): Worksheet * Excel handles text/logical/empty cells differently when * passed directly as arguments as opposed to cell references or arrays. * This function will test both approaches. - * - * @param mixed $expectedResult - * @param array $args */ - protected function runTestCases(string $functionName, $expectedResult, ...$args): void + protected function runTestCases(string $functionName, mixed $expectedResult, mixed ...$args): void { if (is_array($expectedResult)) { $this->runTestCaseReference($functionName, $expectedResult[0], ...$args); @@ -118,11 +108,8 @@ protected function runTestCases(string $functionName, $expectedResult, ...$args) * Excel handles text/logical/empty cells differently when * passed directly as arguments as opposed to cell references or arrays. * This functions tests passing as arrays. - * - * @param mixed $expectedResult - * @param array $args */ - protected function runTestCaseReference(string $functionName, $expectedResult, ...$args): void + protected function runTestCaseReference(string $functionName, mixed $expectedResult, mixed ...$args): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -142,7 +129,7 @@ protected function runTestCaseReference(string $functionName, $expectedResult, . $arrayArg .= '}'; $formula .= "$comma$arrayArg"; $comma = ','; - } else { // @phpstan-ignore-line + } else { $cellId = "A$row"; $formula .= "$comma$cellId"; $comma = ','; @@ -158,11 +145,8 @@ protected function runTestCaseReference(string $functionName, $expectedResult, . * Excel handles text/logical/empty cells differently when * passed directly as arguments as opposed to cell references or arrays. * This functions tests passing as direct arguments. - * - * @param mixed $expectedResult - * @param array $args */ - protected function runTestCaseDirect(string $functionName, $expectedResult, ...$args): void + protected function runTestCaseDirect(string $functionName, mixed $expectedResult, mixed ...$args): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -175,7 +159,7 @@ protected function runTestCaseDirect(string $functionName, $expectedResult, ...$ $comma = ','; $formula .= $this->convertToString($arrayItem); } - } else { // @phpstan-ignore-line + } else { $formula .= $comma; $comma = ','; $formula .= $this->convertToString($arg); @@ -189,11 +173,8 @@ protected function runTestCaseDirect(string $functionName, $expectedResult, ...$ /** * Excel seems to reject bracket notation for literal arrays * for some functions. - * - * @param mixed $expectedResult - * @param array $args */ - protected function runTestCaseNoBracket(string $functionName, $expectedResult, ...$args): void + protected function runTestCaseNoBracket(string $functionName, mixed $expectedResult, mixed ...$args): void { $this->mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -213,7 +194,7 @@ protected function runTestCaseNoBracket(string $functionName, $expectedResult, . } $formula .= "$comma$arrayRange"; $comma = ','; - } else { // @phpstan-ignore-line + } else { $cellId = "A$row"; $formula .= "$comma$cellId"; $comma = ','; @@ -229,10 +210,7 @@ protected function runTestCaseNoBracket(string $functionName, $expectedResult, . self::assertEqualsWithDelta($expectedResult, $sheet->getCell('Z99')->getCalculatedValue(), 1.0e-8, 'arguments supplied as ranges'); } - /** - * @param mixed $arg - */ - private function convertToString($arg): string + private function convertToString(mixed $arg): string { if (is_string($arg)) { return '"' . $arg . '"'; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php index 37a06626b6..ea9c61ef84 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AveDevTest.php @@ -1,15 +1,15 @@ runTestCases('AVEDEV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php index 8a0f35442b..48788ab402 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageATest.php @@ -1,15 +1,15 @@ runTestCases('AVERAGEA', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIf2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIf2Test.php index 1899239f82..4cbdee0636 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIf2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIf2Test.php @@ -1,5 +1,7 @@ runTestCaseNoBracket('AVERAGEIF', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfsTest.php index 10a466b625..e3f835809d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageIfsTest.php @@ -1,5 +1,7 @@ runTestCaseNoBracket('AVERAGEIFS', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php index f8c8e41855..078a8313b2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AverageTest.php @@ -1,15 +1,15 @@ runTestCases('AVERAGE', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php index b34dc5ee0b..2a25cbfe6f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaDistTest.php @@ -1,5 +1,7 @@ runTestCaseReference('BETADIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php index b035abd6d2..eab0cf4ba1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BetaInvTest.php @@ -1,5 +1,7 @@ runTestCaseReference('BETAINV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php index 3970b02661..9a8ac452fc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistRangeTest.php @@ -1,5 +1,7 @@ runTestCaseReference('BINOM.DIST.RANGE', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php index 9d89628eac..5f824d7178 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomDistTest.php @@ -1,5 +1,7 @@ runTestCaseReference('BINOMDIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php index cd15517df5..ecd12285c2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/BinomInvTest.php @@ -1,5 +1,7 @@ runTestCaseReference('BINOM.INV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php index 81db209da4..a9319cee65 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistLeftTailTest.php @@ -1,5 +1,7 @@ runTestCaseReference('CHISQ.DIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php index 06ba2d3de5..94835eb614 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiDistRightTailTest.php @@ -1,5 +1,7 @@ runTestCaseReference('CHISQ.DIST.RT', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php index 858cfa3ff5..d12f3b3f49 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvLeftTailTest.php @@ -1,5 +1,7 @@ runTestCaseReference('CHISQ.INV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php index 79c8531239..82da0a6d64 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiInvRightTailTest.php @@ -1,5 +1,7 @@ runTestCases('CHISQ.INV.RT', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiTestTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiTestTest.php index 7f9ea55a78..0059a9de8b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiTestTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ChiTestTest.php @@ -1,5 +1,7 @@ runTestCaseReference('CONFIDENCE', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php index 204cf34d73..e832a89e7b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CorrelTest.php @@ -1,5 +1,7 @@ runTestCases('COUNTA', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php index ec266a8967..e5f44f78d1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountBlankTest.php @@ -1,5 +1,7 @@ runTestCaseNoBracket('COUNTBLANK', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php index dbfb5facae..794751d6f0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfTest.php @@ -1,15 +1,15 @@ runTestCaseNoBracket('COUNTIF', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php index 382e8a6fda..54c8a05bef 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountIfsTest.php @@ -1,5 +1,7 @@ runTestCaseNoBracket('COUNTIFS', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php index b8a775a2af..ef951be3f1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CountTest.php @@ -1,15 +1,15 @@ runTestCaseNoBracket('COUNT', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerBasicCOUNT(): array /** * @dataProvider providerExcelCOUNT - * - * @param mixed $expectedResult */ - public function testExcelCOUNT($expectedResult, ...$args): void + public function testExcelCOUNT(mixed $expectedResult, mixed ...$args): void { if (is_array($args[0])) { $this->runTestCaseNoBracket('COUNT', $expectedResult, ...$args); @@ -40,10 +38,8 @@ public static function providerExcelCOUNT(): array /** * @dataProvider providerOpenOfficeCOUNT - * - * @param mixed $expectedResult */ - public function testOpenOfficeCOUNT($expectedResult, ...$args): void + public function testOpenOfficeCOUNT(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); if (is_array($args[0])) { @@ -60,10 +56,8 @@ public static function providerOpenOfficeCOUNT(): array /** * @dataProvider providerGnumericCOUNT - * - * @param mixed $expectedResult */ - public function testGnumericCOUNT($expectedResult, ...$args): void + public function testGnumericCOUNT(mixed $expectedResult, mixed ...$args): void { $this->setGnumeric(); $this->runTestCaseNoBracket('COUNT', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php index 4c04f86790..63b11e8d3f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/CovarTest.php @@ -1,15 +1,15 @@ runTestCaseNoBracket('COVAR', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/DevSqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/DevSqTest.php index 8f2b282d03..e239e105a9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/DevSqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/DevSqTest.php @@ -1,15 +1,15 @@ runTestCases('DEVSQ', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php index 018eee002c..2cb5b64cbb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ExponDistTest.php @@ -1,5 +1,7 @@ runTestCases('EXPONDIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php index 2a1db8993b..6c6478f288 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FDistTest.php @@ -1,5 +1,7 @@ runTestCases('F.DIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php index 875724efa6..aa3189742e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherInvTest.php @@ -1,5 +1,7 @@ runTestCases('FISHERINV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php index de20c2d443..352a3afc53 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/FisherTest.php @@ -1,5 +1,7 @@ runTestCases('FISHER', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php index c8d944cbff..396e69e0ba 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ForecastTest.php @@ -1,5 +1,7 @@ runTestCases('GAMMA.DIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php index dcddf82cd0..b3d1a3409b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaInvTest.php @@ -1,5 +1,7 @@ runTestCases('GAMMA.INV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php index e30aaa37bf..8c9c4c76a3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaLnTest.php @@ -1,5 +1,7 @@ runTestCases('GAMMALN', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php index 412133fdcf..9db243cc02 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GammaTest.php @@ -1,5 +1,7 @@ runTestCases('GAMMA', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php index 57d1afd438..4fb98f5ec5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GaussTest.php @@ -1,5 +1,7 @@ runTestCases('GAUSS', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php index ead0233f54..f5b8b91b4f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GeoMeanTest.php @@ -1,15 +1,15 @@ runTestCases('GEOMEAN', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php index ea7a64e4f5..51d379a8d9 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/GrowthTest.php @@ -1,5 +1,7 @@ runTestCases('HARMEAN', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php index 34d8b19210..b240d874b0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/HypGeomDistTest.php @@ -1,5 +1,7 @@ runTestCases('HYPGEOMDIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php index d50a6836b8..c340c98997 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/InterceptTest.php @@ -1,15 +1,15 @@ runTestCaseNoBracket('INTERCEPT', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/KurtTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/KurtTest.php index 95776acf97..1b2d791683 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/KurtTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/KurtTest.php @@ -1,15 +1,15 @@ runTestCases('KURT', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php index 848b4b7615..de1e4aa1ea 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LargeTest.php @@ -1,15 +1,15 @@ runTestCaseReference('LARGE', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php index 485857aef7..1c86b7128d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LinEstTest.php @@ -1,5 +1,7 @@ runTestCases('LOGINV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php index 6238540f39..0857e54249 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDist2Test.php @@ -1,5 +1,7 @@ runTestCases('LOGNORM.DIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php index 89f04b0890..fcb01d5a44 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/LogNormDistTest.php @@ -1,5 +1,7 @@ runTestCases('LOGNORMDIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php index ea7af4a1fe..4e65e2db45 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxATest.php @@ -1,15 +1,15 @@ runTestCaseReference('MAXA', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php index 86944471e3..25a7ac696a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxIfsTest.php @@ -1,15 +1,15 @@ runTestCaseNoBracket('MAXIFS', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxTest.php index bf7db628ea..ea1e5110bd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MaxTest.php @@ -1,15 +1,15 @@ runTestCaseReference('MAX', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php index aa568fdcc1..2eeaf6042d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MedianTest.php @@ -1,15 +1,15 @@ runTestCases('MEDIAN', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinATest.php index 7daa156195..28d417dae7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinATest.php @@ -1,15 +1,15 @@ runTestCaseReference('MINA', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php index d3dda839e0..7fb91bfbcb 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinIfsTest.php @@ -1,15 +1,15 @@ runTestCaseNoBracket('MINIFS', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinTest.php index 03493c21ed..c699cfedf3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MinTest.php @@ -1,15 +1,15 @@ runTestCaseReference('MIN', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php index aed9188e4a..5ae2c4977c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ModeTest.php @@ -1,5 +1,7 @@ getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MovedFunctionsTest.php index e51e8823fa..6b0b8c6283 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MovedFunctionsTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MovedFunctionsTest.php @@ -1,5 +1,7 @@ runTestCases('NEGBINOMDIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php index 590a2b4258..ba62123ec3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormDistTest.php @@ -1,5 +1,7 @@ runTestCases('NORMDIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php index a287d6684a..5aa42fc85b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormInvTest.php @@ -1,5 +1,7 @@ runTestCases('NORMINV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php index b3c9df24f4..c85c125c7c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDist2Test.php @@ -1,5 +1,7 @@ runTestCases('NORM.S.DIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php index 4306e862e7..95d8ff32de 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSDistTest.php @@ -1,5 +1,7 @@ runTestCases('NORMSDIST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php index 131a7b8e5b..e935538023 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/NormSInvTest.php @@ -1,5 +1,7 @@ runTestCases('NORMSINV', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php index 200f88e9b9..153b768224 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php @@ -1,5 +1,7 @@ runTestCaseReference('PERCENTRANK', $expectedResult, $valueSet, $value); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentileTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentileTest.php index 35dd358497..47faff9e31 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentileTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentileTest.php @@ -1,15 +1,15 @@ runTestCaseReference('PERCENTILE', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php index d680a5a2b7..75a7999564 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutTest.php @@ -1,5 +1,7 @@ runTestCases('PERMUT', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php index 29533d1e5e..2cfc6a567d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PermutationATest.php @@ -1,5 +1,7 @@ runTestCases('PERMUTATIONA', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php index 74ae8a6147..2233a74eca 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PoissonTest.php @@ -1,5 +1,7 @@ runTestCases('POISSON', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/QuartileTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/QuartileTest.php index 343ac8eb40..daf658b849 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/QuartileTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/QuartileTest.php @@ -1,15 +1,15 @@ runTestCaseReference('QUARTILE', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php index c3f8bb2b4b..5777a8f2d0 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php @@ -1,5 +1,7 @@ runTestCaseReference('RANK', $expectedResult, $value, $valueSet); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php index 51ce4ee18f..fba99b1b82 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RsqTest.php @@ -1,15 +1,15 @@ runTestCaseNoBracket('RSQ', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php index 264d29de19..f88287cc33 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SkewTest.php @@ -1,15 +1,15 @@ runTestCaseReference('SKEW', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php index 0d7fe282b6..12220561b7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SlopeTest.php @@ -1,15 +1,15 @@ runTestCaseNoBracket('SLOPE', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SmallTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SmallTest.php index 86dbc481d4..13dc6f99c4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SmallTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SmallTest.php @@ -1,17 +1,15 @@ runTestCaseReference('SMALL', $expectedResult, $values, $position); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevATest.php index 1268d44034..c6964f9487 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevATest.php @@ -1,15 +1,15 @@ runTestCaseReference('STDEVA', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerSTDEVA(): array /** * @dataProvider providerOdsSTDEVA - * - * @param mixed $expectedResult */ - public function testOdsSTDEVA($expectedResult, ...$args): void + public function testOdsSTDEVA(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); $this->runTestCaseReference('STDEVA', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPATest.php index 9d5389ed16..db309b2f7a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPATest.php @@ -1,15 +1,15 @@ runTestCaseReference('STDEVPA', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerSTDEVPA(): array /** * @dataProvider providerOdsSTDEVPA - * - * @param mixed $expectedResult */ - public function testOdsSTDEVPA($expectedResult, ...$args): void + public function testOdsSTDEVPA(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); $this->runTestCaseReference('STDEVPA', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPTest.php index 60057d218b..89898d2a1e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevPTest.php @@ -1,15 +1,15 @@ runTestCaseReference('STDEVP', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerSTDEVP(): array /** * @dataProvider providerOdsSTDEVP - * - * @param mixed $expectedResult */ - public function testOdsSTDEVP($expectedResult, ...$args): void + public function testOdsSTDEVP(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); $this->runTestCaseReference('STDEVP', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevTest.php index eb607d8289..b920621533 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StDevTest.php @@ -1,15 +1,15 @@ runTestCaseReference('STDEV', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerSTDEV(): array /** * @dataProvider providerOdsSTDEV - * - * @param mixed $expectedResult */ - public function testOdsSTDEV($expectedResult, ...$args): void + public function testOdsSTDEV(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); $this->runTestCaseReference('STDEV', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php index 3a36ddfbb3..8defe4c03c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/StandardizeTest.php @@ -1,5 +1,7 @@ runTestCases('STANDARDIZE', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php index 5971aaf8e7..5c195630a1 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/SteyxTest.php @@ -1,15 +1,15 @@ runTestCaseReference('TDIST', $expectedResult, $value, $degrees, $tails); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php index ebe4abc6a0..ed16e9dbaa 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TinvTest.php @@ -1,5 +1,7 @@ runTestCaseReference('TINV', $expectedResult, $probability, $degrees); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php index 5aa32bda33..1a09ce9b4c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/TrendTest.php @@ -1,5 +1,7 @@ runTestCaseReference('TRIMMEAN', $expectedResult, $args, $percentage); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarATest.php index 4872310832..084a452e42 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarATest.php @@ -1,15 +1,15 @@ runTestCases('VARA', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerVARA(): array /** * @dataProvider providerOdsVARA - * - * @param mixed $expectedResult */ - public function testOdsVARA($expectedResult, ...$args): void + public function testOdsVARA(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); $this->runTestCases('VARA', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPATest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPATest.php index 7c128b6f96..9c1e62fdb7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPATest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPATest.php @@ -1,15 +1,15 @@ runTestCases('VARPA', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerVARPA(): array /** * @dataProvider providerOdsVARPA - * - * @param mixed $expectedResult */ - public function testOdsVARPA($expectedResult, ...$args): void + public function testOdsVARPA(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); $this->runTestCases('VARPA', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPTest.php index 5ab6e60951..45f46d08b6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarPTest.php @@ -1,15 +1,15 @@ runTestCases('VARP', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerVARP(): array /** * @dataProvider providerOdsVARP - * - * @param mixed $expectedResult */ - public function testOdsVARP($expectedResult, ...$args): void + public function testOdsVARP(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); $this->runTestCases('VARP', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarTest.php index 088fd4bae7..c565b4177c 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/VarTest.php @@ -1,15 +1,15 @@ runTestCases('VAR', $expectedResult, ...$args); } @@ -21,10 +21,8 @@ public static function providerVAR(): array /** * @dataProvider providerOdsVAR - * - * @param mixed $expectedResult */ - public function testOdsVAR($expectedResult, ...$args): void + public function testOdsVAR(mixed $expectedResult, mixed ...$args): void { $this->setOpenOffice(); $this->runTestCases('VAR', $expectedResult, ...$args); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php index 3c6f8116be..533477525f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/WeibullTest.php @@ -1,5 +1,7 @@ runTestCases('WEIBULL', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php index 492fdd860d..32ae58a1c6 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/ZTestTest.php @@ -1,5 +1,7 @@ runTestCaseReference('ZTEST', $expectedResult, ...$args); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/AllSetupTeardown.php index e0343b2b87..63f2e01c82 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/AllSetupTeardown.php @@ -1,5 +1,7 @@ expectException(CalcException::class); } } - /** - * @param mixed $value - */ - protected function setCell(string $cell, $value): void + protected function setCell(string $cell, mixed $value): void { if ($value !== null) { if (is_string($value) && is_numeric($value)) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ArrayToTextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ArrayToTextTest.php index a63bd6f24b..56d035729a 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ArrayToTextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ArrayToTextTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php index 3162a6baa6..7b83438cd2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CleanTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php index 001ad6075e..e29c057a69 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/CodeTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php index b5eeda7b6d..cfe5662634 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ConcatenateTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php index 5ecd3f507e..d6e50de05f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php index 20293f1ed1..802b73e4cc 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ExactTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php index d649308373..6f5e187b83 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FindTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php index a820299dad..0ee5c1cc39 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/FixedTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php index 496eb0af92..4be89c238b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LeftTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -40,13 +41,8 @@ public static function providerLEFT(): array /** * @dataProvider providerLocaleLEFT - * - * @param string $expectedResult - * @param mixed $value - * @param mixed $locale - * @param mixed $characters */ - public function testLowerWithLocaleBoolean($expectedResult, $locale, $value, $characters): void + public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value, mixed $characters): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php index c22f40b6c6..e2db773ae4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LenTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php index 1ea6ac9f71..7549a3a4a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/LowerTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -34,12 +33,8 @@ public static function providerLOWER(): array /** * @dataProvider providerLocaleLOWER - * - * @param string $expectedResult - * @param mixed $value - * @param mixed $locale */ - public function testLowerWithLocaleBoolean($expectedResult, $locale, $value): void + public function testLowerWithLocaleBoolean(string $expectedResult, mixed $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 78f8273a4d..4a103f2bf5 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/MidTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -46,14 +47,8 @@ public static function providerMID(): array /** * @dataProvider providerLocaleMID - * - * @param string $expectedResult - * @param mixed $value - * @param mixed $locale - * @param mixed $offset - * @param mixed $characters */ - public function testMiddleWithLocaleBoolean($expectedResult, $locale, $value, $offset, $characters): void + public function testMiddleWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value, mixed $offset, mixed $characters): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php index 3b410cbd74..9dfa1fa205 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/NumberValueTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/OpenOfficeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/OpenOfficeTest.php index 64e02e50b8..c7af96f64f 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/OpenOfficeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/OpenOfficeTest.php @@ -1,15 +1,15 @@ setOpenOffice(); $this->mightHaveException($expectedResult); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php index 9f6e6f7b74..a3aee91439 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ProperTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -34,12 +33,8 @@ public static function providerPROPER(): array /** * @dataProvider providerLocaleLOWER - * - * @param string $expectedResult - * @param mixed $value - * @param mixed $locale */ - public function testLowerWithLocaleBoolean($expectedResult, $locale, $value): void + public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php index 64e38d796e..68a6f501e8 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReplaceTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php index 09355c71e9..8cbed14d3d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ReptTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php index 4c9210d669..d2bc683627 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/RightTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -40,13 +41,8 @@ public static function providerRIGHT(): array /** * @dataProvider providerLocaleRIGHT - * - * @param string $expectedResult - * @param mixed $value - * @param mixed $locale - * @param mixed $characters */ - public function testLowerWithLocaleBoolean($expectedResult, $locale, $value, $characters): void + public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value, mixed $characters): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php index aa08787cb5..5c441b7dd4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SearchTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php index ced6cb00e5..9273302527 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/SubstituteTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php index 991b6d9bcc..6f2bf123a2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); if ($value === 'no arguments') { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextAfterTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextAfterTest.php index b64db024b3..9f50af3ef2 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextAfterTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextAfterTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextSplitTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextSplitTest.php index c32f2f062a..9801d77d4b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextSplitTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextSplitTest.php @@ -1,5 +1,7 @@ $value) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php index f0a7e120fc..eedd8b93b4 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TextTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php index 45ae5374a0..30929afd9d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/TrimTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php index dd5c82a790..964a2accb3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/UpperTest.php @@ -1,5 +1,7 @@ mightHaveException($expectedResult); $sheet = $this->getSheet(); @@ -34,12 +33,8 @@ public static function providerUPPER(): array /** * @dataProvider providerLocaleLOWER - * - * @param string $expectedResult - * @param mixed $value - * @param mixed $locale */ - public function testLowerWithLocaleBoolean($expectedResult, $locale, $value): void + public function testLowerWithLocaleBoolean(string $expectedResult, mixed $locale, mixed $value): void { $newLocale = Settings::setLocale($locale); if ($newLocale === false) { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php index 900af7dd79..c04dfe8798 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/ValueTest.php @@ -1,5 +1,7 @@ getSheet(); $this->setCell('A1', $value); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/UrlEncodeTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/UrlEncodeTest.php index 82f60ef986..8ab1337f18 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/UrlEncodeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/UrlEncodeTest.php @@ -1,5 +1,7 @@ getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Calculation/RowColumnReferenceTest.php b/tests/PhpSpreadsheetTests/Calculation/RowColumnReferenceTest.php index 1c28334bd8..1219583643 100644 --- a/tests/PhpSpreadsheetTests/Calculation/RowColumnReferenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/RowColumnReferenceTest.php @@ -1,5 +1,7 @@ getActiveSheet(); @@ -171,11 +164,8 @@ public static function fractionProvider(): array /** * @dataProvider percentageProvider - * - * @param mixed $value - * @param mixed $valueBinded */ - public function testPercentages($value, $valueBinded): void + public function testPercentages(mixed $value, mixed $valueBinded): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); @@ -201,11 +191,8 @@ public static function percentageProvider(): array /** * @dataProvider timeProvider - * - * @param mixed $value - * @param mixed $valueBinded */ - public function testTimes($value, $valueBinded): void + public function testTimes(mixed $value, mixed $valueBinded): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Cell/CellAddressTest.php b/tests/PhpSpreadsheetTests/Cell/CellAddressTest.php index eb8e68027d..2cddc48a06 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellAddressTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellAddressTest.php @@ -1,5 +1,7 @@ expectException(Exception::class); $this->expectExceptionMessage( @@ -84,11 +84,8 @@ public function testCreateFromColumnAndRow( /** * @dataProvider providerCreateFromColumnRowException - * - * @param mixed $columnId - * @param mixed $rowId */ - public function testCreateFromColumnRowException($columnId, $rowId): void + public function testCreateFromColumnRowException(mixed $columnId, mixed $rowId): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Row and Column Ids must be positive integer values'); @@ -135,11 +132,8 @@ public static function providerCreateFromColumnRowArray(): array /** * @dataProvider providerCreateFromColumnRowException - * - * @param mixed $columnId - * @param mixed $rowId */ - public function testCreateFromColumnRowArrayException($columnId, $rowId): void + public function testCreateFromColumnRowArrayException(mixed $columnId, mixed $rowId): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Row and Column Ids must be positive integer values'); diff --git a/tests/PhpSpreadsheetTests/Cell/CellDetachTest.php b/tests/PhpSpreadsheetTests/Cell/CellDetachTest.php index 950322a7f9..388d3ad713 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellDetachTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellDetachTest.php @@ -1,5 +1,7 @@ getActiveSheet()->getCell('A1'); @@ -106,10 +105,8 @@ public function testInvalidIsoDateSetValueExplicit(): void /** * @dataProvider providerSetValueExplicitException - * - * @param mixed $value */ - public function testSetValueExplicitException($value, string $dataType): void + public function testSetValueExplicitException(mixed $value, string $dataType): void { $this->expectException(Exception::class); diff --git a/tests/PhpSpreadsheetTests/Cell/ColumnRangeTest.php b/tests/PhpSpreadsheetTests/Cell/ColumnRangeTest.php index 14455701fd..10da1dd21c 100644 --- a/tests/PhpSpreadsheetTests/Cell/ColumnRangeTest.php +++ b/tests/PhpSpreadsheetTests/Cell/ColumnRangeTest.php @@ -1,5 +1,7 @@ $split) { @@ -244,11 +228,8 @@ public static function providerSplitRange(): array /** * @dataProvider providerBuildRange - * - * @param mixed $expectedResult - * @param mixed $rangeSets */ - public function testBuildRange($expectedResult, $rangeSets): void + public function testBuildRange(mixed $expectedResult, mixed $rangeSets): void { $result = Coordinate::buildRange($rangeSets); self::assertEquals($expectedResult, $result); @@ -279,11 +260,8 @@ public function testBuildRangeInvalid2(): void /** * @dataProvider providerRangeBoundaries - * - * @param mixed $expectedResult - * @param string $rangeSet */ - public function testRangeBoundaries($expectedResult, $rangeSet): void + public function testRangeBoundaries(mixed $expectedResult, string $rangeSet): void { $result = Coordinate::rangeBoundaries($rangeSet); self::assertEquals($expectedResult, $result); @@ -296,11 +274,8 @@ public static function providerRangeBoundaries(): array /** * @dataProvider providerRangeDimension - * - * @param mixed $expectedResult - * @param string $rangeSet */ - public function testRangeDimension($expectedResult, $rangeSet): void + public function testRangeDimension(mixed $expectedResult, string $rangeSet): void { $result = Coordinate::rangeDimension($rangeSet); self::assertEquals($expectedResult, $result); @@ -313,11 +288,8 @@ public static function providerRangeDimension(): array /** * @dataProvider providerGetRangeBoundaries - * - * @param mixed $expectedResult - * @param string $rangeSet */ - public function testGetRangeBoundaries($expectedResult, $rangeSet): void + public function testGetRangeBoundaries(mixed $expectedResult, string $rangeSet): void { $result = Coordinate::getRangeBoundaries($rangeSet); self::assertEquals($expectedResult, $result); @@ -330,11 +302,8 @@ public static function providerGetRangeBoundaries(): array /** * @dataProvider providerExtractAllCellReferencesInRange - * - * @param array $expectedResult - * @param string $rangeSet */ - public function testExtractAllCellReferencesInRange($expectedResult, $rangeSet): void + public function testExtractAllCellReferencesInRange(array $expectedResult, string $rangeSet): void { $result = Coordinate::extractAllCellReferencesInRange($rangeSet); self::assertEquals($expectedResult, $result); @@ -347,10 +316,8 @@ public static function providerExtractAllCellReferencesInRange(): array /** * @dataProvider providerInvalidRange - * - * @param string $range */ - public function testExtractAllCellReferencesInRangeInvalidRange($range): void + public function testExtractAllCellReferencesInRangeInvalidRange(string $range): void { $this->expectException(Exception::class); $this->expectExceptionMessage('Invalid range: "' . $range . '"'); @@ -365,11 +332,8 @@ public static function providerInvalidRange(): array /** * @dataProvider providerMergeRangesInCollection - * - * @param mixed $expectedResult - * @param mixed $rangeSets */ - public function testMergeRangesInCollection($expectedResult, $rangeSets): void + public function testMergeRangesInCollection(mixed $expectedResult, mixed $rangeSets): void { $result = Coordinate::mergeRangesInCollection($rangeSets); self::assertEquals($expectedResult, $result); @@ -382,11 +346,8 @@ public static function providerMergeRangesInCollection(): array /** * @dataProvider providerCoordinateIsRange - * - * @param mixed $expectedResult - * @param string $rangeSet */ - public function testCoordinateIsRange($expectedResult, $rangeSet): void + public function testCoordinateIsRange(mixed $expectedResult, string $rangeSet): void { $result = Coordinate::coordinateIsRange($rangeSet); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php index 176dd6acaf..974297c4ce 100644 --- a/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php +++ b/tests/PhpSpreadsheetTests/Cell/DataTypeTest.php @@ -1,5 +1,7 @@ getActiveSheet(); @@ -50,11 +50,8 @@ public static function binderProvider(): array /** * @dataProvider providerDataTypeForValue - * - * @param mixed $expectedResult - * @param mixed $value */ - public function testDataTypeForValue($expectedResult, $value): void + public function testDataTypeForValue(mixed $expectedResult, mixed $value): void { $result = DefaultValueBinder::dataTypeForValue($value); self::assertEquals($expectedResult, $result); diff --git a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php index e92fbaf3d7..68d43e418c 100644 --- a/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php +++ b/tests/PhpSpreadsheetTests/Cell/HyperlinkTest.php @@ -1,5 +1,7 @@ testExpectedExceptions($expected, $actual); @@ -100,11 +91,7 @@ public function getErrorMessage(): string return $this->errorMessage; } - /** - * @param mixed $expected - * @param mixed $actual - */ - public function runAssertComplexEquals($expected, $actual, ?float $delta = null): void + public function runAssertComplexEquals(mixed $expected, mixed $actual, ?float $delta = null): void { self::assertTrue($this->assertComplexEquals($expected, $actual, $delta), $this->getErrorMessage()); } diff --git a/tests/PhpSpreadsheetTests/DefinedNameFormulaTest.php b/tests/PhpSpreadsheetTests/DefinedNameFormulaTest.php index e1a9c2e696..131163def6 100644 --- a/tests/PhpSpreadsheetTests/DefinedNameFormulaTest.php +++ b/tests/PhpSpreadsheetTests/DefinedNameFormulaTest.php @@ -1,5 +1,7 @@ startTime; @@ -80,11 +79,8 @@ public function testSetModifier(): void /** * @dataProvider providerModifiedTime - * - * @param mixed $expectedModifiedTime - * @param mixed $modified */ - public function testSetModified($expectedModifiedTime, $modified): void + public function testSetModified(mixed $expectedModifiedTime, mixed $modified): void { $expectedModifiedTime = $expectedModifiedTime ?? $this->startTime; @@ -160,14 +156,8 @@ public function testSetManager(): void /** * @dataProvider providerCustomProperties - * - * @param mixed $expectedType - * @param mixed $expectedValue - * @param string $propertyName - * @param mixed $propertyValue - * @param ?string $propertyType */ - public function testSetCustomProperties($expectedType, $expectedValue, $propertyName, $propertyValue, $propertyType = null): void + public function testSetCustomProperties(mixed $expectedType, mixed $expectedValue, string $propertyName, mixed $propertyValue, ?string $propertyType = null): void { if ($propertyType === null) { $this->properties->setCustomProperty($propertyName, $propertyValue); diff --git a/tests/PhpSpreadsheetTests/Document/SecurityTest.php b/tests/PhpSpreadsheetTests/Document/SecurityTest.php index 9599626030..015e32ba29 100644 --- a/tests/PhpSpreadsheetTests/Document/SecurityTest.php +++ b/tests/PhpSpreadsheetTests/Document/SecurityTest.php @@ -1,5 +1,7 @@ '; diff --git a/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php b/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php index cee46bfa01..72e9ad1aa1 100644 --- a/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php +++ b/tests/PhpSpreadsheetTests/Functional/FreezePaneTest.php @@ -1,5 +1,7 @@ getActiveSheet(); @@ -105,10 +101,8 @@ public function testFreezePaneUserSelectedCell($format): void /** * @dataProvider providerFormats - * - * @param string $format */ - public function testNoFreezePaneUserSelectedCell($format): void + public function testNoFreezePaneUserSelectedCell(string $format): void { $spreadsheet = new Spreadsheet(); $worksheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php b/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php index b5ef4df40e..c99826bfd6 100644 --- a/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/MergedCellsTest.php @@ -1,5 +1,7 @@ setActiveSheetIndex(0); diff --git a/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php b/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php index 1ceed4572b..535f927feb 100644 --- a/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php +++ b/tests/PhpSpreadsheetTests/Functional/PrintAreaTest.php @@ -1,5 +1,7 @@ getActiveSheet()->getCell('B2')->setValue(''); diff --git a/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php b/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php index a9a26a5ee8..755ee2d340 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php @@ -1,5 +1,7 @@ getActiveSheet()->fromArray($arrayData, null, 'A1'); diff --git a/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php b/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php index 4444a29314..89a7327e58 100644 --- a/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/SelectedCellsTest.php @@ -1,5 +1,7 @@ getActiveSheet(); @@ -65,10 +65,8 @@ public static function customizeWriter(WriterXlsx $writer): void * Ensure saved spreadsheets maintain the correct data type. * * @dataProvider providerFormulae - * - * @param string $format */ - public function testFormulaeNoPrecalc($format, array $values): void + public function testFormulaeNoPrecalc(string $format, array $values): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php b/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php index 9998dceddc..5c21443a95 100644 --- a/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php +++ b/tests/PhpSpreadsheetTests/Functional/WorkbookViewAttributesTest.php @@ -1,5 +1,7 @@ getAuthor() : ''; } diff --git a/tests/PhpSpreadsheetTests/Helper/DimensionTest.php b/tests/PhpSpreadsheetTests/Helper/DimensionTest.php index 5fdc3b75e6..e6a823c763 100644 --- a/tests/PhpSpreadsheetTests/Helper/DimensionTest.php +++ b/tests/PhpSpreadsheetTests/Helper/DimensionTest.php @@ -1,5 +1,7 @@ toRichTextObject($input); diff --git a/tests/PhpSpreadsheetTests/Helper/SampleCoverageTest.php b/tests/PhpSpreadsheetTests/Helper/SampleCoverageTest.php index f3f616fe63..2c54dd68fc 100644 --- a/tests/PhpSpreadsheetTests/Helper/SampleCoverageTest.php +++ b/tests/PhpSpreadsheetTests/Helper/SampleCoverageTest.php @@ -1,5 +1,7 @@ filterType == 1) { return $this->filter1($row); diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php index 8c28c1e705..abb85d73e8 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php @@ -1,5 +1,7 @@ setInputEncoding($encoding); @@ -24,11 +23,8 @@ public function testEncodings($filename, $encoding): void /** * @dataProvider providerEncodings - * - * @param string $filename - * @param string $encoding */ - public function testWorkSheetInfo($filename, $encoding): void + public function testWorkSheetInfo(string $filename, string $encoding): void { $reader = new Csv(); $reader->setInputEncoding($encoding); diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvIssue2232Test.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvIssue2232Test.php index 82256365f5..ae305d42f0 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvIssue2232Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvIssue2232Test.php @@ -1,5 +1,7 @@ localeAdjusted) { self::markTestSkipped('Unable to set locale for testing.'); @@ -95,11 +92,9 @@ public static function providerNumberFormatNoConversionTest(): array /** * @dataProvider providerNumberValueConversionTest * - * @param mixed $expectedValue - * * @runInSeparateProcess */ - public function testNumberValueConversion($expectedValue, string $cellAddress): void + public function testNumberValueConversion(mixed $expectedValue, string $cellAddress): void { if (!$this->localeAdjusted) { self::markTestSkipped('Unable to set locale for testing.'); diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatTest.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatTest.php index 0022fd15ad..3cf4047092 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatTest.php @@ -1,5 +1,7 @@ csvReader->load($this->filename); $worksheet = $spreadsheet->getActiveSheet(); @@ -63,10 +63,8 @@ public static function providerNumberFormatNoConversionTest(): array /** * @dataProvider providerNumberValueConversionTest - * - * @param mixed $expectedValue */ - public function testNumberValueConversion($expectedValue, string $cellAddress): void + public function testNumberValueConversion(mixed $expectedValue, string $cellAddress): void { $this->csvReader->castFormattedNumberToNumeric(true); $spreadsheet = $this->csvReader->load($this->filename); @@ -114,10 +112,8 @@ public static function providerNumberValueConversionTest(): array /** * @dataProvider providerNumberFormatConversionTest - * - * @param mixed $expectedValue */ - public function testNumberFormatConversion($expectedValue, string $expectedFormat, string $cellAddress): void + public function testNumberFormatConversion(mixed $expectedValue, string $expectedFormat, string $cellAddress): void { $this->csvReader->castFormattedNumberToNumeric(true, true); $spreadsheet = $this->csvReader->load($this->filename); diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvTest.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvTest.php index 8a0308a4e0..3f4375df85 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvTest.php @@ -1,5 +1,7 @@ getDelimiter(); @@ -92,11 +89,8 @@ public static function providerDelimiterDetection(): array /** * @dataProvider providerCanLoad - * - * @param bool $expected - * @param string $filename */ - public function testCanLoad($expected, $filename): void + public function testCanLoad(bool $expected, string $filename): void { $reader = new Csv(); self::assertSame($expected, $reader->canRead($filename)); diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/AutoFilterTest.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/AutoFilterTest.php index fd309fbd92..be82e77f30 100644 --- a/tests/PhpSpreadsheetTests/Reader/Gnumeric/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/AutoFilterTest.php @@ -1,5 +1,7 @@ Apellido y Nombre - + Obra Social Corresponde Reducción? - + - + 12345678901 EMILIANO ZAPATA SALAZAR - + 101208 Yes - + - + 23456789012 FRANCISCO PANCHO VILLA - + 101208 No - + diff --git a/tests/PhpSpreadsheetTests/Reader/Html/Issue2810Test.php b/tests/PhpSpreadsheetTests/Reader/Html/Issue2810Test.php index 5e6e738695..b2ade3d5fc 100644 --- a/tests/PhpSpreadsheetTests/Reader/Html/Issue2810Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Html/Issue2810Test.php @@ -1,5 +1,7 @@ timeZone); } - /** - * @return Spreadsheet - */ - private function loadOdsTestFile() + private function loadOdsTestFile(): Spreadsheet { $reader = new Ods(); return $reader->loadIntoExisting(self::ODS_TEST_FILE, new Spreadsheet()); } - /** - * @return Spreadsheet - */ - protected function loadDataFile() + protected function loadDataFile(): Spreadsheet { $reader = new Ods(); diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupBug1772Test.php b/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupBug1772Test.php index 7fc7e53763..568bb602c0 100644 --- a/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupBug1772Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Ods/PageSetupBug1772Test.php @@ -1,5 +1,7 @@ scanFile($filename); @@ -40,10 +39,8 @@ public static function providerValidXML(): array /** * @dataProvider providerInvalidXML - * - * @param mixed $filename */ - public function testInvalidXML($filename): void + public function testInvalidXML(mixed $filename): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Reader\Exception::class); @@ -95,11 +92,8 @@ public function testGetSecurityScannerForNonXmlBasedReader2(): void /** * @dataProvider providerValidXMLForCallback - * - * @param mixed $filename - * @param mixed $expectedResult */ - public function testSecurityScanWithCallback($filename, $expectedResult): void + public function testSecurityScanWithCallback(mixed $filename, mixed $expectedResult): void { $fileReader = new Xlsx(); $scanner = $fileReader->getSecurityScannerOrThrow(); diff --git a/tests/PhpSpreadsheetTests/Reader/Slk/SlkCommentsTest.php b/tests/PhpSpreadsheetTests/Reader/Slk/SlkCommentsTest.php index 6f8a7ef51a..f77bc86d28 100644 --- a/tests/PhpSpreadsheetTests/Reader/Slk/SlkCommentsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Slk/SlkCommentsTest.php @@ -1,5 +1,7 @@ getMockBuilder(WorksheetAutoFilter::class) ->disableOriginalConstructor() diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/ChartSheetTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/ChartSheetTest.php index e7862697ee..e433f01aa9 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/ChartSheetTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/ChartSheetTest.php @@ -1,5 +1,7 @@ getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/ReferenceHelper2Test.php b/tests/PhpSpreadsheetTests/ReferenceHelper2Test.php index 076ed1b6f3..c3f8484f05 100644 --- a/tests/PhpSpreadsheetTests/ReferenceHelper2Test.php +++ b/tests/PhpSpreadsheetTests/ReferenceHelper2Test.php @@ -1,5 +1,7 @@ insertNewRowBefore(2, 2); $comments = array_map( - function (Comment $value) { + function (Comment $value): string { return $value->getText()->getPlainText(); }, $sheet->getComments() @@ -245,7 +247,7 @@ public function testDeleteRowsWithComments(): void $sheet->removeRow(2, 2); $comments = array_map( - function (Comment $value) { + function (Comment $value): string { return $value->getText()->getPlainText(); }, $sheet->getComments() diff --git a/tests/PhpSpreadsheetTests/RichTextTest.php b/tests/PhpSpreadsheetTests/RichTextTest.php index 04a1d72a9e..3ebd099c0e 100644 --- a/tests/PhpSpreadsheetTests/RichTextTest.php +++ b/tests/PhpSpreadsheetTests/RichTextTest.php @@ -1,5 +1,7 @@ expectException(Exception::class); diff --git a/tests/PhpSpreadsheetTests/Shared/Date2Test.php b/tests/PhpSpreadsheetTests/Shared/Date2Test.php index 78d2b55ecd..7d66fe8717 100644 --- a/tests/PhpSpreadsheetTests/Shared/Date2Test.php +++ b/tests/PhpSpreadsheetTests/Shared/Date2Test.php @@ -1,5 +1,7 @@ spreadsheet = new Spreadsheet(); @@ -87,11 +87,8 @@ public static function providerTimeOnly(): array /** * @dataProvider providerDateAndTime - * - * @param float|int $expectedResult - * @param float|int $value */ - public function testDateAndTime($expectedResult, $value, ?string $format = null): void + public function testDateAndTime(int|float $expectedResult, int|float|string $value, ?string $format = null): void { Cell::setCalculateDateTimeType(Cell::CALCULATE_DATE_TIME_FLOAT); $this->spreadsheet = new Spreadsheet(); @@ -135,11 +132,8 @@ public static function providerDateAndTime(): array /** * @dataProvider providerAsis - * - * @param float|int $expectedResult - * @param float|int $value */ - public function testDefault($expectedResult, $value, ?string $format = null): void + public function testDefault(int|float $expectedResult, int|float|string $value, ?string $format = null): void { //Cell::setCalculateDateTimeType(Cell::CALCULATE_DATE_TIME_ASIS); $this->spreadsheet = new Spreadsheet(); @@ -160,11 +154,8 @@ public function testDefault($expectedResult, $value, ?string $format = null): vo /** * @dataProvider providerAsis - * - * @param float|int $expectedResult - * @param float|int $value */ - public function testAsis($expectedResult, $value, ?string $format = null): void + public function testAsis(int|float $expectedResult, int|float|string $value, ?string $format = null): void { Cell::setCalculateDateTimeType(Cell::CALCULATE_DATE_TIME_ASIS); $this->spreadsheet = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Shared/DateTest.php b/tests/PhpSpreadsheetTests/Shared/DateTest.php index 9bcd6ff296..7839cfc452 100644 --- a/tests/PhpSpreadsheetTests/Shared/DateTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DateTest.php @@ -1,5 +1,7 @@ PHP_INT_MAX || $expectedResult < PHP_INT_MIN)) { self::markTestSkipped('Test invalid on 32-bit system.'); @@ -76,11 +69,8 @@ public static function providerDateTimeExcelToTimestamp1900(): array /** * @dataProvider providerDateTimeTimestampToExcel1900 - * - * @param mixed $expectedResult - * @param mixed $unixTimestamp */ - public function testDateTimeTimestampToExcel1900($expectedResult, $unixTimestamp): void + public function testDateTimeTimestampToExcel1900(mixed $expectedResult, mixed $unixTimestamp): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -95,11 +85,8 @@ public static function providerDateTimeTimestampToExcel1900(): array /** * @dataProvider providerDateTimeDateTimeToExcel - * - * @param mixed $expectedResult - * @param mixed $dateTimeObject */ - public function testDateTimeDateTimeToExcel($expectedResult, $dateTimeObject): void + public function testDateTimeDateTimeToExcel(mixed $expectedResult, mixed $dateTimeObject): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -114,10 +101,8 @@ public static function providerDateTimeDateTimeToExcel(): array /** * @dataProvider providerDateTimeFormattedPHPToExcel1900 - * - * @param mixed $expectedResult */ - public function testDateTimeFormattedPHPToExcel1900($expectedResult, ...$args): void + public function testDateTimeFormattedPHPToExcel1900(mixed $expectedResult, mixed ...$args): void { Date::setExcelCalendar(Date::CALENDAR_WINDOWS_1900); @@ -132,11 +117,8 @@ public static function providerDateTimeFormattedPHPToExcel1900(): array /** * @dataProvider providerDateTimeExcelToTimestamp1904 - * - * @param mixed $expectedResult - * @param mixed $excelDateTimeValue */ - public function testDateTimeExcelToTimestamp1904($expectedResult, $excelDateTimeValue): void + public function testDateTimeExcelToTimestamp1904(mixed $expectedResult, mixed $excelDateTimeValue): void { if (is_numeric($expectedResult) && ($expectedResult > PHP_INT_MAX || $expectedResult < PHP_INT_MIN)) { self::markTestSkipped('Test invalid on 32-bit system.'); @@ -154,11 +136,8 @@ public static function providerDateTimeExcelToTimestamp1904(): array /** * @dataProvider providerDateTimeTimestampToExcel1904 - * - * @param mixed $expectedResult - * @param mixed $unixTimestamp */ - public function testDateTimeTimestampToExcel1904($expectedResult, $unixTimestamp): void + public function testDateTimeTimestampToExcel1904(mixed $expectedResult, mixed $unixTimestamp): void { Date::setExcelCalendar(Date::CALENDAR_MAC_1904); @@ -173,10 +152,8 @@ public static function providerDateTimeTimestampToExcel1904(): array /** * @dataProvider providerIsDateTimeFormatCode - * - * @param mixed $expectedResult */ - public function testIsDateTimeFormatCode($expectedResult, string $format): void + public function testIsDateTimeFormatCode(mixed $expectedResult, string $format): void { $result = Date::isDateTimeFormatCode($format); self::assertEquals($expectedResult, $result); @@ -189,12 +166,8 @@ public static function providerIsDateTimeFormatCode(): array /** * @dataProvider providerDateTimeExcelToTimestamp1900Timezone - * - * @param mixed $expectedResult - * @param mixed $excelDateTimeValue - * @param mixed $timezone */ - public function testDateTimeExcelToTimestamp1900Timezone($expectedResult, $excelDateTimeValue, $timezone): void + public function testDateTimeExcelToTimestamp1900Timezone(mixed $expectedResult, mixed $excelDateTimeValue, mixed $timezone): void { if (is_numeric($expectedResult) && ($expectedResult > PHP_INT_MAX || $expectedResult < PHP_INT_MIN)) { self::markTestSkipped('Test invalid on 32-bit system.'); diff --git a/tests/PhpSpreadsheetTests/Shared/DgContainerTest.php b/tests/PhpSpreadsheetTests/Shared/DgContainerTest.php index 0a539f2845..57273bf665 100644 --- a/tests/PhpSpreadsheetTests/Shared/DgContainerTest.php +++ b/tests/PhpSpreadsheetTests/Shared/DgContainerTest.php @@ -1,5 +1,7 @@ getSlope(1); diff --git a/tests/PhpSpreadsheetTests/Shared/Trend/LinearBestFitTest.php b/tests/PhpSpreadsheetTests/Shared/Trend/LinearBestFitTest.php index c88ff8d58a..6f150ffa96 100644 --- a/tests/PhpSpreadsheetTests/Shared/Trend/LinearBestFitTest.php +++ b/tests/PhpSpreadsheetTests/Shared/Trend/LinearBestFitTest.php @@ -1,5 +1,7 @@ getSlope(1); diff --git a/tests/PhpSpreadsheetTests/Shared/XmlWriterTest.php b/tests/PhpSpreadsheetTests/Shared/XmlWriterTest.php index 200325137b..63bebc34d9 100644 --- a/tests/PhpSpreadsheetTests/Shared/XmlWriterTest.php +++ b/tests/PhpSpreadsheetTests/Shared/XmlWriterTest.php @@ -1,5 +1,7 @@ |string $fullRange - * @param string $fullRange */ - public function xtestSetRangeValidRange($fullRange, string $actualRange): void + public function xtestSetRangeValidRange(string|array|AddressRange $fullRange, string $actualRange): void { $table = new Table(self::INITIAL_RANGE); diff --git a/tests/PhpSpreadsheetTests/Worksheet/Worksheet2Test.php b/tests/PhpSpreadsheetTests/Worksheet/Worksheet2Test.php index 2b1a2b5d82..8735caccd1 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/Worksheet2Test.php +++ b/tests/PhpSpreadsheetTests/Worksheet/Worksheet2Test.php @@ -1,5 +1,7 @@ rangeToArray($cellRange)); + self::assertSame($expected, $worksheet->rangeToArray((string) $cellRange)); } public static function rangeToArrayProvider(): array diff --git a/tests/PhpSpreadsheetTests/Writer/Csv/CsvEnclosureTest.php b/tests/PhpSpreadsheetTests/Writer/Csv/CsvEnclosureTest.php index 383f83abac..ffbdf453c1 100644 --- a/tests/PhpSpreadsheetTests/Writer/Csv/CsvEnclosureTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Csv/CsvEnclosureTest.php @@ -1,5 +1,7 @@ spreadsheet = new Spreadsheet(); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php b/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php index 92a904660c..1594a6fa34 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/HtmlNumberFormatTest.php @@ -1,5 +1,7 @@ getActiveSheet(); @@ -189,12 +178,8 @@ public static function providerNumberFormat(): array /** * @dataProvider providerNumberFormatDates - * - * @param mixed $expectedResult - * @param mixed $val - * @param mixed $fmt */ - public function testFormatValueWithMaskDate($expectedResult, $val, $fmt): void + public function testFormatValueWithMaskDate(mixed $expectedResult, mixed $val, mixed $fmt): void { $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); diff --git a/tests/PhpSpreadsheetTests/Writer/Html/ImageCopyTest.php b/tests/PhpSpreadsheetTests/Writer/Html/ImageCopyTest.php index adee76b08d..83e8bdf041 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/ImageCopyTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/ImageCopyTest.php @@ -1,5 +1,7 @@ right('00' . dechex((int) ($palette[0])), 2) . $this->right('00' . dechex((int) ($palette[1])), 2) @@ -153,10 +151,8 @@ private function paletteToColor($palette) * * @param string $value text to get right character * @param int $nbchar number of char at right of string - * - * @return string */ - private function right($value, $nbchar) + private function right(string $value, int $nbchar): string { return mb_substr($value, mb_strlen($value) - $nbchar, $nbchar); } diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php index 412ca45be2..5f9c5d91d6 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php @@ -1,5 +1,7 @@ ', false, false], diff --git a/tests/data/Calculation/Calculation.php b/tests/data/Calculation/Calculation.php index e49bed9fed..27cafc90bc 100644 --- a/tests/data/Calculation/Calculation.php +++ b/tests/data/Calculation/Calculation.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Logical/ANDLiteral.php b/tests/data/Calculation/Logical/ANDLiteral.php index 0dff483bb7..0747f8a4a2 100644 --- a/tests/data/Calculation/Logical/ANDLiteral.php +++ b/tests/data/Calculation/Logical/ANDLiteral.php @@ -1,5 +1,7 @@ [true, 'true, true'], 'boolean and string-true' => [true, 'true, "true"'], diff --git a/tests/data/Calculation/Logical/IF.php b/tests/data/Calculation/Logical/IF.php index 3bf7d90f28..1f69d10995 100644 --- a/tests/data/Calculation/Logical/IF.php +++ b/tests/data/Calculation/Logical/IF.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Logical/IFERROR.php b/tests/data/Calculation/Logical/IFERROR.php index a379a5fbf4..ebc6b40605 100644 --- a/tests/data/Calculation/Logical/IFERROR.php +++ b/tests/data/Calculation/Logical/IFERROR.php @@ -1,5 +1,7 @@ [ 0, diff --git a/tests/data/Calculation/Logical/IFNA.php b/tests/data/Calculation/Logical/IFNA.php index d7fb7193f2..4216212a02 100644 --- a/tests/data/Calculation/Logical/IFNA.php +++ b/tests/data/Calculation/Logical/IFNA.php @@ -1,5 +1,7 @@ ['exception'], [ diff --git a/tests/data/Calculation/Logical/NOT.php b/tests/data/Calculation/Logical/NOT.php index 9936c26812..37b94968de 100644 --- a/tests/data/Calculation/Logical/NOT.php +++ b/tests/data/Calculation/Logical/NOT.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Logical/OR.php b/tests/data/Calculation/Logical/OR.php index c5317b3bcb..53aab19704 100644 --- a/tests/data/Calculation/Logical/OR.php +++ b/tests/data/Calculation/Logical/OR.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Logical/ORLiteral.php b/tests/data/Calculation/Logical/ORLiteral.php index 17f4988226..d8331d60ee 100644 --- a/tests/data/Calculation/Logical/ORLiteral.php +++ b/tests/data/Calculation/Logical/ORLiteral.php @@ -1,5 +1,7 @@ [true, 'true, true'], 'boolean or string-true' => [true, 'true, "true"'], diff --git a/tests/data/Calculation/Logical/SWITCH.php b/tests/data/Calculation/Logical/SWITCH.php index 689d1d8faa..724aa09dbf 100644 --- a/tests/data/Calculation/Logical/SWITCH.php +++ b/tests/data/Calculation/Logical/SWITCH.php @@ -1,5 +1,7 @@ [ 'C', diff --git a/tests/data/Calculation/Logical/XOR.php b/tests/data/Calculation/Logical/XOR.php index 57a170a48c..52895d44b8 100644 --- a/tests/data/Calculation/Logical/XOR.php +++ b/tests/data/Calculation/Logical/XOR.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Logical/XORLiteral.php b/tests/data/Calculation/Logical/XORLiteral.php index a0c0be7073..086fb7e83c 100644 --- a/tests/data/Calculation/Logical/XORLiteral.php +++ b/tests/data/Calculation/Logical/XORLiteral.php @@ -1,5 +1,7 @@ [false, 'true, true'], 'boolean xor string-true' => [false, 'true, "true"'], diff --git a/tests/data/Calculation/LookupRef/ADDRESS.php b/tests/data/Calculation/LookupRef/ADDRESS.php index 14a3cf7db8..aaaada75a3 100644 --- a/tests/data/Calculation/LookupRef/ADDRESS.php +++ b/tests/data/Calculation/LookupRef/ADDRESS.php @@ -1,5 +1,7 @@ [1, 'namedrangex'], 'global $f$2:$h$2' => [3, 'namedrangey'], diff --git a/tests/data/Calculation/LookupRef/COLUMNonSpreadsheet.php b/tests/data/Calculation/LookupRef/COLUMNonSpreadsheet.php index cc93653e80..16a43707cb 100644 --- a/tests/data/Calculation/LookupRef/COLUMNonSpreadsheet.php +++ b/tests/data/Calculation/LookupRef/COLUMNonSpreadsheet.php @@ -1,5 +1,7 @@ [2, 'omitted'], 'global name $E$2:$E$6' => [5, 'namedrangex'], diff --git a/tests/data/Calculation/LookupRef/FORMULATEXT.php b/tests/data/Calculation/LookupRef/FORMULATEXT.php index 46639c28cf..e5debe475a 100644 --- a/tests/data/Calculation/LookupRef/FORMULATEXT.php +++ b/tests/data/Calculation/LookupRef/FORMULATEXT.php @@ -1,5 +1,7 @@ ['R' => 1]], // Expected diff --git a/tests/data/Calculation/LookupRef/INDEXonSpreadsheet.php b/tests/data/Calculation/LookupRef/INDEXonSpreadsheet.php index eff13722f3..76f6ddd464 100644 --- a/tests/data/Calculation/LookupRef/INDEXonSpreadsheet.php +++ b/tests/data/Calculation/LookupRef/INDEXonSpreadsheet.php @@ -1,5 +1,7 @@ [ 1, // Expected diff --git a/tests/data/Calculation/LookupRef/INDIRECT.php b/tests/data/Calculation/LookupRef/INDIRECT.php index 7dc2515a31..77554ec85e 100644 --- a/tests/data/Calculation/LookupRef/INDIRECT.php +++ b/tests/data/Calculation/LookupRef/INDIRECT.php @@ -1,5 +1,7 @@ [600, '$A$1:$A$3'], 'cell range on different sheet' => [30, 'OtherSheet!A1:A2'], diff --git a/tests/data/Calculation/LookupRef/LOOKUP.php b/tests/data/Calculation/LookupRef/LOOKUP.php index 9c7d96eb01..84e3e27855 100644 --- a/tests/data/Calculation/LookupRef/LOOKUP.php +++ b/tests/data/Calculation/LookupRef/LOOKUP.php @@ -1,5 +1,7 @@ [ 2, // Expected diff --git a/tests/data/Calculation/LookupRef/OFFSET.php b/tests/data/Calculation/LookupRef/OFFSET.php index 9c2f52c1de..53706dd1f3 100644 --- a/tests/data/Calculation/LookupRef/OFFSET.php +++ b/tests/data/Calculation/LookupRef/OFFSET.php @@ -1,5 +1,7 @@ [5, 'namedrangex'], 'global $F$2:$H$2' => [1, 'namedrangey'], diff --git a/tests/data/Calculation/LookupRef/ROWonSpreadsheet.php b/tests/data/Calculation/LookupRef/ROWonSpreadsheet.php index f2395e6b74..0250934df0 100644 --- a/tests/data/Calculation/LookupRef/ROWonSpreadsheet.php +++ b/tests/data/Calculation/LookupRef/ROWonSpreadsheet.php @@ -1,5 +1,7 @@ [3, 'omitted'], 'global name $E$2:$E$6' => [2, 'namedrangex'], diff --git a/tests/data/Calculation/LookupRef/TRANSPOSE.php b/tests/data/Calculation/LookupRef/TRANSPOSE.php index a5ca45f48f..1f75ff1254 100644 --- a/tests/data/Calculation/LookupRef/TRANSPOSE.php +++ b/tests/data/Calculation/LookupRef/TRANSPOSE.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Statistical/BETADIST.php b/tests/data/Calculation/Statistical/BETADIST.php index ef89575fdd..92b61fc5ae 100644 --- a/tests/data/Calculation/Statistical/BETADIST.php +++ b/tests/data/Calculation/Statistical/BETADIST.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Statistical/COVAR.php b/tests/data/Calculation/Statistical/COVAR.php index d32cc8b3c6..f02bbad8e2 100644 --- a/tests/data/Calculation/Statistical/COVAR.php +++ b/tests/data/Calculation/Statistical/COVAR.php @@ -1,5 +1,7 @@ [ 3, diff --git a/tests/data/Calculation/Statistical/FDIST.php b/tests/data/Calculation/Statistical/FDIST.php index 39be714d99..7ef64c6cb0 100644 --- a/tests/data/Calculation/Statistical/FDIST.php +++ b/tests/data/Calculation/Statistical/FDIST.php @@ -1,5 +1,7 @@ [ 3, diff --git a/tests/data/Calculation/Statistical/HARMEAN.php b/tests/data/Calculation/Statistical/HARMEAN.php index 1c34ff3328..e8db95a6f2 100644 --- a/tests/data/Calculation/Statistical/HARMEAN.php +++ b/tests/data/Calculation/Statistical/HARMEAN.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Statistical/MEDIAN.php b/tests/data/Calculation/Statistical/MEDIAN.php index bde86d480e..3eca4feb82 100644 --- a/tests/data/Calculation/Statistical/MEDIAN.php +++ b/tests/data/Calculation/Statistical/MEDIAN.php @@ -1,5 +1,7 @@ [ 'exception', diff --git a/tests/data/Calculation/Statistical/MODE.php b/tests/data/Calculation/Statistical/MODE.php index 7d27b33e5e..a2d6eb9716 100644 --- a/tests/data/Calculation/Statistical/MODE.php +++ b/tests/data/Calculation/Statistical/MODE.php @@ -1,5 +1,7 @@ [ 5, diff --git a/tests/data/Calculation/Statistical/PERCENTILE.php b/tests/data/Calculation/Statistical/PERCENTILE.php index 890399c531..4cf5173b67 100644 --- a/tests/data/Calculation/Statistical/PERCENTILE.php +++ b/tests/data/Calculation/Statistical/PERCENTILE.php @@ -1,5 +1,7 @@ ["\x00", '=CHAR(0)'], 'OO treats CODE(bool) as 0/1' => ['48', '=CODE(FALSE)'], diff --git a/tests/data/Calculation/TextData/PROPER.php b/tests/data/Calculation/TextData/PROPER.php index e9a5d4ceb6..6798151c07 100644 --- a/tests/data/Calculation/TextData/PROPER.php +++ b/tests/data/Calculation/TextData/PROPER.php @@ -1,5 +1,7 @@ ['exception'], 'one argument' => ['exception', 'ABC'], diff --git a/tests/data/Calculation/TextData/RIGHT.php b/tests/data/Calculation/TextData/RIGHT.php index 77ea64bf71..922a3591e3 100644 --- a/tests/data/Calculation/TextData/RIGHT.php +++ b/tests/data/Calculation/TextData/RIGHT.php @@ -1,5 +1,7 @@ ['=D3+F7+G4+C6+5', '=R3C4+R7C6+R4C7+R6C3+5'], 'Basic subtraction' => ['=D3-F7-G4-C6-5', '=R3C4-R7C6-R4C7-R6C3-5'], diff --git a/tests/data/Cell/ConvertFormulaToA1FromR1C1Relative.php b/tests/data/Cell/ConvertFormulaToA1FromR1C1Relative.php index d6df418cda..84e11af3b1 100644 --- a/tests/data/Cell/ConvertFormulaToA1FromR1C1Relative.php +++ b/tests/data/Cell/ConvertFormulaToA1FromR1C1Relative.php @@ -1,5 +1,7 @@ ['=D3+F7+G4+C6+5', '=R[-2]C[-1]+R[2]C[1]+R[-1]C[2]+R[1]C[-2]+5', 5, 5], 'Basic subtraction' => ['=D3-F7-G4-C6-5', '=R[-2]C[-1]-R[2]C[1]-R[-1]C[2]-R[1]C[-2]-5', 5, 5], diff --git a/tests/data/Cell/ConvertFormulaToA1FromSpreadsheetXml.php b/tests/data/Cell/ConvertFormulaToA1FromSpreadsheetXml.php index d350c07b30..915d1a4689 100644 --- a/tests/data/Cell/ConvertFormulaToA1FromSpreadsheetXml.php +++ b/tests/data/Cell/ConvertFormulaToA1FromSpreadsheetXml.php @@ -1,5 +1,7 @@ ['=D3+F7+G4+C6+5', 'of:=[.D3]+[.F7]+[.G4]+[.C6]+5'], 'Basic subtraction' => ['=D3-F7-G4-C6-5', 'of:=[.D3]-[.F7]-[.G4]-[.C6]-5'], diff --git a/tests/data/Cell/DefaultValueBinder.php b/tests/data/Cell/DefaultValueBinder.php index f5dafc7bc1..b9f3d51e11 100644 --- a/tests/data/Cell/DefaultValueBinder.php +++ b/tests/data/Cell/DefaultValueBinder.php @@ -1,5 +1,7 @@ [ diff --git a/tests/data/CellMergeRangesInCollection.php b/tests/data/CellMergeRangesInCollection.php index 0a7723ee00..3be59edc36 100644 --- a/tests/data/CellMergeRangesInCollection.php +++ b/tests/data/CellMergeRangesInCollection.php @@ -1,5 +1,7 @@ [ [ diff --git a/tests/data/CellRangeDimension.php b/tests/data/CellRangeDimension.php index a3e15531cd..ca289179b3 100644 --- a/tests/data/CellRangeDimension.php +++ b/tests/data/CellRangeDimension.php @@ -1,5 +1,7 @@ 19-Dec-1960 05:00:00 UTC diff --git a/tests/data/Shared/Date/ExcelToTimestamp1904.php b/tests/data/Shared/Date/ExcelToTimestamp1904.php index 82fcde1cf9..12a3999a91 100644 --- a/tests/data/Shared/Date/ExcelToTimestamp1904.php +++ b/tests/data/Shared/Date/ExcelToTimestamp1904.php @@ -1,5 +1,7 @@ [0.8, 0.813512072856517], diff --git a/tests/data/Shared/Trend/LinearBestFit.php b/tests/data/Shared/Trend/LinearBestFit.php index b1be2f9a57..046fdb6ee1 100644 --- a/tests/data/Shared/Trend/LinearBestFit.php +++ b/tests/data/Shared/Trend/LinearBestFit.php @@ -1,5 +1,7 @@ [-1.1, -1.1064189189190], diff --git a/tests/data/Style/Color/ColorChangeBrightness.php b/tests/data/Style/Color/ColorChangeBrightness.php index 1c552e157d..6d9f038360 100644 --- a/tests/data/Style/Color/ColorChangeBrightness.php +++ b/tests/data/Style/Color/ColorChangeBrightness.php @@ -1,5 +1,7 @@