From 4b0da60ec4e94469a9e822aac7b8e545f0cdf7bf Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Fri, 8 Sep 2023 00:18:38 +0800 Subject: [PATCH] Rector ParamTypeByMethodCallTypeRector --- .../Calculation/Calculation.php | 20 +++++----------- src/PhpSpreadsheet/Calculation/Financial.php | 2 +- .../CashFlow/Variable/NonPeriodic.php | 2 +- src/PhpSpreadsheet/Calculation/MathTrig.php | 5 ++-- .../Calculation/Statistical.php | 24 +++++++++---------- .../Calculation/Statistical/Conditional.php | 5 ++-- .../Calculation/Statistical/Trends.php | 24 +++++++++---------- .../Calculation/TextData/Extract.php | 3 +-- src/PhpSpreadsheet/Cell/Coordinate.php | 4 ++-- src/PhpSpreadsheet/Chart/Axis.php | 2 +- src/PhpSpreadsheet/Chart/Properties.php | 7 ++---- src/PhpSpreadsheet/Reader/Ods.php | 12 +++------- src/PhpSpreadsheet/Reader/Slk.php | 8 ++----- src/PhpSpreadsheet/Reader/Xls.php | 18 +++++--------- src/PhpSpreadsheet/Reader/Xlsx.php | 8 ++----- src/PhpSpreadsheet/Shared/Font.php | 3 +-- src/PhpSpreadsheet/Shared/Xls.php | 2 +- src/PhpSpreadsheet/Spreadsheet.php | 2 +- src/PhpSpreadsheet/Style/RgbTint.php | 2 +- .../Worksheet/ColumnCellIterator.php | 2 +- .../Worksheet/ColumnIterator.php | 2 +- .../Worksheet/RowCellIterator.php | 2 +- src/PhpSpreadsheet/Worksheet/RowIterator.php | 2 +- src/PhpSpreadsheet/Worksheet/Table.php | 2 +- src/PhpSpreadsheet/Worksheet/Worksheet.php | 6 ++--- src/PhpSpreadsheet/Writer/Html.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Workbook.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Comments.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 2 +- .../Functions/Statistical/PercentRankTest.php | 2 +- 30 files changed, 72 insertions(+), 107 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 6bdfb2a97..7e1ae9b6e 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3339,10 +3339,7 @@ class Calculation /** @var ?array */ private static $functionReplaceToLocale; - /** - * @param string $formula - */ - public function _translateFormulaToLocale($formula): string + public function _translateFormulaToLocale(string $formula): string { // Build list of function names and constants for translation if (self::$functionReplaceFromExcel === null) { @@ -3380,10 +3377,7 @@ class Calculation /** @var ?array */ private static $functionReplaceToExcel; - /** - * @param string $formula - */ - public function _translateFormulaToEnglish($formula): string + public function _translateFormulaToEnglish(string $formula): string { if (self::$functionReplaceFromLocale === null) { self::$functionReplaceFromLocale = []; @@ -5256,11 +5250,10 @@ class Calculation /** * @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) { $result = []; if (!is_array($operand2)) { @@ -5302,11 +5295,10 @@ class Calculation /** * @param mixed $operand1 * @param mixed $operand2 - * @param string $operation * * @return mixed */ - private function executeBinaryComparisonOperation($operand1, $operand2, $operation, Stack &$stack, bool $recursingArrays = false) + private function executeBinaryComparisonOperation($operand1, $operand2, string $operation, Stack &$stack, bool $recursingArrays = false) { // If we're dealing with matrix operations, we want a matrix result if ((is_array($operand1)) || (is_array($operand2))) { @@ -5484,7 +5476,7 @@ class Calculation * * @return mixed 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) { // Return value $returnValue = []; @@ -5536,7 +5528,7 @@ class Calculation * * @return mixed 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) { // Return value $returnValue = []; diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index dcca5f880..dfe011ef8 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -1290,7 +1290,7 @@ class Financial * * @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/CashFlow/Variable/NonPeriodic.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php index b4247b704..3695e59db 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 !== '') { diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index a92e9c82e..56b95242c 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -762,13 +762,12 @@ class MathTrig * 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); } diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 4231d54d9..cea7af453 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -365,12 +365,12 @@ class Statistical * 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); } @@ -516,12 +516,12 @@ class Statistical * @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); } @@ -729,7 +729,7 @@ class Statistical * * @return float|string */ - public static function INTERCEPT($yValues, $xValues) + public static function INTERCEPT(array $yValues, array $xValues) { return Trends::INTERCEPT($yValues, $xValues); } @@ -794,7 +794,7 @@ class Statistical * * @return array|int|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) { return Trends::LINEST($yValues, $xValues, $const, $stats); } @@ -816,7 +816,7 @@ class Statistical * * @return array|int|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) { return Trends::LOGEST($yValues, $xValues, $const, $stats); } @@ -1328,7 +1328,7 @@ class Statistical * * @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); } @@ -1368,7 +1368,7 @@ class Statistical * * @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); } @@ -1514,7 +1514,7 @@ class Statistical * * @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/Conditional.php b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php index 0f35d5661..12e238aeb 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php @@ -183,13 +183,12 @@ class Conditional * 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]]; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php index 705de17d8..ae479f3d9 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php @@ -90,12 +90,12 @@ class Trends * * 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 @@ class Trends * * @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 @@ class Trends * * @return float|string */ - public static function INTERCEPT($yValues, $xValues) + public static function INTERCEPT(array $yValues, array $xValues) { try { self::checkTrendArrays($yValues, $xValues); @@ -212,7 +212,7 @@ class Trends * * @return array|int|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) { $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats); @@ -273,7 +273,7 @@ class Trends * * @return array|int|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) { $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats); @@ -338,7 +338,7 @@ class Trends * * @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 @@ class Trends * * @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 @@ class Trends * * @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/TextData/Extract.php b/src/PhpSpreadsheet/Calculation/TextData/Extract.php index 95b4b3eae..9a90b10ba 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Extract.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Extract.php @@ -218,13 +218,12 @@ class Extract /** * @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); diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index 977bdb614..af30ecc81 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -233,7 +233,7 @@ abstract class Coordinate * * @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 @@ abstract class Coordinate * @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); diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index 318068e60..29f8d2d00 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -231,7 +231,7 @@ class Axis extends Properties * @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); } diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index edb775456..028192da1 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -611,11 +611,9 @@ abstract class Properties /** * 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)); @@ -780,11 +778,10 @@ abstract class Properties /** * 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/Reader/Ods.php b/src/PhpSpreadsheet/Reader/Ods.php index 8fb8cd4bd..3ef61cbcb 100644 --- a/src/PhpSpreadsheet/Reader/Ods.php +++ b/src/PhpSpreadsheet/Reader/Ods.php @@ -88,11 +88,9 @@ class Ods extends BaseReader /** * 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) { File::assertFile($filename, self::INITIAL_FILE); @@ -139,11 +137,9 @@ class Ods extends BaseReader /** * 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) { File::assertFile($filename, self::INITIAL_FILE); @@ -248,11 +244,9 @@ class Ods extends BaseReader /** * 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) { File::assertFile($filename, self::INITIAL_FILE); diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 525e9c7dc..e4187a9dd 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -132,11 +132,9 @@ class Slk extends BaseReader /** * 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) { // Open file $this->canReadOrBust($filename); @@ -504,11 +502,9 @@ class Slk extends BaseReader /** * 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); diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 343077949..56668b8f9 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -467,11 +467,9 @@ class Xls extends BaseReader /** * 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) { File::assertFile($filename); @@ -529,11 +527,9 @@ class Xls extends BaseReader /** * 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) { File::assertFile($filename); @@ -1394,10 +1390,8 @@ class Xls extends BaseReader /** * 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(); @@ -5257,7 +5251,7 @@ class Xls extends BaseReader * * @return string Human readable formula */ - private function getFormulaFromData(string $formulaData, string $additionalData = '', $baseCell = 'A1'): string + private function getFormulaFromData(string $formulaData, string $additionalData = '', string $baseCell = 'A1'): string { // start parsing the formula data $tokens = []; @@ -5454,7 +5448,7 @@ class Xls extends BaseReader * * @return array */ - private function getNextToken(string $formulaData, $baseCell = 'A1') + private function getNextToken(string $formulaData, string $baseCell = 'A1') { // offset: 0; size: 1; token id $id = ord($formulaData[0]); // token id @@ -7227,7 +7221,7 @@ class Xls extends BaseReader * * @return string Cell range address */ - private function readBIFF8CellRangeAddressB(string $subData, $baseCell = 'A1'): string + private function readBIFF8CellRangeAddressB(string $subData, string $baseCell = 'A1'): string { [$baseCol, $baseRow] = Coordinate::indexesFromString($baseCell); $baseCol = $baseCol - 1; diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 77550128d..ebe5500e7 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -175,11 +175,9 @@ class Xlsx extends BaseReader /** * 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) { File::assertFile($filename, self::INITIAL_FILE); @@ -214,11 +212,9 @@ class Xlsx extends BaseReader /** * 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) { File::assertFile($filename, self::INITIAL_FILE); diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index 56e1ec711..717e8e0ac 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -470,12 +470,11 @@ class Font /** * 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): int + public static function getTextWidthPixelsApprox(string $columnText, FontStyle $font, $rotation = 0): int { $fontName = $font->getName(); $fontSize = $font->getSize(); diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php index bbc294adc..c36e4ee8f 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -206,7 +206,7 @@ class Xls * * @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) { [$col_start, $row] = Coordinate::indexesFromString($coordinates); $row_start = $row - 1; diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 6f5c222b3..1f320f353 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -760,7 +760,7 @@ class Spreadsheet implements JsonSerializable * * @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( diff --git a/src/PhpSpreadsheet/Style/RgbTint.php b/src/PhpSpreadsheet/Style/RgbTint.php index 582ae4839..9c0ce7f12 100644 --- a/src/PhpSpreadsheet/Style/RgbTint.php +++ b/src/PhpSpreadsheet/Style/RgbTint.php @@ -72,7 +72,7 @@ class RgbTint * * @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/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index ed88d4eca..6d9a2d563 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -47,7 +47,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; diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index fffef1292..761e4c39f 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; diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 0df776f2a..4647df29e 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -47,7 +47,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; diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index af2bda25a..12baee797 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; diff --git a/src/PhpSpreadsheet/Worksheet/Table.php b/src/PhpSpreadsheet/Worksheet/Table.php index a57317ef3..520796d85 100644 --- a/src/PhpSpreadsheet/Worksheet/Table.php +++ b/src/PhpSpreadsheet/Worksheet/Table.php @@ -412,7 +412,7 @@ class Table * * @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); } diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 8e92e5ef5..564279a46 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -1243,7 +1243,7 @@ class Worksheet implements IComparable * * @return $this */ - public function setCellValueExplicit($coordinate, $value, $dataType) + public function setCellValueExplicit($coordinate, $value, string $dataType) { $cellAddress = Functions::trimSheetFromCellReference(Validations::validateCellAddress($coordinate)); $this->getCell($cellAddress)->setValueExplicit($value, $dataType); @@ -1273,7 +1273,7 @@ class Worksheet implements IComparable * * @return $this */ - public function setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, $dataType) + public function setCellValueExplicitByColumnAndRow($columnIndex, $row, $value, string $dataType) { $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValueExplicit($value, $dataType); @@ -1417,7 +1417,7 @@ class Worksheet implements IComparable * 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); diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 67bd33a4b..4b923791b 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -1473,7 +1473,7 @@ class Html extends BaseWriter * @param int $row Row number (0-based) * @param string $cellType eg: 'td' */ - private function generateRow(Worksheet $worksheet, array $values, int $row, $cellType): string + private function generateRow(Worksheet $worksheet, array $values, int $row, string $cellType): string { // Sheet index $sheetIndex = $worksheet->getParentOrThrow()->getIndex($worksheet); diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index fd7f461cf..30afa28e0 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -939,7 +939,7 @@ class Workbook extends BIFFwriter * @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 diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index 91973884c..f2b118b7c 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -161,7 +161,7 @@ class Comments extends WriterPart * @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/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 0e72c5d12..e36b85314 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/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php index 83b091fe2..153b76822 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/PercentRankTest.php @@ -11,7 +11,7 @@ class PercentRankTest extends AllSetupTeardown * * @param mixed[] $valueSet */ - public function testPERCENTRANK(mixed $expectedResult, $valueSet, mixed $value, mixed $digits = null): void + public function testPERCENTRANK(mixed $expectedResult, mixed $valueSet, mixed $value, mixed $digits = null): void { if ($digits === null) { $this->runTestCaseReference('PERCENTRANK', $expectedResult, $valueSet, $value);