From 92b5ab80232dc4d39138faa9595217571741f0af Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 15 Nov 2023 12:26:06 +0900 Subject: [PATCH 01/25] Add all missing types --- .../Calculation/MathTrig/Arabic.php | 6 ++-- .../Calculation/Statistical/AggregateBase.php | 2 +- .../Calculation/Statistical/Averages.php | 8 ++--- src/PhpSpreadsheet/Cell/AddressRange.php | 10 ++---- .../Cell/AdvancedValueBinder.php | 4 +-- .../Cell/DefaultValueBinder.php | 4 +-- src/PhpSpreadsheet/Chart/Axis.php | 10 ++---- src/PhpSpreadsheet/Style/Alignment.php | 34 +++++-------------- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 32 +++++------------ 9 files changed, 31 insertions(+), 79 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php b/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php index 3c32476d1c..4b780ab13a 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php @@ -25,10 +25,8 @@ class Arabic * * @param int $sum * @param int $subtract - * - * @return int */ - private static function calculateArabic(array $roman, &$sum = 0, $subtract = 0) + private static function calculateArabic(array $roman, &$sum = 0, $subtract = 0): int { $numeral = array_shift($roman); if (!isset(self::ROMAN_LOOKUP[$numeral])) { @@ -64,7 +62,7 @@ private static function calculateArabic(array $roman, &$sum = 0, $subtract = 0) * 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(mixed $roman) + public static function evaluate(mixed $roman): array|int|string { if (is_array($roman)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $roman); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php b/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php index 591b409d98..f8b2eddf53 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php @@ -13,7 +13,7 @@ abstract class AggregateBase * * @return int|mixed */ - protected static function testAcceptedBoolean(mixed $arg, mixed $k) + protected static function testAcceptedBoolean(mixed $arg, mixed $k): mixed { if (!is_bool($arg)) { return $arg; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Averages.php b/src/PhpSpreadsheet/Calculation/Statistical/Averages.php index d158d135e0..cd7a9f8125 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Averages.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Averages.php @@ -147,7 +147,7 @@ public static function averageA(mixed ...$args): string|int|float * * @return float|string The result, or a string containing an error */ - public static function median(mixed ...$args) + public static function median(mixed ...$args): float|string { $aArgs = Functions::flattenArray($args); @@ -181,7 +181,7 @@ public static function median(mixed ...$args) * * @return float|string The result, or a string containing an error */ - public static function mode(mixed ...$args) + public static function mode(mixed ...$args): float|string { $returnValue = ExcelError::NA(); @@ -210,10 +210,8 @@ function ($value): bool { /** * Special variant of array_count_values that isn't limited to strings and integers, * but can work with floating point numbers as values. - * - * @return float|string */ - private static function modeCalc(array $data) + private static function modeCalc(array $data): float|string { $frequencyArray = []; $index = 0; diff --git a/src/PhpSpreadsheet/Cell/AddressRange.php b/src/PhpSpreadsheet/Cell/AddressRange.php index 614abe9977..0217504b58 100644 --- a/src/PhpSpreadsheet/Cell/AddressRange.php +++ b/src/PhpSpreadsheet/Cell/AddressRange.php @@ -10,15 +10,9 @@ interface AddressRange public const MAX_COLUMN_INT = 16384; - /** - * @return mixed - */ - public function from(); + public function from(): mixed; - /** - * @return mixed - */ - public function to(); + public function to(): mixed; public function __toString(): string; } diff --git a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php index 33302c5419..09c2f749da 100644 --- a/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php +++ b/src/PhpSpreadsheet/Cell/AdvancedValueBinder.php @@ -16,10 +16,8 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder * * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell - * - * @return bool */ - public function bindValue(Cell $cell, $value = null) + public function bindValue(Cell $cell, $value = null): bool { if ($value === null) { return parent::bindValue($cell, $value); diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index f86e37cc4f..dfe025b4b7 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -15,10 +15,8 @@ class DefaultValueBinder implements IValueBinder * * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell - * - * @return bool */ - public function bindValue(Cell $cell, $value) + public function bindValue(Cell $cell, $value): bool { // sanitize UTF-8 strings if (is_string($value)) { diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index 7de219184a..90f1f50317 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -103,10 +103,8 @@ public function setAxisNumberProperties(mixed $format_code, ?bool $numeric = nul /** * Get Axis Number Format Data Type. - * - * @return string */ - public function getAxisNumberFormat() + public function getAxisNumberFormat(): string { return $this->axisNumber['format']; } @@ -175,7 +173,7 @@ public function setAxisOptionsProperties( * * @return ?string */ - public function getAxisOptionsProperty($property) + public function getAxisOptionsProperty($property): ?string { if ($property === 'textRotation') { if ($this->axisText !== null) { @@ -247,10 +245,8 @@ public function getFillColorObject(): ChartColor * @see Properties::getLineColorProperty() * * @param string $propertyName - * - * @return null|int|string */ - public function getLineProperty($propertyName) + public function getLineProperty($propertyName): null|int|string { return $this->getLineColorProperty($propertyName); } diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 90d607e92d..6f87fd6b5d 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -166,10 +166,8 @@ public function __construct($isSupervisor = false, $isConditional = false) /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return Alignment */ - public function getSharedComponent() + public function getSharedComponent(): self { /** @var Style */ $parent = $this->parent; @@ -239,10 +237,8 @@ public function applyFromArray(array $styleArray): static /** * Get Horizontal. - * - * @return null|string */ - public function getHorizontal() + public function getHorizontal(): null|string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHorizontal(); @@ -277,10 +273,8 @@ public function setHorizontal(string $horizontalAlignment): static /** * Get Vertical. - * - * @return null|string */ - public function getVertical() + public function getVertical(): null|string { if ($this->isSupervisor) { return $this->getSharedComponent()->getVertical(); @@ -312,10 +306,8 @@ public function setVertical($verticalAlignment): static /** * Get TextRotation. - * - * @return null|int */ - public function getTextRotation() + public function getTextRotation(): null|int { if ($this->isSupervisor) { return $this->getSharedComponent()->getTextRotation(); @@ -355,10 +347,8 @@ public function setTextRotation($angleInDegrees): static /** * Get Wrap Text. - * - * @return bool */ - public function getWrapText() + public function getWrapText(): bool { if ($this->isSupervisor) { return $this->getSharedComponent()->getWrapText(); @@ -391,10 +381,8 @@ public function setWrapText($wrapped): static /** * Get Shrink to fit. - * - * @return bool */ - public function getShrinkToFit() + public function getShrinkToFit(): bool { if ($this->isSupervisor) { return $this->getSharedComponent()->getShrinkToFit(); @@ -427,10 +415,8 @@ public function setShrinkToFit($shrink): static /** * Get indent. - * - * @return int */ - public function getIndent() + public function getIndent(): int { if ($this->isSupervisor) { return $this->getSharedComponent()->getIndent(); @@ -470,10 +456,8 @@ public function setIndent($indent): static /** * Get read order. - * - * @return int */ - public function getReadOrder() + public function getReadOrder(): int { if ($this->isSupervisor) { return $this->getSharedComponent()->getReadOrder(); @@ -509,7 +493,7 @@ public function setReadOrder($readOrder): static * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHashCode(); diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index ec50e8c83f..58c19f97de 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -71,10 +71,8 @@ public function __destruct() /** * Get AutoFilter Parent Worksheet. - * - * @return null|Worksheet */ - public function getParent() + public function getParent(): null|Worksheet { return $this->workSheet; } @@ -94,10 +92,8 @@ public function setParent(?Worksheet $worksheet = null): static /** * Get AutoFilter Range. - * - * @return string */ - public function getRange() + public function getRange(): string { return $this->range; } @@ -162,7 +158,7 @@ public function setRangeToMaxRow(): self * * @return AutoFilter\Column[] */ - public function getColumns() + public function getColumns(): array { return $this->columns; } @@ -196,7 +192,7 @@ public function testColumnInRange($column): int * * @return int The offset of the specified column within the autofilter range */ - public function getColumnOffset($column) + public function getColumnOffset($column): int { return $this->testColumnInRange($column); } @@ -205,10 +201,8 @@ public function getColumnOffset($column) * Get a specified AutoFilter Column. * * @param string $column Column name (e.g. A) - * - * @return AutoFilter\Column */ - public function getColumn($column) + public function getColumn($column): AutoFilter\Column { $this->testColumnInRange($column); @@ -223,10 +217,8 @@ public function getColumn($column) * Get a specified AutoFilter Column by it's offset. * * @param int $columnOffset Column offset within range (starting from 0) - * - * @return AutoFilter\Column */ - public function getColumnByOffset($columnOffset) + public function getColumnByOffset($columnOffset): AutoFilter\Column { [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range); $pColumn = Coordinate::stringFromColumnIndex($rangeStart[0] + $columnOffset); @@ -319,10 +311,8 @@ public function shiftColumn($fromColumn, $toColumn): static * Test if cell value is in the defined set of values. * * @param mixed[] $dataSet - * - * @return bool */ - protected static function filterTestInSimpleDataSet(mixed $cellValue, array $dataSet) + protected static function filterTestInSimpleDataSet(mixed $cellValue, array $dataSet): bool { $dataSetValues = $dataSet['filterValues']; $blanks = $dataSet['blanks']; @@ -337,10 +327,8 @@ protected static function filterTestInSimpleDataSet(mixed $cellValue, array $dat * Test if cell value is in the defined set of Excel date values. * * @param mixed[] $dataSet - * - * @return bool */ - protected static function filterTestInDateGroupSet(mixed $cellValue, array $dataSet) + protected static function filterTestInDateGroupSet(mixed $cellValue, array $dataSet): bool { $dateSet = $dataSet['filterValues']; $blanks = $dataSet['blanks']; @@ -765,10 +753,8 @@ private function dynamicFilterDateRange($dynamicRuleType, AutoFilter\Column &$fi * Apply the AutoFilter rules to the AutoFilter Range. * * @param ?string $ruleType - * - * @return mixed */ - private function calculateTopTenValue(string $columnID, int $startRow, int $endRow, $ruleType, mixed $ruleValue) + private function calculateTopTenValue(string $columnID, int $startRow, int $endRow, $ruleType, mixed $ruleValue): mixed { $range = $columnID . $startRow . ':' . $columnID . $endRow; $retVal = null; From c303df24081430dccdcdd294a50a4330a345b512 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Dec 2023 16:30:22 +0100 Subject: [PATCH 02/25] Type all interfaces --- phpstan-baseline.neon | 225 ++++++++++++++++++ phpstan.neon.dist | 5 + .../Autofilter/10_Autofilter_selection_2.php | 2 +- samples/Basic/24_Readfilter.php | 2 +- samples/Basic/39_Dropdown.php | 6 +- .../Chart/33_Chart_create_line_dateaxis.php | 4 +- samples/Chart/33_Chart_create_radar.php | 2 +- samples/Chart/33_Chart_create_scatter.php | 2 +- samples/Chart/33_Chart_create_scatter2.php | 4 +- samples/Chart/33_Chart_create_scatter4.php | 2 +- .../33_Chart_create_scatter5_trendlines.php | 6 +- .../33_Chart_create_scatter6_value_xaxis.php | 14 +- .../CrossWorksheetNamedFormula.php | 2 +- samples/Pdf/21b_Pdf.php | 2 +- samples/Pdf/21c_Pdf.php | 2 +- ...eader_loading_several_named_worksheets.php | 2 +- ...Simple_file_reader_using_a_read_filter.php | 2 +- ...eader_using_a_configurable_read_filter.php | 18 +- ...a_configurable_read_filter_(version_1).php | 11 +- ...a_configurable_read_filter_(version_2).php | 11 +- ...ks_to_split_across_multiple_worksheets.php | 11 +- src/PhpSpreadsheet/Cell/DataValidation.php | 24 +- src/PhpSpreadsheet/Cell/IValueBinder.php | 4 +- src/PhpSpreadsheet/Chart/Axis.php | 8 +- src/PhpSpreadsheet/Chart/DataSeries.php | 13 +- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 3 +- src/PhpSpreadsheet/Chart/Properties.php | 19 +- .../Chart/Renderer/IRenderer.php | 2 +- .../Chart/Renderer/JpGraphRendererBase.php | 2 +- src/PhpSpreadsheet/IComparable.php | 2 +- src/PhpSpreadsheet/Reader/BaseReader.php | 28 +-- src/PhpSpreadsheet/Reader/IReadFilter.php | 4 +- src/PhpSpreadsheet/Reader/IReader.php | 63 ++--- src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 4 +- src/PhpSpreadsheet/RichText/ITextElement.php | 14 +- src/PhpSpreadsheet/RichText/Run.php | 4 +- src/PhpSpreadsheet/RichText/TextElement.php | 10 +- src/PhpSpreadsheet/Style/Border.php | 2 +- src/PhpSpreadsheet/Style/Borders.php | 2 +- src/PhpSpreadsheet/Style/Fill.php | 2 +- src/PhpSpreadsheet/Style/Font.php | 2 +- src/PhpSpreadsheet/Style/NumberFormat.php | 2 +- src/PhpSpreadsheet/Style/Protection.php | 2 +- src/PhpSpreadsheet/Style/Style.php | 4 +- src/PhpSpreadsheet/Worksheet/Worksheet.php | 2 +- src/PhpSpreadsheet/Writer/BaseWriter.php | 18 +- src/PhpSpreadsheet/Writer/IWriter.php | 33 +-- .../Chart/DataSeriesColorTest.php | 4 +- .../Chart/GridlinesLineStyleTest.php | 8 +- .../Chart/LineStylesTest.php | 4 +- 50 files changed, 397 insertions(+), 227 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index c7cbf42ca9..ff99e79fcc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,5 +1,230 @@ parameters: ignoreErrors: + - + message: "#^Parameter \\#1 \\$formula of method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\DataValidation\\:\\:setFormula1\\(\\) expects string, int given\\.$#" + count: 1 + path: samples/Basic/15_Datavalidation.php + + - + message: "#^Parameter \\#1 \\$formula of method PhpOffice\\\\PhpSpreadsheet\\\\Cell\\\\DataValidation\\:\\:setFormula2\\(\\) expects string, int given\\.$#" + count: 1 + path: samples/Basic/15_Datavalidation.php + + - + message: "#^Parameter \\#6 \\$color of function imagestring expects int, int\\|false given\\.$#" + count: 1 + path: samples/Basic/25_In_memory_image.php + + - + message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: samples/Basic/39_Dropdown.php + + - + message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\\\|false given\\.$#" + count: 2 + path: samples/Basic/39_Dropdown.php + + - + message: "#^Parameter \\#2 \\$array of function array_map expects array, array\\\\|false given\\.$#" + count: 1 + path: samples/Basic/39_Dropdown.php + + - + message: "#^Part \\$result \\(array\\|float\\|string\\) of encapsed string cannot be cast to string\\.$#" + count: 1 + path: samples/Calculations/Engineering/Convert-Online.php + + - + message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: samples/Chart/32_Chart_read_write.php + + - + message: "#^Cannot call method getPlotArea\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 3 + path: samples/Chart/32_Chart_read_write.php + + - + message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 2 + path: samples/Chart/32_Chart_read_write.php + + - + message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" + count: 1 + path: samples/Chart/32_Chart_read_write.php + + - + message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: samples/Chart/32_Chart_read_write_HTML.php + + - + message: "#^Cannot call method getPlotArea\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 3 + path: samples/Chart/32_Chart_read_write_HTML.php + + - + message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 2 + path: samples/Chart/32_Chart_read_write_HTML.php + + - + message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" + count: 1 + path: samples/Chart/32_Chart_read_write_HTML.php + + - + message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: samples/Chart/32_Chart_read_write_PDF.php + + - + message: "#^Cannot call method getPlotArea\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 3 + path: samples/Chart/32_Chart_read_write_PDF.php + + - + message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 2 + path: samples/Chart/32_Chart_read_write_PDF.php + + - + message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" + count: 1 + path: samples/Chart/32_Chart_read_write_PDF.php + + - + message: "#^Cannot call method format\\(\\) on DateTime\\|false\\.$#" + count: 5 + path: samples/Chart/33_Chart_create_line_dateaxis.php + + - + message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: samples/Chart/35_Chart_render.php + + - + message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 2 + path: samples/Chart/35_Chart_render.php + + - + message: "#^Cannot call method render\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 1 + path: samples/Chart/35_Chart_render.php + + - + message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\\\|false given\\.$#" + count: 1 + path: samples/Chart/35_Chart_render.php + + - + message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" + count: 1 + path: samples/Chart/35_Chart_render.php + + - + message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" + count: 1 + path: samples/Chart/35_Chart_render33.php + + - + message: "#^Call to function in_array\\(\\) with arguments string, array\\{\\} and true will always evaluate to false\\.$#" + count: 1 + path: samples/Chart/35_Chart_render33.php + + - + message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 2 + path: samples/Chart/35_Chart_render33.php + + - + message: "#^Cannot call method render\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" + count: 1 + path: samples/Chart/35_Chart_render33.php + + - + message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\\\|false given\\.$#" + count: 1 + path: samples/Chart/35_Chart_render33.php + + - + message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" + count: 1 + path: samples/Chart/35_Chart_render33.php + + - + message: "#^Call to method save\\(\\) on an unknown class PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Pdf\\\\Mpdf2\\.$#" + count: 1 + path: samples/Pdf/21e_UnusualFont_mpdf.php + + - + message: "#^Instantiated class PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Pdf\\\\Mpdf2 not found\\.$#" + count: 1 + path: samples/Pdf/21e_UnusualFont_mpdf.php + + - + message: "#^Call to an undefined method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\BaseReader\\:\\:setContiguous\\(\\)\\.$#" + count: 1 + path: samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php + + - + message: "#^Parameter \\#6 \\$color of function imagestring expects int, int\\|false given\\.$#" + count: 1 + path: samples/Reader/20_Reader_worksheet_hyperlink_image.php + + - + message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Accounting.php + + - + message: "#^Parameter \\#2 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Accounting constructor expects int, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Accounting.php + + - + message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Currency.php + + - + message: "#^Parameter \\#2 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Currency constructor expects int, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Currency.php + + - + message: "#^Parameter \\#1 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Number constructor expects int, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Number.php + + - + message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Number.php + + - + message: "#^Parameter \\#1 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Percentage constructor expects int, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Percentage.php + + - + message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Percentage.php + + - + message: "#^Parameter \\#1 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Scientific constructor expects int, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Scientific.php + + - + message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" + count: 1 + path: samples/Wizards/NumberFormat/Scientific.php + - message: "#^Cannot call method getTokenSubType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" count: 4 diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f6ce123adc..4c942ef72e 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -6,6 +6,7 @@ includes: parameters: level: 8 paths: + - samples/ - src/ - tests/ excludePaths: @@ -21,3 +22,7 @@ parameters: ignoreErrors: # Accept a bit anything for assert methods - '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~' + - '~^Variable \$helper might not be defined\.$~' + - + message: '~^Cannot call method \w+\(\) on PhpOffice\\PhpSpreadsheet\\.*\|null\.$~' + path: samples/ diff --git a/samples/Autofilter/10_Autofilter_selection_2.php b/samples/Autofilter/10_Autofilter_selection_2.php index 4d5d891cff..6b82bcdf52 100644 --- a/samples/Autofilter/10_Autofilter_selection_2.php +++ b/samples/Autofilter/10_Autofilter_selection_2.php @@ -126,7 +126,7 @@ $autoFilter->getColumn('D') ->setFilterType(Column::AUTOFILTER_FILTERTYPE_DYNAMICFILTER) ->createRule() - ->setRule(Rule::AUTOFILTER_COLUMN_RULE_EQUAL, null, Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE) + ->setRule(Rule::AUTOFILTER_COLUMN_RULE_EQUAL, '', Rule::AUTOFILTER_RULETYPE_DYNAMIC_YEARTODATE) ->setRuleType(Rule::AUTOFILTER_RULETYPE_DYNAMICFILTER); $helper->log('Add filter on the Date (Column D) to display year to date'); diff --git a/samples/Basic/24_Readfilter.php b/samples/Basic/24_Readfilter.php index e5b613a67e..0f73818f9e 100644 --- a/samples/Basic/24_Readfilter.php +++ b/samples/Basic/24_Readfilter.php @@ -18,7 +18,7 @@ class MyReadFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Read title row and rows 20 - 30 if ($row == 1 || ($row >= 20 && $row <= 30)) { diff --git a/samples/Basic/39_Dropdown.php b/samples/Basic/39_Dropdown.php index 0e8ff52b6e..f5bb578204 100644 --- a/samples/Basic/39_Dropdown.php +++ b/samples/Basic/39_Dropdown.php @@ -20,10 +20,6 @@ ->setDescription('Test document for PhpSpreadsheet, generated using PHP classes.') ->setKeywords('Office PhpSpreadsheet php') ->setCategory('Test result file'); -function transpose($value) -{ - return [$value]; -} // Add some data $continentColumn = 'D'; @@ -39,7 +35,7 @@ function transpose($value) $countryCount = count($countries); // Transpose $countries from a row to a column array - $countries = array_map('transpose', $countries); + $countries = array_map(fn (mixed $value): array => [$value], $countries); $spreadsheet->getActiveSheet() ->fromArray($countries, null, $column . '1'); $spreadsheet->addNamedRange( diff --git a/samples/Chart/33_Chart_create_line_dateaxis.php b/samples/Chart/33_Chart_create_line_dateaxis.php index d7b674f6d1..c3c15fd10b 100644 --- a/samples/Chart/33_Chart_create_line_dateaxis.php +++ b/samples/Chart/33_Chart_create_line_dateaxis.php @@ -157,7 +157,7 @@ $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues null, // plotDirection - null, // smooth line + false, // smooth line DataSeries::STYLE_SMOOTHMARKER // plotStyle ); @@ -279,7 +279,7 @@ // change xAxis tick marks to match Qtr boundaries $nQtrs = sprintf('%3.2f', (($dateMinMax['max'] - $dateMinMax['min']) / 30.5) / 4); -$tickMarkInterval = ($nQtrs > 20) ? 6 : 3; // tick marks every ? months +$tickMarkInterval = ($nQtrs > 20) ? '6' : '3'; // tick marks every ? months $xAxis->setAxisOptionsProperties( Properties::AXIS_LABELS_NEXT_TO, // axis_label pos diff --git a/samples/Chart/33_Chart_create_radar.php b/samples/Chart/33_Chart_create_radar.php index c73731d7cc..4d140477d1 100644 --- a/samples/Chart/33_Chart_create_radar.php +++ b/samples/Chart/33_Chart_create_radar.php @@ -74,7 +74,7 @@ $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues null, // plotDirection - null, // smooth line + false, // smooth line DataSeries::STYLE_MARKER // plotStyle ); diff --git a/samples/Chart/33_Chart_create_scatter.php b/samples/Chart/33_Chart_create_scatter.php index 367e3c2ce9..779e42505e 100644 --- a/samples/Chart/33_Chart_create_scatter.php +++ b/samples/Chart/33_Chart_create_scatter.php @@ -60,7 +60,7 @@ $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues null, // plotDirection - null, // smooth line + false, // smooth line DataSeries::STYLE_LINEMARKER // plotStyle ); diff --git a/samples/Chart/33_Chart_create_scatter2.php b/samples/Chart/33_Chart_create_scatter2.php index 8662d88a24..7c0608cd35 100644 --- a/samples/Chart/33_Chart_create_scatter2.php +++ b/samples/Chart/33_Chart_create_scatter2.php @@ -89,9 +89,9 @@ Properties::LINE_STYLE_CAP_SQUARE, // cap Properties::LINE_STYLE_JOIN_MITER, // join Properties::LINE_STYLE_ARROW_TYPE_OPEN, // head type - (string) Properties::LINE_STYLE_ARROW_SIZE_4, // head size preset index + Properties::LINE_STYLE_ARROW_SIZE_4, // head size preset index Properties::LINE_STYLE_ARROW_TYPE_ARROW, // end type - (string) Properties::LINE_STYLE_ARROW_SIZE_6 // end size preset index + Properties::LINE_STYLE_ARROW_SIZE_6 // end size preset index ); // series 2 - straight line - no special effects, connected, straight line diff --git a/samples/Chart/33_Chart_create_scatter4.php b/samples/Chart/33_Chart_create_scatter4.php index 58f2ddd8a0..211a0908a7 100644 --- a/samples/Chart/33_Chart_create_scatter4.php +++ b/samples/Chart/33_Chart_create_scatter4.php @@ -61,7 +61,7 @@ $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues null, // plotDirection - null, // smooth line + false, // smooth line DataSeries::STYLE_LINEMARKER // plotStyle ); diff --git a/samples/Chart/33_Chart_create_scatter5_trendlines.php b/samples/Chart/33_Chart_create_scatter5_trendlines.php index f58aadaf73..533ac4c416 100644 --- a/samples/Chart/33_Chart_create_scatter5_trendlines.php +++ b/samples/Chart/33_Chart_create_scatter5_trendlines.php @@ -133,7 +133,7 @@ $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues null, // plotDirection - null, // smooth line + false, // smooth line DataSeries::STYLE_SMOOTHMARKER // plotStyle ); @@ -217,7 +217,7 @@ $dataSeriesValues[0]->getTrendLines()[1]->setLineStyleProperties(1.25); $dataSeriesValues[0]->getTrendLines()[2]->getLineColor()->setColorProperties('accent2', null, ChartColor::EXCEL_COLOR_TYPE_SCHEME); -$dataSeriesValues[0]->getTrendLines()[2]->setLineStyleProperties(1.5, null, null, null, null, null, null, Properties::LINE_STYLE_ARROW_TYPE_OPEN, 8); +$dataSeriesValues[0]->getTrendLines()[2]->setLineStyleProperties(1.5, null, null, null, null, null, 0, Properties::LINE_STYLE_ARROW_TYPE_OPEN, 8); $xAxis = new ChartAxis(); $xAxis->setAxisNumberProperties(Properties::FORMAT_CODE_DATE_ISO8601); // m/d/yyyy @@ -231,7 +231,7 @@ $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues null, // plotDirection - null, // smooth line + false, // smooth line DataSeries::STYLE_SMOOTHMARKER // plotStyle ); diff --git a/samples/Chart/33_Chart_create_scatter6_value_xaxis.php b/samples/Chart/33_Chart_create_scatter6_value_xaxis.php index 94f602a92f..b2a2f532d5 100644 --- a/samples/Chart/33_Chart_create_scatter6_value_xaxis.php +++ b/samples/Chart/33_Chart_create_scatter6_value_xaxis.php @@ -61,7 +61,7 @@ $xAxisTickValues, // plotCategory $dataSeriesValues, // plotValues null, // plotDirection - null, // smooth line + false, // smooth line DataSeries::STYLE_LINEMARKER // plotStyle ); @@ -81,10 +81,10 @@ null, // axisOrientation null, // majorTmt Properties::TICK_MARK_OUTSIDE, // minorTmt - 0, // minimum - 6, // maximum + '0', // minimum + '6', // maximum null, // majorUnit - 1, // minorUnit + '1', // minorUnit ); $xAxis->setAxisType(ChartAxis::AXIS_TYPE_VALUE); @@ -98,10 +98,10 @@ null, // axisOrientation null, // majorTmt Properties::TICK_MARK_OUTSIDE, // minorTmt - 0, // minimum - 25, // 30 // maximum + '0', // minimum + '25', // 30 // maximum null, // majorUnit - 5, // minorUnit + '5', // minorUnit ); // Create the chart diff --git a/samples/DefinedNames/CrossWorksheetNamedFormula.php b/samples/DefinedNames/CrossWorksheetNamedFormula.php index 5ce7651628..6c2faec2b9 100644 --- a/samples/DefinedNames/CrossWorksheetNamedFormula.php +++ b/samples/DefinedNames/CrossWorksheetNamedFormula.php @@ -40,7 +40,7 @@ $worksheet = $spreadsheet->addSheet(new Worksheet($spreadsheet)); setYearlyData($worksheet, '2020', [], 'GROWTH'); -function setYearlyData(Worksheet $worksheet, string $year, $yearlyData, ?string $title = null): void +function setYearlyData(Worksheet $worksheet, string $year, array $yearlyData, ?string $title = null): void { // Set up some basic data $worksheetTitle = $title ?: $year; diff --git a/samples/Pdf/21b_Pdf.php b/samples/Pdf/21b_Pdf.php index d7a1cb51e3..38ba4d9c45 100644 --- a/samples/Pdf/21b_Pdf.php +++ b/samples/Pdf/21b_Pdf.php @@ -21,7 +21,7 @@ function replaceBody(string $html): string EOF; - return preg_replace($bodystring, $bodyrepl, $html); + return preg_replace($bodystring, $bodyrepl, $html) ?? ''; } require __DIR__ . '/../Header.php'; diff --git a/samples/Pdf/21c_Pdf.php b/samples/Pdf/21c_Pdf.php index f556dcb2ff..758dd7c00e 100644 --- a/samples/Pdf/21c_Pdf.php +++ b/samples/Pdf/21c_Pdf.php @@ -40,7 +40,7 @@ function addHeadersFootersMpdf2000(string $html): string EOF; - return preg_replace($bodystring, $bodyrepl, $html); + return preg_replace($bodystring, $bodyrepl, $html ?? '') ?? ''; } $spreadsheet = new Spreadsheet(); diff --git a/samples/Reader/08_Simple_file_reader_loading_several_named_worksheets.php b/samples/Reader/08_Simple_file_reader_loading_several_named_worksheets.php index 66efc3e0fb..b6eb745204 100644 --- a/samples/Reader/08_Simple_file_reader_loading_several_named_worksheets.php +++ b/samples/Reader/08_Simple_file_reader_loading_several_named_worksheets.php @@ -10,7 +10,7 @@ $helper->log('Loading file ' . pathinfo($inputFileName, PATHINFO_BASENAME) . ' using IOFactory with a defined reader type of ' . $inputFileType); $reader = IOFactory::createReader($inputFileType); -$helper->log('Loading Sheet' . ((count($sheetnames) == 1) ? '' : 's') . ' "' . implode('" and "', $sheetnames) . '" only'); +$helper->log('Loading Sheets "' . implode('" and "', $sheetnames) . '" only'); $reader->setLoadSheetsOnly($sheetnames); $spreadsheet = $reader->load($inputFileName); diff --git a/samples/Reader/09_Simple_file_reader_using_a_read_filter.php b/samples/Reader/09_Simple_file_reader_using_a_read_filter.php index 5b3faa775b..08cd648e4d 100644 --- a/samples/Reader/09_Simple_file_reader_using_a_read_filter.php +++ b/samples/Reader/09_Simple_file_reader_using_a_read_filter.php @@ -13,7 +13,7 @@ class MyReadFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Read rows 9 to 15 and columns A to E only if ($row >= 9 && $row <= 15) { diff --git a/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php b/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php index 437fe6cffa..44394a5685 100644 --- a/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php +++ b/samples/Reader/10_Simple_file_reader_using_a_configurable_read_filter.php @@ -13,20 +13,14 @@ class MyReadFilter implements IReadFilter { - private $startRow = 0; - - private $endRow = 0; - - private $columns = []; - - public function __construct($startRow, $endRow, $columns) - { - $this->startRow = $startRow; - $this->endRow = $endRow; - $this->columns = $columns; + public function __construct( + private int $startRow = 0, + private int $endRow = 0, + private array $columns = [] + ) { } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { if ($row >= $this->startRow && $row <= $this->endRow) { if (in_array($columnAddress, $this->columns)) { diff --git a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php index ec01132618..b72aef7afc 100644 --- a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php +++ b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php @@ -13,23 +13,20 @@ /** Define a Read Filter class implementing IReadFilter */ class ChunkReadFilter implements IReadFilter { - private $startRow = 0; + private int $startRow = 0; - private $endRow = 0; + private int $endRow = 0; /** * We expect a list of the rows that we want to read to be passed into the constructor. - * - * @param mixed $startRow - * @param mixed $chunkSize */ - public function __construct($startRow, $chunkSize) + public function __construct(int $startRow, int $chunkSize) { $this->startRow = $startRow; $this->endRow = $startRow + $chunkSize; } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Only read the heading row, and the rows that were configured in the constructor if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php index e8c4a65903..d421b6ad4e 100644 --- a/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php +++ b/samples/Reader/12_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_2).php @@ -13,23 +13,20 @@ /** Define a Read Filter class implementing IReadFilter */ class ChunkReadFilter implements IReadFilter { - private $startRow = 0; + private int $startRow = 0; - private $endRow = 0; + private int $endRow = 0; /** * Set the list of rows that we want to read. - * - * @param mixed $startRow - * @param mixed $chunkSize */ - public function setRows($startRow, $chunkSize): void + public function setRows(int $startRow, int $chunkSize): void { $this->startRow = $startRow; $this->endRow = $startRow + $chunkSize; } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php index 82544f60a7..c47f8c7a98 100644 --- a/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php +++ b/samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php @@ -13,23 +13,20 @@ /** Define a Read Filter class implementing IReadFilter */ class ChunkReadFilter implements IReadFilter { - private $startRow = 0; + private int $startRow = 0; - private $endRow = 0; + private int $endRow = 0; /** * Set the list of rows that we want to read. - * - * @param mixed $startRow - * @param mixed $chunkSize */ - public function setRows($startRow, $chunkSize): void + public function setRows(int $startRow, int $chunkSize): void { $this->startRow = $startRow; $this->endRow = $startRow + $chunkSize; } - public function readCell($columnAddress, $row, $worksheetName = '') + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { // Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow if (($row == 1) || ($row >= $this->startRow && $row < $this->endRow)) { diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php index 7f1b363c5d..0c6b9a6599 100644 --- a/src/PhpSpreadsheet/Cell/DataValidation.php +++ b/src/PhpSpreadsheet/Cell/DataValidation.php @@ -31,17 +31,13 @@ class DataValidation /** * Formula 1. - * - * @var string */ - private $formula1 = ''; + private string $formula1 = ''; /** * Formula 2. - * - * @var string */ - private $formula2 = ''; + private string $formula2 = ''; /** * Type. @@ -129,10 +125,8 @@ public function __construct() /** * Get Formula 1. - * - * @return string */ - public function getFormula1() + public function getFormula1(): string { return $this->formula1; } @@ -140,11 +134,9 @@ public function getFormula1() /** * Set Formula 1. * - * @param string $formula - * * @return $this */ - public function setFormula1($formula): static + public function setFormula1(string $formula): static { $this->formula1 = $formula; @@ -153,10 +145,8 @@ public function setFormula1($formula): static /** * Get Formula 2. - * - * @return string */ - public function getFormula2() + public function getFormula2(): string { return $this->formula2; } @@ -164,11 +154,9 @@ public function getFormula2() /** * Set Formula 2. * - * @param string $formula - * * @return $this */ - public function setFormula2($formula): static + public function setFormula2(string $formula): static { $this->formula2 = $formula; diff --git a/src/PhpSpreadsheet/Cell/IValueBinder.php b/src/PhpSpreadsheet/Cell/IValueBinder.php index 5af9f5f60e..b2f7e91a35 100644 --- a/src/PhpSpreadsheet/Cell/IValueBinder.php +++ b/src/PhpSpreadsheet/Cell/IValueBinder.php @@ -9,8 +9,6 @@ interface IValueBinder * * @param Cell $cell Cell to bind value to * @param mixed $value Value to bind in cell - * - * @return bool */ - public function bindValue(Cell $cell, $value); + public function bindValue(Cell $cell, mixed $value): bool; } diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index 90f1f50317..3054759024 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -52,9 +52,9 @@ public function __construct() /** * Axis Options. * - * @var mixed[] + * @var array */ - private $axisOptions = [ + private array $axisOptions = [ 'minimum' => null, 'maximum' => null, 'major_unit' => null, @@ -169,11 +169,9 @@ public function setAxisOptionsProperties( /** * Get Axis Options Property. * - * @param string $property - * * @return ?string */ - public function getAxisOptionsProperty($property): ?string + public function getAxisOptionsProperty(string $property): ?string { if ($property === 'textRotation') { if ($this->axisText !== null) { diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index 8bceae071d..d0391c22da 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -127,8 +127,17 @@ class DataSeries * @param bool $smoothLine * @param null|string $plotStyle */ - public function __construct($plotType = null, $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], array $plotCategory = [], array $plotValues = [], $plotDirection = null, $smoothLine = false, $plotStyle = null) - { + public function __construct( + $plotType = null, + $plotGrouping = null, + array $plotOrder = [], + array $plotLabel = [], + array $plotCategory = [], + array $plotValues = [], + $plotDirection = null, + $smoothLine = false, + $plotStyle = null + ) { $this->plotType = $plotType; $this->plotGrouping = $plotGrouping; $this->plotOrder = $plotOrder; diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index a3f5ca0cf0..d076391adb 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -98,9 +98,8 @@ class DataSeriesValues extends Properties * @param mixed $dataValues * @param null|mixed $marker * @param null|ChartColor|ChartColor[]|string|string[] $fillColor - * @param string $pointSize */ - public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null, $fillColor = null, $pointSize = '3') + public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null, $fillColor = null, int|string $pointSize = '3') { parent::__construct(); $this->markerFillColor = new ChartColor(); diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index 849f561949..ead6b3afc2 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -795,16 +795,27 @@ public function getLineColorProperty($propertyName) * @param string $capType * @param string $joinType * @param string $headArrowType - * @param string $headArrowSize * @param string $endArrowType - * @param string $endArrowSize * @param string $headArrowWidth * @param string $headArrowLength * @param string $endArrowWidth * @param string $endArrowLength */ - public function setLineStyleProperties($lineWidth = null, $compoundType = '', $dashType = '', $capType = '', $joinType = '', $headArrowType = '', $headArrowSize = '', $endArrowType = '', $endArrowSize = '', $headArrowWidth = '', $headArrowLength = '', $endArrowWidth = '', $endArrowLength = ''): void - { + public function setLineStyleProperties( + $lineWidth = null, + $compoundType = '', + $dashType = '', + $capType = '', + $joinType = '', + $headArrowType = '', + int $headArrowSize = 0, + $endArrowType = '', + int $endArrowSize = 0, + $headArrowWidth = '', + $headArrowLength = '', + $endArrowWidth = '', + $endArrowLength = '' + ): void { $this->activateObject(); if (is_numeric($lineWidth)) { $this->lineStyleProperties['width'] = $lineWidth; diff --git a/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php b/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php index ff14cd726c..ae28ff4fc9 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php +++ b/src/PhpSpreadsheet/Chart/Renderer/IRenderer.php @@ -18,5 +18,5 @@ public function __construct(Chart $chart); * * @return bool true on success */ - public function render($filename); + public function render(?string $filename): bool; } diff --git a/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php b/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php index 27cf3b165d..7c21a131a8 100644 --- a/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php +++ b/src/PhpSpreadsheet/Chart/Renderer/JpGraphRendererBase.php @@ -785,7 +785,7 @@ private function renderCombinationChart($groupCount, $outputDestination): bool return true; } - public function render($outputDestination) + public function render(?string $outputDestination): bool { self::$plotColour = 0; diff --git a/src/PhpSpreadsheet/IComparable.php b/src/PhpSpreadsheet/IComparable.php index c215847b31..64b451ede2 100644 --- a/src/PhpSpreadsheet/IComparable.php +++ b/src/PhpSpreadsheet/IComparable.php @@ -9,5 +9,5 @@ interface IComparable * * @return string Hash code */ - public function getHashCode(); + public function getHashCode(): string; } diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index b8e6a81a9b..435926531f 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -62,48 +62,48 @@ public function __construct() $this->readFilter = new DefaultReadFilter(); } - public function getReadDataOnly() + public function getReadDataOnly(): bool { return $this->readDataOnly; } - public function setReadDataOnly($readCellValuesOnly) + public function setReadDataOnly(bool $readCellValuesOnly): self { - $this->readDataOnly = (bool) $readCellValuesOnly; + $this->readDataOnly = $readCellValuesOnly; return $this; } - public function getReadEmptyCells() + public function getReadEmptyCells(): bool { return $this->readEmptyCells; } - public function setReadEmptyCells($readEmptyCells) + public function setReadEmptyCells(bool $readEmptyCells): self { - $this->readEmptyCells = (bool) $readEmptyCells; + $this->readEmptyCells = $readEmptyCells; return $this; } - public function getIncludeCharts() + public function getIncludeCharts(): bool { return $this->includeCharts; } - public function setIncludeCharts($includeCharts) + public function setIncludeCharts(bool $includeCharts): self { - $this->includeCharts = (bool) $includeCharts; + $this->includeCharts = $includeCharts; return $this; } - public function getLoadSheetsOnly() + public function getLoadSheetsOnly(): ?array { return $this->loadSheetsOnly; } - public function setLoadSheetsOnly($sheetList) + public function setLoadSheetsOnly(string|array|null $sheetList): self { if ($sheetList === null) { return $this->setLoadAllSheets(); @@ -114,19 +114,19 @@ public function setLoadSheetsOnly($sheetList) return $this; } - public function setLoadAllSheets() + public function setLoadAllSheets(): self { $this->loadSheetsOnly = null; return $this; } - public function getReadFilter() + public function getReadFilter(): IReadFilter { return $this->readFilter; } - public function setReadFilter(IReadFilter $readFilter) + public function setReadFilter(IReadFilter $readFilter): self { $this->readFilter = $readFilter; diff --git a/src/PhpSpreadsheet/Reader/IReadFilter.php b/src/PhpSpreadsheet/Reader/IReadFilter.php index 9f68a7f360..1fd12e56f7 100644 --- a/src/PhpSpreadsheet/Reader/IReadFilter.php +++ b/src/PhpSpreadsheet/Reader/IReadFilter.php @@ -10,8 +10,6 @@ interface 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(string $columnAddress, int $row, string $worksheetName = ''): bool; } diff --git a/src/PhpSpreadsheet/Reader/IReader.php b/src/PhpSpreadsheet/Reader/IReader.php index dadf36ff90..79be3d8c7f 100644 --- a/src/PhpSpreadsheet/Reader/IReader.php +++ b/src/PhpSpreadsheet/Reader/IReader.php @@ -13,9 +13,6 @@ interface IReader public const SKIP_EMPTY_CELLS = 4; public const IGNORE_EMPTY_CELLS = 4; - /** - * IReader constructor. - */ public function __construct(); /** @@ -28,10 +25,8 @@ public function canRead(string $filename): bool; * If this is true, then the Reader will only read data values for cells, it will not read any formatting * or structural information (like merges). * If false (the default) it will read data and formatting. - * - * @return bool */ - public function getReadDataOnly(); + public function getReadDataOnly(): bool; /** * Set read data only @@ -39,41 +34,33 @@ public function getReadDataOnly(); * or structural information (like merges). * Set to false (the default) to advise the Reader to read both data and formatting for cells. * - * @param bool $readDataOnly - * - * @return IReader + * @return $this */ - public function setReadDataOnly($readDataOnly); + public function setReadDataOnly(bool $readDataOnly): self; /** * Read empty cells? * If this is true (the default), then the Reader will read data values for all cells, irrespective of value. * If false it will not read data for cells containing a null value or an empty string. - * - * @return bool */ - public function getReadEmptyCells(); + public function getReadEmptyCells(): bool; /** * Set read empty cells * Set to true (the default) to advise the Reader read data values for all cells, irrespective of value. * Set to false to advise the Reader to ignore cells containing a null value or an empty string. * - * @param bool $readEmptyCells - * - * @return IReader + * @return $this */ - public function setReadEmptyCells($readEmptyCells); + public function setReadEmptyCells(bool $readEmptyCells): self; /** * Read charts in workbook? * If this is true, then the Reader will include any charts that exist in the workbook. * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. * If false (the default) it will ignore any charts defined in the workbook file. - * - * @return bool */ - public function getIncludeCharts(); + public function getIncludeCharts(): bool; /** * Set read charts in workbook @@ -81,53 +68,47 @@ public function getIncludeCharts(); * Note that a ReadDataOnly value of false overrides, and charts won't be read regardless of the IncludeCharts value. * Set to false (the default) to discard charts. * - * @param bool $includeCharts - * - * @return IReader + * @return $this */ - public function setIncludeCharts($includeCharts); + public function setIncludeCharts(bool $includeCharts): self; /** * Get which sheets to load * Returns either an array of worksheet names (the list of worksheets that should be loaded), or a null * indicating that all worksheets in the workbook should be loaded. - * - * @return mixed */ - public function getLoadSheetsOnly(); + public function getLoadSheetsOnly(): ?array; /** * Set which sheets to load. * - * @param mixed $value - * This should be either an array of worksheet names to be loaded, or a string containing a single worksheet name. - * If NULL, then it tells the Reader to read all worksheets in the workbook + * @param null|array|string $value This should be either an array of worksheet names to be loaded, + * or a string containing a single worksheet name. If NULL, then it tells the Reader to + * read all worksheets in the workbook * - * @return IReader + * @return $this */ - public function setLoadSheetsOnly($value); + public function setLoadSheetsOnly(string|array|null $value): self; /** * Set all sheets to load * Tells the Reader to load all worksheets from the workbook. * - * @return IReader + * @return $this */ - public function setLoadAllSheets(); + public function setLoadAllSheets(): self; /** * Read filter. - * - * @return IReadFilter */ - public function getReadFilter(); + public function getReadFilter(): IReadFilter; /** * Set read filter. * - * @return IReader + * @return $this */ - public function setReadFilter(IReadFilter $readFilter); + public function setReadFilter(IReadFilter $readFilter): self; /** * Loads PhpSpreadsheet from file. @@ -138,8 +119,6 @@ public function setReadFilter(IReadFilter $readFilter); * self::READ_DATA_ONLY Read only data, not style or structure information, from the file * 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 Spreadsheet */ - public function load(string $filename, int $flags = 0); + public function load(string $filename, int $flags = 0): Spreadsheet; } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 789d46ee78..4a2d660c66 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -1448,8 +1448,8 @@ private function readLineStyle(SimpleXMLElement $chartDetail, ?ChartProperties $ } else { $joinType = ''; } - $headArrowSize = ''; - $endArrowSize = ''; + $headArrowSize = 0; + $endArrowSize = 0; /** @var string */ $headArrowType = self::getAttributeString($sppr->ln->headEnd, 'type'); /** @var string */ diff --git a/src/PhpSpreadsheet/RichText/ITextElement.php b/src/PhpSpreadsheet/RichText/ITextElement.php index 284a365e35..548e68ba59 100644 --- a/src/PhpSpreadsheet/RichText/ITextElement.php +++ b/src/PhpSpreadsheet/RichText/ITextElement.php @@ -8,31 +8,27 @@ interface ITextElement { /** * Get text. - * - * @return string Text */ - public function getText(); + public function getText(): string; /** * Set text. * * @param string $text Text * - * @return ITextElement + * @return $this */ - public function setText($text); + public function setText(string $text): self; /** * Get font. - * - * @return null|Font */ - public function getFont(); + public function getFont(): ?Font; /** * Get hash code. * * @return string Hash code */ - public function getHashCode(); + public function getHashCode(): string; } diff --git a/src/PhpSpreadsheet/RichText/Run.php b/src/PhpSpreadsheet/RichText/Run.php index c2b7156e60..4acc155c24 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -27,10 +27,8 @@ public function __construct($text = '') /** * Get font. - * - * @return null|Font */ - public function getFont() + public function getFont(): ?Font { return $this->font; } diff --git a/src/PhpSpreadsheet/RichText/TextElement.php b/src/PhpSpreadsheet/RichText/TextElement.php index b8049ddb88..073dd7a8c9 100644 --- a/src/PhpSpreadsheet/RichText/TextElement.php +++ b/src/PhpSpreadsheet/RichText/TextElement.php @@ -29,7 +29,7 @@ public function __construct($text = '') * * @return string Text */ - public function getText() + public function getText(): string { return $this->text; } @@ -41,7 +41,7 @@ public function getText() * * @return $this */ - public function setText($text) + public function setText(string $text): self { $this->text = $text; @@ -50,10 +50,8 @@ public function setText($text) /** * Get font. For this class, the return value is always null. - * - * @return null|Font */ - public function getFont() + public function getFont(): ?Font { return null; } @@ -63,7 +61,7 @@ public function getFont() * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { return md5( $this->text diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 006f64c26c..691962d569 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -211,7 +211,7 @@ public function setColor(Color $color): static * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHashCode(); diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index b027029847..9189db8bd5 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -378,7 +378,7 @@ public function setDiagonalDirection($direction): static * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHashcode(); diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index 5ae5c7f255..fe2adc3fad 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -309,7 +309,7 @@ public function getColorsChanged(): bool * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHashCode(); diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index 09a24d10ab..b2e73d1cfb 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -768,7 +768,7 @@ private function hashChartColor(?ChartColor $underlineColor): string * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHashCode(); diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 6e791069fd..c494a38dc8 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -416,7 +416,7 @@ public static function builtInFormatCodeIndex($formatCodeIndex) * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHashCode(); diff --git a/src/PhpSpreadsheet/Style/Protection.php b/src/PhpSpreadsheet/Style/Protection.php index 1f605af381..1708098858 100644 --- a/src/PhpSpreadsheet/Style/Protection.php +++ b/src/PhpSpreadsheet/Style/Protection.php @@ -164,7 +164,7 @@ public function setHidden($hiddenType): static * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { if ($this->isSupervisor) { return $this->getSharedComponent()->getHashCode(); diff --git a/src/PhpSpreadsheet/Style/Style.php b/src/PhpSpreadsheet/Style/Style.php index b8383369fa..45b6fef3dc 100644 --- a/src/PhpSpreadsheet/Style/Style.php +++ b/src/PhpSpreadsheet/Style/Style.php @@ -556,10 +556,8 @@ public function getFill() /** * Get Font. - * - * @return Font */ - public function getFont() + public function getFont(): Font { return $this->font; } diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 8ed1d22eb7..45c1c02f52 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -3413,7 +3413,7 @@ public function garbageCollect(): static * * @return string Hash code */ - public function getHashCode() + public function getHashCode(): string { if ($this->dirty) { $this->hash = md5($this->title . $this->autoFilter . ($this->protection->isProtectionEnabled() ? 't' : 'f') . __CLASS__); diff --git a/src/PhpSpreadsheet/Writer/BaseWriter.php b/src/PhpSpreadsheet/Writer/BaseWriter.php index f903e93aec..df862f7c55 100644 --- a/src/PhpSpreadsheet/Writer/BaseWriter.php +++ b/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -45,36 +45,36 @@ abstract class BaseWriter implements IWriter */ private $shouldCloseFile; - public function getIncludeCharts() + public function getIncludeCharts(): bool { return $this->includeCharts; } - public function setIncludeCharts($includeCharts) + public function setIncludeCharts(bool $includeCharts): self { - $this->includeCharts = (bool) $includeCharts; + $this->includeCharts = $includeCharts; return $this; } - public function getPreCalculateFormulas() + public function getPreCalculateFormulas(): bool { return $this->preCalculateFormulas; } - public function setPreCalculateFormulas($precalculateFormulas) + public function setPreCalculateFormulas(bool $precalculateFormulas): self { - $this->preCalculateFormulas = (bool) $precalculateFormulas; + $this->preCalculateFormulas = $precalculateFormulas; return $this; } - public function getUseDiskCaching() + public function getUseDiskCaching(): bool { return $this->useDiskCaching; } - public function setUseDiskCaching($useDiskCache, $cacheDirectory = null) + public function setUseDiskCaching(bool $useDiskCache, ?string $cacheDirectory = null): self { $this->useDiskCaching = $useDiskCache; @@ -89,7 +89,7 @@ public function setUseDiskCaching($useDiskCache, $cacheDirectory = null) return $this; } - public function getDiskCachingDirectory() + public function getDiskCachingDirectory(): string { return $this->diskCachingDirectory; } diff --git a/src/PhpSpreadsheet/Writer/IWriter.php b/src/PhpSpreadsheet/Writer/IWriter.php index a4bd5d522d..cd48306797 100644 --- a/src/PhpSpreadsheet/Writer/IWriter.php +++ b/src/PhpSpreadsheet/Writer/IWriter.php @@ -21,21 +21,17 @@ public function __construct(Spreadsheet $spreadsheet); * Write charts in workbook? * If this is true, then the Writer will write definitions for any charts that exist in the PhpSpreadsheet object. * If false (the default) it will ignore any charts defined in the PhpSpreadsheet object. - * - * @return bool */ - public function getIncludeCharts(); + public function getIncludeCharts(): bool; /** * Set write charts in workbook * Set to true, to advise the Writer to include any charts that exist in the PhpSpreadsheet object. * Set to false (the default) to ignore charts. * - * @param bool $includeCharts - * - * @return IWriter + * @return $this */ - public function setIncludeCharts($includeCharts); + public function setIncludeCharts(bool $includeCharts): self; /** * Get Pre-Calculate Formulas flag @@ -44,10 +40,8 @@ public function setIncludeCharts($includeCharts); * viewer when opening the file * If false, then formulae are not calculated on save. This is faster for saving in PhpSpreadsheet, but slower * when opening the resulting file in MS Excel, because Excel has to recalculate the formulae itself. - * - * @return bool */ - public function getPreCalculateFormulas(); + public function getPreCalculateFormulas(): bool; /** * Set Pre-Calculate Formulas @@ -56,9 +50,9 @@ public function getPreCalculateFormulas(); * * @param bool $precalculateFormulas Pre-Calculate Formulas? * - * @return IWriter + * @return $this */ - public function setPreCalculateFormulas($precalculateFormulas); + public function setPreCalculateFormulas(bool $precalculateFormulas): self; /** * Save PhpSpreadsheet to file. @@ -74,25 +68,20 @@ public function save($filename, int $flags = 0): void; /** * Get use disk caching where possible? - * - * @return bool */ - public function getUseDiskCaching(); + public function getUseDiskCaching(): bool; /** * Set use disk caching where possible? * - * @param bool $useDiskCache - * @param string $cacheDirectory Disk caching directory + * @param ?string $cacheDirectory Disk caching directory * - * @return IWriter + * @return $this */ - public function setUseDiskCaching($useDiskCache, $cacheDirectory = null); + public function setUseDiskCaching(bool $useDiskCache, ?string $cacheDirectory = null): self; /** * Get disk caching directory. - * - * @return string */ - public function getDiskCachingDirectory(); + public function getDiskCachingDirectory(): string; } diff --git a/tests/PhpSpreadsheetTests/Chart/DataSeriesColorTest.php b/tests/PhpSpreadsheetTests/Chart/DataSeriesColorTest.php index 690445d3e4..75e9c2e24d 100644 --- a/tests/PhpSpreadsheetTests/Chart/DataSeriesColorTest.php +++ b/tests/PhpSpreadsheetTests/Chart/DataSeriesColorTest.php @@ -109,9 +109,9 @@ public function testDataSeriesValues(): void Properties::LINE_STYLE_CAP_SQUARE, // cap Properties::LINE_STYLE_JOIN_MITER, // join Properties::LINE_STYLE_ARROW_TYPE_OPEN, // head type - (string) Properties::LINE_STYLE_ARROW_SIZE_4, // head size preset index + Properties::LINE_STYLE_ARROW_SIZE_4, // head size preset index Properties::LINE_STYLE_ARROW_TYPE_ARROW, // end type - (string) Properties::LINE_STYLE_ARROW_SIZE_6 // end size preset index + Properties::LINE_STYLE_ARROW_SIZE_6 // end size preset index ); // series 2 - straight line - no special effects, connected, straight line diff --git a/tests/PhpSpreadsheetTests/Chart/GridlinesLineStyleTest.php b/tests/PhpSpreadsheetTests/Chart/GridlinesLineStyleTest.php index 9251d25dbf..99c03d453b 100644 --- a/tests/PhpSpreadsheetTests/Chart/GridlinesLineStyleTest.php +++ b/tests/PhpSpreadsheetTests/Chart/GridlinesLineStyleTest.php @@ -103,9 +103,9 @@ public function testLineStyles(): void $cap = Properties::LINE_STYLE_CAP_ROUND; $join = Properties::LINE_STYLE_JOIN_MITER; $headArrowType = Properties::LINE_STYLE_ARROW_TYPE_DIAMOND; - $headArrowSize = (string) Properties::LINE_STYLE_ARROW_SIZE_2; + $headArrowSize = Properties::LINE_STYLE_ARROW_SIZE_2; $endArrowType = Properties::LINE_STYLE_ARROW_TYPE_OVAL; - $endArrowSize = (string) Properties::LINE_STYLE_ARROW_SIZE_3; + $endArrowSize = Properties::LINE_STYLE_ARROW_SIZE_3; $majorGridlines->setLineStyleProperties( $width, $compound, @@ -299,9 +299,9 @@ public function testLineStylesDeprecated(): void $cap = Properties::LINE_STYLE_CAP_ROUND; $join = Properties::LINE_STYLE_JOIN_MITER; $headArrowType = Properties::LINE_STYLE_ARROW_TYPE_DIAMOND; - $headArrowSize = (string) Properties::LINE_STYLE_ARROW_SIZE_2; + $headArrowSize = Properties::LINE_STYLE_ARROW_SIZE_2; $endArrowType = Properties::LINE_STYLE_ARROW_TYPE_OVAL; - $endArrowSize = (string) Properties::LINE_STYLE_ARROW_SIZE_3; + $endArrowSize = Properties::LINE_STYLE_ARROW_SIZE_3; $majorGridlines->setLineStyleProperties( $width, $compound, diff --git a/tests/PhpSpreadsheetTests/Chart/LineStylesTest.php b/tests/PhpSpreadsheetTests/Chart/LineStylesTest.php index b382c4a929..9543206ce6 100644 --- a/tests/PhpSpreadsheetTests/Chart/LineStylesTest.php +++ b/tests/PhpSpreadsheetTests/Chart/LineStylesTest.php @@ -21,9 +21,9 @@ public function testLineStyles(): void Properties::LINE_STYLE_CAP_SQUARE, // capType '', // jointType '', // headArrowType - '', // headArrowSize + 0, // headArrowSize '', // endArrowType - '', // endArrowSize + 0, // endArrowSize 'lg', // headArrowWidth 'med', // headArrowLength '', // endArrowWidth From f62245bbae583f09c630b4502e02956725d22738 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Dec 2023 16:56:55 +0100 Subject: [PATCH 03/25] phpcs on samples/ too --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index feec99134c..5a7e9164a8 100644 --- a/composer.json +++ b/composer.json @@ -46,22 +46,22 @@ "scripts": { "check": [ "./bin/check-phpdoc-types", - "phpcs src/ tests/ --report=checkstyle", - "phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PHPCompatibility --runtime-set testVersion 8.0- -n", + "phpcs samples/ src/ tests/ --report=checkstyle", + "phpcs samples/ src/ tests/ --standard=PHPCompatibility --runtime-set testVersion 8.0- -n", "php-cs-fixer fix --ansi --dry-run --diff", "phpunit --color=always", "phpstan analyse --ansi --memory-limit=2048M" ], "style": [ - "phpcs src/ tests/ --report=checkstyle", + "phpcs samples/ src/ tests/ --report=checkstyle", "php-cs-fixer fix --ansi --dry-run --diff" ], "fix": [ - "phpcbf src/ tests/ --report=checkstyle", + "phpcbf samples/ src/ tests/ --report=checkstyle", "php-cs-fixer fix" ], "versions": [ - "phpcs --report-width=200 samples/ src/ tests/ --ignore=samples/Header.php --standard=PHPCompatibility --runtime-set testVersion 8.0- -n" + "phpcs samples/ src/ tests/ --standard=PHPCompatibility --runtime-set testVersion 8.0- -n" ] }, "require": { From 3c0350ed61ded09a045437855449486b7ea56371 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Dec 2023 18:28:56 +0100 Subject: [PATCH 04/25] Add some return types --- .../Calculation/Database/DAverage.php | 2 - .../Calculation/Database/DGet.php | 4 +- .../Calculation/Database/DMax.php | 4 +- .../Calculation/Database/DMin.php | 4 +- .../Calculation/Database/DStDev.php | 4 +- .../Calculation/Database/DStDevP.php | 4 +- .../Calculation/Database/DSum.php | 4 +- .../Calculation/Database/DatabaseAbstract.php | 9 +- .../Calculation/DateTimeExcel/Difference.php | 4 +- .../Calculation/DateTimeExcel/Helpers.php | 10 +- .../Calculation/DateTimeExcel/WorkDay.php | 9 +- .../Engine/CyclicReferenceStack.php | 4 +- .../Calculation/Engine/Logger.php | 16 +--- .../Calculation/Engineering/Complex.php | 3 +- .../Engineering/ComplexFunctions.php | 95 ++++++++----------- .../Engineering/ComplexOperations.php | 10 +- .../Calculation/Engineering/ConvertUOM.php | 7 +- .../Calculation/Engineering/Erf.php | 6 +- .../Calculation/Engineering/ErfC.php | 9 +- .../CashFlow/Constant/Periodic/Cumulative.php | 4 - .../CashFlow/Variable/NonPeriodic.php | 13 +-- .../Financial/CashFlow/Variable/Periodic.php | 2 - .../Calculation/Financial/Coupons.php | 4 - .../Calculation/Financial/Depreciation.php | 6 +- .../Calculation/Financial/Dollar.php | 3 +- .../Financial/Securities/Rates.php | 8 +- .../Calculation/Information/ErrorValue.php | 9 +- .../Calculation/Information/Value.php | 25 ++--- .../Calculation/Logical/Operations.php | 5 +- .../Calculation/LookupRef/Address.php | 3 +- .../Calculation/LookupRef/ExcelMatch.php | 5 +- .../Calculation/LookupRef/Filter.php | 5 +- .../Calculation/LookupRef/Formula.php | 4 +- .../Calculation/LookupRef/Unique.php | 10 +- .../Calculation/MathTrig/Gcd.php | 7 +- .../Calculation/MathTrig/Trig/Tangent.php | 3 +- .../Calculation/Statistical/Confidence.php | 3 +- .../Statistical/Distributions/Beta.php | 6 +- .../Statistical/Distributions/Binomial.php | 6 +- .../Statistical/Distributions/ChiSquared.php | 12 +-- .../Statistical/Distributions/Exponential.php | 3 +- .../Statistical/Distributions/F.php | 3 +- .../Statistical/Distributions/Fisher.php | 6 +- .../Statistical/Distributions/Gamma.php | 9 +- .../Distributions/HyperGeometric.php | 3 +- .../Calculation/TextData/CaseConvert.php | 9 +- .../Calculation/TextData/Format.php | 12 +-- .../Calculation/TextData/Replace.php | 6 +- .../Calculation/TextData/Text.php | 6 +- .../Calculation/TextData/Trim.php | 6 +- src/PhpSpreadsheet/Shared/Date.php | 4 +- 51 files changed, 127 insertions(+), 291 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Database/DAverage.php b/src/PhpSpreadsheet/Calculation/Database/DAverage.php index 9388e469c7..20a1eef27a 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DAverage.php +++ b/src/PhpSpreadsheet/Calculation/Database/DAverage.php @@ -29,8 +29,6 @@ class DAverage 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): string|int|float { diff --git a/src/PhpSpreadsheet/Calculation/Database/DGet.php b/src/PhpSpreadsheet/Calculation/Database/DGet.php index 4a52f2e416..188f5e6787 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DGet.php +++ b/src/PhpSpreadsheet/Calculation/Database/DGet.php @@ -29,10 +29,8 @@ class DGet 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 mixed */ - public static function evaluate($database, $field, $criteria) + public static function evaluate($database, $field, $criteria): null|float|int|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DMax.php b/src/PhpSpreadsheet/Calculation/Database/DMax.php index 512557ccc2..14153a95b9 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DMax.php +++ b/src/PhpSpreadsheet/Calculation/Database/DMax.php @@ -30,10 +30,8 @@ class DMax 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 null|float|string */ - public static function evaluate($database, $field, $criteria, bool $returnError = true) + public static function evaluate($database, $field, $criteria, bool $returnError = true): null|float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DMin.php b/src/PhpSpreadsheet/Calculation/Database/DMin.php index ce01a0debc..586dcd6230 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DMin.php +++ b/src/PhpSpreadsheet/Calculation/Database/DMin.php @@ -30,10 +30,8 @@ class DMin 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 null|float|string */ - public static function evaluate($database, $field, $criteria, bool $returnError = true) + public static function evaluate($database, $field, $criteria, bool $returnError = true): float|string|null { $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 05418d490c..403e672dc2 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DStDev.php +++ b/src/PhpSpreadsheet/Calculation/Database/DStDev.php @@ -30,10 +30,8 @@ class DStDev 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): float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DStDevP.php b/src/PhpSpreadsheet/Calculation/Database/DStDevP.php index 927e29ceca..31534797e2 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DStDevP.php +++ b/src/PhpSpreadsheet/Calculation/Database/DStDevP.php @@ -30,10 +30,8 @@ class DStDevP 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): float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DSum.php b/src/PhpSpreadsheet/Calculation/Database/DSum.php index aa8976bc8c..2c17d531a3 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DSum.php +++ b/src/PhpSpreadsheet/Calculation/Database/DSum.php @@ -29,10 +29,8 @@ class DSum 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 null|float|string */ - public static function evaluate($database, $field, $criteria, bool $returnNull = false) + public static function evaluate($database, $field, $criteria, bool $returnNull = false): null|float|string { $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 f0b9ff7c82..ea74a759d3 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php +++ b/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php @@ -12,10 +12,8 @@ abstract class DatabaseAbstract * @param array $database * @param null|int|string $field * @param array $criteria - * - * @return null|float|int|string */ - abstract public static function evaluate($database, $field, $criteria); + abstract public static function evaluate($database, $field, $criteria): null|float|int|string; /** * fieldExtract. @@ -163,10 +161,7 @@ private static function executeQuery(array $database, string $query, array $crit return $database; } - /** - * @return mixed - */ - private static function processCondition(string $criterion, array $fields, array $dataValues, string $conditions) + private static function processCondition(string $criterion, array $fields, array $dataValues, string $conditions): mixed { $key = array_search($criterion, $fields, true); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php index 2822f08177..9052b8485b 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php @@ -82,10 +82,8 @@ private static function initialDiff(float $startDate, float $endDate): float * Decide whether it's time to set retVal. * * @param bool|int $retVal - * - * @return null|bool|int */ - private static function replaceRetValue($retVal, string $unit, string $compare) + private static function replaceRetValue($retVal, string $unit, string $compare): null|bool|int { if ($retVal !== false || $unit !== $compare) { return $retVal; diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index e329be724b..9082b48449 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -159,17 +159,15 @@ public static function returnIn3FormatsArray(array $dateArray, bool $noFrac = fa /** * Return result in one of three formats. - * - * @return mixed */ - public static function returnIn3FormatsFloat(float $excelDateValue) + public static function returnIn3FormatsFloat(float $excelDateValue): float|int|DateTime { $retType = Functions::getReturnDateType(); if ($retType === Functions::RETURNDATE_EXCEL) { return $excelDateValue; } if ($retType === Functions::RETURNDATE_UNIX_TIMESTAMP) { - return (int) SharedDateHelper::excelToTimestamp($excelDateValue); + return SharedDateHelper::excelToTimestamp($excelDateValue); } // RETURNDATE_PHP_DATETIME_OBJECT @@ -242,10 +240,8 @@ public static function validateNumericNull(mixed $number): int|float /** * Many functions accept null/false/true argument treated as 0/0/1. - * - * @return float */ - public static function validateNotNegative(mixed $number) + public static function validateNotNegative(mixed $number): float { if (!is_numeric($number)) { throw new Exception(ExcelError::VALUE()); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php index 1f5735e8eb..f384bebe37 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; +use DateTime; use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; use PhpOffice\PhpSpreadsheet\Calculation\Exception; use PhpOffice\PhpSpreadsheet\Calculation\Functions; @@ -71,10 +72,8 @@ public static function date($startDate, $endDays, ...$dateArgs) /** * Use incrementing logic to determine Workday. - * - * @return mixed */ - private static function incrementing(float $startDate, int $endDays, array $holidayArray) + private static function incrementing(float $startDate, int $endDays, array $holidayArray): float|int|DateTime { // Adjust the start date if it falls over a weekend $startDoW = self::getWeekDay($startDate, 3); @@ -132,10 +131,8 @@ private static function incrementingArray(float $startDate, float $endDate, arra /** * Use decrementing logic to determine Workday. - * - * @return mixed */ - private static function decrementing(float $startDate, int $endDays, array $holidayArray) + private static function decrementing(float $startDate, int $endDays, array $holidayArray): float|int|DateTime { // Adjust the start date if it falls over a weekend $startDoW = self::getWeekDay($startDate, 3); diff --git a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php index 11d0925c23..f76ced9119 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php +++ b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php @@ -29,10 +29,8 @@ public function push(mixed $value): void /** * Pop the last entry from the stack. - * - * @return mixed */ - public function pop() + public function pop(): mixed { return array_pop($this->stack); } diff --git a/src/PhpSpreadsheet/Calculation/Engine/Logger.php b/src/PhpSpreadsheet/Calculation/Engine/Logger.php index bd7ba70632..106731f2b0 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/Logger.php +++ b/src/PhpSpreadsheet/Calculation/Engine/Logger.php @@ -8,20 +8,16 @@ class Logger * Flag to determine whether a debug log should be generated by the calculation engine * If true, then a debug log will be generated * If false, then a debug log will not be generated. - * - * @var bool */ - private $writeDebugLog = false; + private bool $writeDebugLog = false; /** * Flag to determine whether a debug log should be echoed by the calculation engine * If true, then a debug log will be echoed * If false, then a debug log will not be echoed * A debug log can only be echoed if it is generated. - * - * @var bool */ - private $echoDebugLog = false; + private bool $echoDebugLog = false; /** * The debug log generated by the calculation engine. @@ -55,10 +51,8 @@ public function setWriteDebugLog($writeDebugLog): void /** * Return whether calculation engine logging is enabled or disabled. - * - * @return bool */ - public function getWriteDebugLog() + public function getWriteDebugLog(): bool { return $this->writeDebugLog; } @@ -75,10 +69,8 @@ public function setEchoDebugLog($echoDebugLog): void /** * Return whether echoing of debug log information is enabled or disabled. - * - * @return bool */ - public function getEchoDebugLog() + public function getEchoDebugLog(): bool { return $this->echoDebugLog; } diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Complex.php b/src/PhpSpreadsheet/Calculation/Engineering/Complex.php index 4ae0342e76..3e41371be3 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Complex.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Complex.php @@ -28,8 +28,7 @@ class Complex * If omitted, the suffix is assumed to be "i". * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 COMPLEX(mixed $realNumber = 0.0, mixed $imaginary = 0.0, mixed $suffix = 'i'): array|string diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php b/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php index 5b0daf1c61..d1b7764af0 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php @@ -22,11 +22,10 @@ class ComplexFunctions * @param array|string $complexNumber the complex number for which you want the absolute value * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMABS($complexNumber) + public static function IMABS(array|string $complexNumber): array|float|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -53,11 +52,10 @@ public static function IMABS($complexNumber) * @param array|string $complexNumber the complex number for which you want the argument theta * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMARGUMENT($complexNumber) + public static function IMARGUMENT(array|string $complexNumber): array|float|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -87,11 +85,10 @@ public static function IMARGUMENT($complexNumber) * @param array|string $complexNumber the complex number for which you want the conjugate * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMCONJUGATE($complexNumber): array|string + public static function IMCONJUGATE(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -117,11 +114,10 @@ public static function IMCONJUGATE($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the cosine * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMCOS(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -147,11 +143,10 @@ public static function IMCOS($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the hyperbolic cosine * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMCOSH(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -177,11 +172,10 @@ public static function IMCOSH($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the cotangent * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMCOT(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -207,11 +201,10 @@ public static function IMCOT($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the cosecant * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMCSC(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -237,11 +230,10 @@ public static function IMCSC($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the hyperbolic cosecant * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMCSCH(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -267,11 +259,10 @@ public static function IMCSCH($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the sine * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMSIN(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -297,11 +288,10 @@ public static function IMSIN($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the hyperbolic sine * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMSINH(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -327,11 +317,10 @@ public static function IMSINH($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the secant * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMSEC(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -357,11 +346,10 @@ public static function IMSEC($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the hyperbolic secant * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMSECH(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -387,11 +375,10 @@ public static function IMSECH($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the tangent * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string + public static function IMTAN(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -417,11 +404,10 @@ public static function IMTAN($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the square root * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMSQRT($complexNumber): array|string + public static function IMSQRT(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -452,11 +438,10 @@ public static function IMSQRT($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the natural logarithm * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMLN($complexNumber): array|string + public static function IMLN(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -486,11 +471,10 @@ public static function IMLN($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the common logarithm * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMLOG10($complexNumber): array|string + public static function IMLOG10(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -520,11 +504,10 @@ public static function IMLOG10($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the base-2 logarithm * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMLOG2($complexNumber): array|string + public static function IMLOG2(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -554,11 +537,10 @@ public static function IMLOG2($complexNumber): array|string * @param array|string $complexNumber the complex number for which you want the exponential * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMEXP($complexNumber): array|string + public static function IMEXP(array|string $complexNumber): array|string { if (is_array($complexNumber)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $complexNumber); @@ -586,11 +568,10 @@ public static function IMEXP($complexNumber): array|string * @param array|float|int|string $realNumber the power to which you want to raise the complex number * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMPOWER($complexNumber, $realNumber): array|string + public static function IMPOWER(array|string $complexNumber, array|float|int|string $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 bab5082812..61efa84768 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php @@ -25,11 +25,10 @@ class ComplexOperations * @param array|string $complexDivisor the complex denominator or divisor * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMDIV($complexDividend, $complexDivisor): array|string + public static function IMDIV(array|string $complexDividend, array|string $complexDivisor): array|string { if (is_array($complexDividend) || is_array($complexDivisor)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexDividend, $complexDivisor); @@ -55,11 +54,10 @@ public static function IMDIV($complexDividend, $complexDivisor): array|string * @param array|string $complexNumber2 the complex number to subtract from complexNumber1 * Or can be an array of values * - * @return array|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 IMSUB($complexNumber1, $complexNumber2): array|string + public static function IMSUB(array|string $complexNumber1, array|string $complexNumber2): array|string { if (is_array($complexNumber1) || is_array($complexNumber2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $complexNumber1, $complexNumber2); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php index 2a846f0321..9d897576f1 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php @@ -615,12 +615,7 @@ private static function getUOMDetails(string $uom): array throw new Exception('UoM Not Found'); } - /** - * @param float|int $value - * - * @return float|int - */ - protected static function convertTemperature(string $fromUOM, string $toUOM, $value) + protected static function convertTemperature(string $fromUOM, string $toUOM, float|int $value): float|int { $fromUOM = self::resolveTemperatureSynonyms($fromUOM); $toUOM = self::resolveTemperatureSynonyms($toUOM); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Erf.php b/src/PhpSpreadsheet/Calculation/Engineering/Erf.php index 3c14ecd846..8a64a23463 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Erf.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Erf.php @@ -31,8 +31,7 @@ class Erf * If omitted, ERF integrates between zero and lower_limit * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 ERF(mixed $lower, mixed $upper = null): array|float|string @@ -64,8 +63,7 @@ public static function ERF(mixed $lower, mixed $upper = null): array|float|strin * @param mixed $limit Float bound for integrating ERF, other bound is zero * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 ERFPRECISE(mixed $limit) diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php b/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php index e133c4cc43..4365feccd8 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ErfC.php @@ -26,8 +26,7 @@ class ErfC * @param mixed $value The float lower bound for integrating ERFC * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 ERFC(mixed $value) @@ -47,12 +46,8 @@ public static function ERFC(mixed $value) /** * Method to calculate the erfc value. - * - * @param float|int|string $value - * - * @return float */ - private static function erfcValue($value): float|int + private static function erfcValue(float|int|string $value): float|int { $value = (float) $value; if (abs($value) < 2.2) { diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php index 2cca27a384..9435909091 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Constant/Periodic/Cumulative.php @@ -27,8 +27,6 @@ class Cumulative * @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 interest( mixed $rate, @@ -92,8 +90,6 @@ public static function interest( * @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 principal( mixed $rate, diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php index f2e537d365..2c6453ab35 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php @@ -29,10 +29,8 @@ class NonPeriodic * The first payment date indicates the beginning of the schedule of payments * All other dates must be later than this date, but they may occur in any order * @param mixed $guess An optional guess at the expected answer - * - * @return float|string */ - public static function rate(array $values, array $dates, mixed $guess = self::DEFAULT_GUESS) + public static function rate(array $values, array $dates, mixed $guess = self::DEFAULT_GUESS): float|string { $rslt = self::xirrPart1($values, $dates); if ($rslt !== '') { @@ -118,10 +116,8 @@ public static function rate(array $values, array $dates, mixed $guess = self::DE * @param mixed[] $dates A schedule of payment dates that corresponds to the cash flow payments. * The first payment date indicates the beginning of the schedule of payments. * All other dates must be later than this date, but they may occur in any order. - * - * @return float|string */ - public static function presentValue($rate, $values, $dates) + public static function presentValue($rate, $values, $dates): float|string { return self::xnpvOrdered($rate, $values, $dates, true); } @@ -243,10 +239,7 @@ private static function xirrBisection(array $values, array $dates, float $x1, fl return $rslt; } - /** - * @return float|string - */ - private static function xnpvOrdered(mixed $rate, mixed $values, mixed $dates, bool $ordered = true, bool $capAtNegative1 = false) + private static function xnpvOrdered(mixed $rate, mixed $values, mixed $dates, bool $ordered = true, bool $capAtNegative1 = false): float|string { $rate = Functions::flattenSingleValue($rate); $values = Functions::flattenArray($values); diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php index c5fffcd596..21e537be2d 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/Periodic.php @@ -135,8 +135,6 @@ public static function modifiedRate(mixed $values, mixed $financeRate, mixed $re * Returns the Net Present Value of a cash flow series given a discount rate. * * @param array $args - * - * @return float */ public static function presentValue(mixed $rate, ...$args): int|float { diff --git a/src/PhpSpreadsheet/Calculation/Financial/Coupons.php b/src/PhpSpreadsheet/Calculation/Financial/Coupons.php index d84f7efb71..34376fe9d5 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Coupons.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Coupons.php @@ -39,8 +39,6 @@ class Coupons * 2 Actual/360 * 3 Actual/365 * 4 European 30/360 - * - * @return float|string */ public static function COUPDAYBS( mixed $settlement, @@ -102,8 +100,6 @@ public static function COUPDAYBS( * 2 Actual/360 * 3 Actual/365 * 4 European 30/360 - * - * @return float|string */ public static function COUPDAYS( mixed $settlement, diff --git a/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php b/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php index a0f6f6bf26..b9396456f4 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php @@ -33,8 +33,6 @@ class Depreciation * depreciation. Period must use the same units as life. * @param mixed $month Number of months in the first year. If month is omitted, * it defaults to 12. - * - * @return float|string */ public static function DB(mixed $cost, mixed $salvage, mixed $life, mixed $period, mixed $month = 12): string|float|int { @@ -99,10 +97,8 @@ public static function DB(mixed $cost, mixed $salvage, mixed $life, mixed $perio * @param mixed $factor The rate at which the balance declines. * If factor is omitted, it is assumed to be 2 (the * double-declining balance method). - * - * @return float|string */ - public static function DDB(mixed $cost, mixed $salvage, mixed $life, mixed $period, mixed $factor = 2.0) + public static function DDB(mixed $cost, mixed $salvage, mixed $life, mixed $period, mixed $factor = 2.0): float|string { $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 b1535d46f7..b0581f66c8 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Dollar.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Dollar.php @@ -25,8 +25,7 @@ class Dollar * If you omit precision, it is assumed to be 2 * Or can be an array of precision values * - * @return array|string - * If an array of values is passed for either of the arguments, then the returned result + * @return array|string 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 format(mixed $number, mixed $precision = 2) diff --git a/src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php b/src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php index e0c7e35217..2989a29b31 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Securities/Rates.php @@ -31,8 +31,6 @@ class Rates * 2 Actual/360 * 3 Actual/365 * 4 European 30/360 - * - * @return float|string */ public static function discount( mixed $settlement, @@ -40,7 +38,7 @@ public static function discount( mixed $price, mixed $redemption, mixed $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): float|string { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $price = Functions::flattenSingleValue($price); @@ -94,8 +92,6 @@ public static function discount( * 2 Actual/360 * 3 Actual/365 * 4 European 30/360 - * - * @return float|string */ public static function interest( mixed $settlement, @@ -103,7 +99,7 @@ public static function interest( mixed $investment, mixed $redemption, mixed $basis = FinancialConstants::BASIS_DAYS_PER_YEAR_NASD - ) { + ): float|string { $settlement = Functions::flattenSingleValue($settlement); $maturity = Functions::flattenSingleValue($maturity); $investment = Functions::flattenSingleValue($investment); diff --git a/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php b/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php index 8c3d6c3e33..dcef439903 100644 --- a/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php +++ b/src/PhpSpreadsheet/Calculation/Information/ErrorValue.php @@ -14,8 +14,7 @@ class ErrorValue * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool 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(mixed $value = ''): array|bool @@ -33,8 +32,7 @@ public static function isErr(mixed $value = ''): array|bool * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool 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(mixed $value = ''): array|bool @@ -56,8 +54,7 @@ public static function isError(mixed $value = ''): array|bool * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool 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(mixed $value = ''): array|bool diff --git a/src/PhpSpreadsheet/Calculation/Information/Value.php b/src/PhpSpreadsheet/Calculation/Information/Value.php index 863102b6c8..c9a7a0af3e 100644 --- a/src/PhpSpreadsheet/Calculation/Information/Value.php +++ b/src/PhpSpreadsheet/Calculation/Information/Value.php @@ -20,8 +20,7 @@ class Value * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool 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(mixed $value = null): array|bool @@ -69,8 +68,7 @@ public static function isRef(mixed $value, ?Cell $cell = null): bool * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool|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 isEven(mixed $value = null): array|string|bool @@ -94,8 +92,7 @@ public static function isEven(mixed $value = null): array|string|bool * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool|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 isOdd(mixed $value = null): array|string|bool @@ -119,8 +116,7 @@ public static function isOdd(mixed $value = null): array|string|bool * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool 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(mixed $value = null): array|bool @@ -142,8 +138,7 @@ public static function isNumber(mixed $value = null): array|bool * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool 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(mixed $value = null): array|bool @@ -161,8 +156,7 @@ public static function isLogical(mixed $value = null): array|bool * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool 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(mixed $value = null): array|bool @@ -180,8 +174,7 @@ public static function isText(mixed $value = null): array|bool * @param mixed $value Value to check * Or can be an array of values * - * @return array|bool - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|bool 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(mixed $value = null): array|bool @@ -198,10 +191,8 @@ public static function isNonText(mixed $value = null): array|bool * * @param mixed $cellReference The cell to check * @param ?Cell $cell The current cell (containing this formula) - * - * @return array|bool|string */ - public static function isFormula(mixed $cellReference = '', ?Cell $cell = null) + public static function isFormula(mixed $cellReference = '', ?Cell $cell = null): array|bool|string { if ($cell === null) { return ExcelError::REF(); diff --git a/src/PhpSpreadsheet/Calculation/Logical/Operations.php b/src/PhpSpreadsheet/Calculation/Logical/Operations.php index 51c8827378..16bb5dd4c7 100644 --- a/src/PhpSpreadsheet/Calculation/Logical/Operations.php +++ b/src/PhpSpreadsheet/Calculation/Logical/Operations.php @@ -130,10 +130,7 @@ public static function NOT(mixed $logical = false): array|bool|string return !$logical; } - /** - * @return bool|string - */ - private static function countTrueValues(array $args, callable $func) + private static function countTrueValues(array $args, callable $func): bool|string { $trueValueCount = 0; $count = 0; diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Address.php b/src/PhpSpreadsheet/Calculation/LookupRef/Address.php index eb9ecd9dfa..0a5347b837 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Address.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Address.php @@ -44,8 +44,7 @@ class Address * @param mixed $sheetName Optional Name of worksheet to use * Or can be an array of values * - * @return array|string - * If an array of values is passed as the $testValue argument, then the returned result will also be + * @return array|string 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(mixed $row, mixed $column, mixed $relativity = 1, mixed $referenceStyle = true, mixed $sheetName = ''): array|string diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php b/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php index 2adc87c4fc..3372ca58b9 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php @@ -113,10 +113,7 @@ private static function matchFirstValue(array $lookupArray, mixed $lookupValue): return null; } - /** - * @return mixed - */ - private static function matchLargestValue(array $lookupArray, mixed $lookupValue, array $keySet) + private static function matchLargestValue(array $lookupArray, mixed $lookupValue, array $keySet): mixed { if (is_string($lookupValue)) { if (Functions::getCompatibilityMode() === Functions::COMPATIBILITY_OPENOFFICE) { diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Filter.php b/src/PhpSpreadsheet/Calculation/LookupRef/Filter.php index 920b8e7ed4..a8ef114b41 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Filter.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Filter.php @@ -6,10 +6,7 @@ class Filter { - /** - * @return mixed - */ - public static function filter(mixed $lookupArray, mixed $matchArray, mixed $ifEmpty = null) + public static function filter(mixed $lookupArray, mixed $matchArray, mixed $ifEmpty = null): mixed { if (!is_array($matchArray)) { return ExcelError::VALUE(); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php b/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php index e4990ced6d..74d4865b23 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php @@ -13,10 +13,8 @@ class Formula * * @param mixed $cellReference The cell to check * @param Cell $cell The current cell (containing this formula) - * - * @return string */ - public static function text(mixed $cellReference = '', ?Cell $cell = null) + public static function text(mixed $cellReference = '', ?Cell $cell = null): string { if ($cell === null) { return ExcelError::REF(); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php b/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php index fa048b7dd2..720f28d9b7 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php @@ -33,10 +33,7 @@ public static function unique(mixed $lookupVector, mixed $byColumn = false, mixe : self::uniqueByRow($lookupVector, $exactlyOnce); } - /** - * @return mixed - */ - private static function uniqueByRow(array $lookupVector, bool $exactlyOnce) + private static function uniqueByRow(array $lookupVector, bool $exactlyOnce): mixed { // When not $byColumn, we count whole rows or values, not individual values // so implode each row into a single string value @@ -70,10 +67,7 @@ function (string &$value): void { return (count($result) === 1) ? array_pop($result) : $result; } - /** - * @return mixed - */ - private static function uniqueByColumn(array $lookupVector, bool $exactlyOnce) + private static function uniqueByColumn(array $lookupVector, bool $exactlyOnce): mixed { $flattenedLookupVector = Functions::flattenArray($lookupVector); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Gcd.php b/src/PhpSpreadsheet/Calculation/MathTrig/Gcd.php index 6641ac628e..f2aedb60b2 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Gcd.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Gcd.php @@ -17,13 +17,8 @@ class Gcd * * Excel Function: * GCD(number1[,number2[, ...]]) - * - * @param float|int $a - * @param float|int $b - * - * @return float|int */ - private static function evaluateGCD($a, $b) + private static function evaluateGCD(float|int $a, float|int $b): float|int { return $b ? self::evaluateGCD($b, $a % $b) : $a; } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php index 74feb7aa91..9d6775f4f1 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php @@ -134,8 +134,7 @@ public static function atanh($number) * @param mixed $xCoordinate should be float, the x-coordinate of the point, or can be an array of numbers * @param mixed $yCoordinate should be float, the y-coordinate of the point, or can be an array of numbers * - * @return array|float|string - * The inverse tangent of the specified x- and y-coordinates, or a string containing an error + * @return array|float|string The inverse tangent of the specified x- and y-coordinates, or a string containing an error * 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 */ diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php b/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php index ae4f61e6f1..d4db9eaa53 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php @@ -23,8 +23,7 @@ class Confidence * @param mixed $size As an integer * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 CONFIDENCE(mixed $alpha, mixed $stdDev, mixed $size) diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php index d99ee60042..fe18965f3a 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php @@ -33,8 +33,7 @@ class Beta * @param mixed $rMax as an float * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distribution(mixed $value, mixed $alpha, mixed $beta, mixed $rMin = 0.0, mixed $rMax = 1.0): array|string|float @@ -87,8 +86,7 @@ public static function distribution(mixed $value, mixed $alpha, mixed $beta, mix * @param mixed $rMax Maximum value as a float * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 inverse(mixed $probability, mixed $alpha, mixed $beta, mixed $rMin = 0.0, mixed $rMax = 1.0): array|string|float diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php index a4abb0699f..68fa8821b9 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php @@ -30,8 +30,7 @@ class Binomial * @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false) * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distribution(mixed $value, mixed $trials, mixed $probability, mixed $cumulative) @@ -79,8 +78,7 @@ public static function distribution(mixed $value, mixed $trials, mixed $probabil * If null, then this will indicate the same as the number of Successes * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 range(mixed $trials, mixed $probability, mixed $successes, mixed $limit = null): array|string|float|int diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php index c3cc80b3a4..67edbccede 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php @@ -23,8 +23,7 @@ class ChiSquared * @param mixed $degrees Integer degrees of freedom * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distributionRightTail(mixed $value, mixed $degrees): array|string|int|float @@ -66,8 +65,7 @@ public static function distributionRightTail(mixed $value, mixed $degrees): arra * @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false) * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distributionLeftTail(mixed $value, mixed $degrees, mixed $cumulative): array|string|int|float @@ -115,8 +113,7 @@ public static function distributionLeftTail(mixed $value, mixed $degrees, mixed * @param mixed $degrees Integer degrees of freedom * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 inverseRightTail(mixed $probability, mixed $degrees) @@ -156,8 +153,7 @@ public static function inverseRightTail(mixed $probability, mixed $degrees) * @param mixed $degrees Integer degrees of freedom * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 inverseLeftTail(mixed $probability, mixed $degrees): array|string|float diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php index ba56848d73..55264737fd 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php @@ -24,8 +24,7 @@ class Exponential * @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false) * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distribution(mixed $value, mixed $lambda, mixed $cumulative): array|string|float diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php index 2b2bd4348e..aa7a19dcf2 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php @@ -27,8 +27,7 @@ class F * @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false) * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distribution(mixed $value, mixed $u, mixed $v, mixed $cumulative): array|string|float diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php index 2f494bc2cf..9ad10dbc74 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php @@ -20,8 +20,7 @@ class Fisher * @param mixed $value Float value for which we want the probability * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distribution(mixed $value): array|string|float @@ -53,8 +52,7 @@ public static function distribution(mixed $value): array|string|float * @param mixed $probability Float probability at which you want to evaluate the distribution * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 inverse(mixed $probability): array|string|float diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php index 58986c1705..babe937d34 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php @@ -55,8 +55,7 @@ public static function gamma(mixed $value): array|string|float * @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false) * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distribution(mixed $value, mixed $a, mixed $b, mixed $cumulative) @@ -93,8 +92,7 @@ public static function distribution(mixed $value, mixed $a, mixed $b, mixed $cum * @param mixed $beta Parameter to the distribution as a float * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 inverse(mixed $probability, mixed $alpha, mixed $beta) @@ -126,8 +124,7 @@ public static function inverse(mixed $probability, mixed $alpha, mixed $beta) * @param mixed $value Float Value at which you want to evaluate the distribution * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 ln(mixed $value): array|string|float diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php index 6e072c5e3b..345ea81bff 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php @@ -26,8 +26,7 @@ class HyperGeometric * @param mixed $populationNumber Integer population size * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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 distribution(mixed $sampleSuccesses, mixed $sampleNumber, mixed $populationSuccesses, mixed $populationNumber): array|string|float diff --git a/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php b/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php index 088c9cdc87..83cc4ee1f1 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php +++ b/src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php @@ -17,8 +17,7 @@ class CaseConvert * @param mixed $mixedCaseValue The string value to convert to lower case * Or can be an array of values * - * @return array|string - * If an array of values is passed as the argument, then the returned result will also be an array + * @return array|string 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(mixed $mixedCaseValue): array|string @@ -40,8 +39,7 @@ public static function lower(mixed $mixedCaseValue): array|string * @param mixed $mixedCaseValue The string value to convert to upper case * Or can be an array of values * - * @return array|string - * If an array of values is passed as the argument, then the returned result will also be an array + * @return array|string 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(mixed $mixedCaseValue): array|string @@ -63,8 +61,7 @@ public static function upper(mixed $mixedCaseValue): array|string * @param mixed $mixedCaseValue The string value to convert to title case * Or can be an array of values * - * @return array|string - * If an array of values is passed as the argument, then the returned result will also be an array + * @return array|string 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(mixed $mixedCaseValue): array|string diff --git a/src/PhpSpreadsheet/Calculation/TextData/Format.php b/src/PhpSpreadsheet/Calculation/TextData/Format.php index 845df2471b..88434f85e6 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Format.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Format.php @@ -32,8 +32,7 @@ class Format * If you omit decimals, it is assumed to be 2 * Or can be an array of values * - * @return array|string - * If an array of values is passed for either of the arguments, then the returned result + * @return array|string 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 DOLLAR(mixed $value = 0, mixed $decimals = 2) @@ -74,8 +73,7 @@ public static function DOLLAR(mixed $value = 0, mixed $decimals = 2) * @param mixed $noCommas Boolean value indicating whether the value should have thousands separators or not * Or can be an array of values * - * @return array|string - * If an array of values is passed for either of the arguments, then the returned result + * @return array|string 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(mixed $value, mixed $decimals = 2, mixed $noCommas = false): array|string @@ -115,8 +113,7 @@ public static function FIXEDFORMAT(mixed $value, mixed $decimals = 2, mixed $noC * @param mixed $format A string with the Format mask that should be used * Or can be an array of values * - * @return array|string - * If an array of values is passed for either of the arguments, then the returned result + * @return array|string 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(mixed $value, mixed $format): array|string @@ -225,8 +222,7 @@ public static function VALUE(mixed $value = '') * @param mixed $value The value to format * Or can be an array of values * - * @return array|string - * If an array of values is passed for either of the arguments, then the returned result + * @return array|string 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(mixed $value, mixed $format = false): array|string diff --git a/src/PhpSpreadsheet/Calculation/TextData/Replace.php b/src/PhpSpreadsheet/Calculation/TextData/Replace.php index 1515864659..8f6f196fe4 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Replace.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Replace.php @@ -25,8 +25,7 @@ class Replace * @param mixed $newText String to replace in the defined position * Or can be an array of values * - * @return array|string - * If an array of values is passed for either of the arguments, then the returned result + * @return array|string 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(mixed $oldText, mixed $start, mixed $chars, mixed $newText): array|string @@ -66,8 +65,7 @@ public static function replace(mixed $oldText, mixed $start, mixed $chars, mixed * @param mixed $instance Integer instance Number for the occurrence of frmText to change * Or can be an array of values * - * @return array|string - * If an array of values is passed for either of the arguments, then the returned result + * @return array|string 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(mixed $text = '', mixed $fromText = '', mixed $toText = '', mixed $instance = null): array|string diff --git a/src/PhpSpreadsheet/Calculation/TextData/Text.php b/src/PhpSpreadsheet/Calculation/TextData/Text.php index cca613f7cf..162bfff680 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Text.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Text.php @@ -42,8 +42,7 @@ public static function length(mixed $value = ''): array|int * @param mixed $value2 String Value * Or can be an array of values * - * @return array|bool - * If an array of values is passed for either of the arguments, then the returned result + * @return array|bool 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(mixed $value1, mixed $value2): array|bool @@ -64,8 +63,7 @@ public static function exact(mixed $value1, mixed $value2): array|bool * @param mixed $testValue Value to check * Or can be an array of values * - * @return array|string - * If an array of values is passed for the argument, then the returned result + * @return array|string 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(mixed $testValue = ''): array|string diff --git a/src/PhpSpreadsheet/Calculation/TextData/Trim.php b/src/PhpSpreadsheet/Calculation/TextData/Trim.php index 24a54bf22a..d8f170621f 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Trim.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Trim.php @@ -14,8 +14,7 @@ class Trim * @param mixed $stringValue String Value to check * Or can be an array of values * - * @return array|string - * If an array of values is passed as the argument, then the returned result will also be an array + * @return array|string 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 nonPrintable(mixed $stringValue = '') @@ -35,8 +34,7 @@ public static function nonPrintable(mixed $stringValue = '') * @param mixed $stringValue String Value to check * Or can be an array of values * - * @return array|string - * If an array of values is passed as the argument, then the returned result will also be an array + * @return array|string 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(mixed $stringValue = ''): array|string diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index db92998286..faa80cd064 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -201,7 +201,7 @@ public static function convertIsoDate(mixed $value) * * @return DateTime PHP date/time object */ - public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) + public static function excelToDateTimeObject($excelTimestamp, $timeZone = null): DateTime { $timeZone = ($timeZone === null) ? self::getDefaultTimezone() : self::validateTimeZone($timeZone); if (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_EXCEL) { @@ -237,7 +237,7 @@ public static function excelToDateTimeObject($excelTimestamp, $timeZone = null) $interval = $days . ' days'; return $baseDate->modify($interval) - ->setTime((int) $hours, (int) $minutes, (int) $seconds, (int) $microseconds); + ->setTime($hours, $minutes, $seconds, $microseconds); } /** From 77e6cc528cf68de9f963bbf94853b762d1031b45 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sat, 9 Dec 2023 23:29:45 +0100 Subject: [PATCH 05/25] Apply PhpCsFixer `phpdoc_to_property_type` --- infra/LocaleGenerator.php | 25 +- phpstan-baseline.neon | 972 +++++++++++++++++- .../Calculation/ArrayEnabled.php | 5 +- .../Calculation/Calculation.php | 88 +- .../Engine/ArrayArgumentHelper.php | 33 +- .../Engine/ArrayArgumentProcessor.php | 5 +- .../Calculation/Engine/BranchPruner.php | 21 +- .../Engine/CyclicReferenceStack.php | 2 +- .../Calculation/Engine/Logger.php | 2 +- .../Calculation/Engineering/ConvertUOM.php | 8 +- .../Calculation/Financial/Depreciation.php | 3 +- .../Calculation/FormulaParser.php | 2 +- .../Calculation/FormulaToken.php | 12 +- src/PhpSpreadsheet/Calculation/Functions.php | 8 +- .../Calculation/Information/ExcelError.php | 2 +- .../Statistical/Distributions/Beta.php | 10 +- .../Statistical/Distributions/GammaBase.php | 7 +- .../Calculation/Token/Stack.php | 6 +- src/PhpSpreadsheet/Cell/Cell.php | 15 +- src/PhpSpreadsheet/Cell/CellRange.php | 12 +- src/PhpSpreadsheet/Cell/DataType.php | 2 +- src/PhpSpreadsheet/Cell/DataValidation.php | 44 +- src/PhpSpreadsheet/Cell/Hyperlink.php | 8 +- src/PhpSpreadsheet/Cell/IgnoredErrors.php | 12 +- src/PhpSpreadsheet/Cell/StringValueBinder.php | 20 +- src/PhpSpreadsheet/Chart/Axis.php | 5 +- src/PhpSpreadsheet/Chart/Chart.php | 44 +- src/PhpSpreadsheet/Chart/DataSeries.php | 41 +- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 72 +- src/PhpSpreadsheet/Chart/Legend.php | 8 +- src/PhpSpreadsheet/Chart/PlotArea.php | 12 +- src/PhpSpreadsheet/Chart/Properties.php | 14 +- src/PhpSpreadsheet/Chart/Title.php | 4 +- src/PhpSpreadsheet/Chart/TrendLine.php | 21 +- src/PhpSpreadsheet/Collection/Cells.php | 18 +- .../Collection/Memory/SimpleCache1.php | 2 +- .../Collection/Memory/SimpleCache3.php | 2 +- src/PhpSpreadsheet/Comment.php | 4 +- src/PhpSpreadsheet/Document/Properties.php | 2 +- src/PhpSpreadsheet/Document/Security.php | 12 +- src/PhpSpreadsheet/HashTable.php | 4 +- src/PhpSpreadsheet/Helper/Dimension.php | 5 +- src/PhpSpreadsheet/Helper/Handler.php | 3 +- src/PhpSpreadsheet/Helper/Html.php | 36 +- src/PhpSpreadsheet/Helper/TextGrid.php | 5 +- src/PhpSpreadsheet/IOFactory.php | 4 +- src/PhpSpreadsheet/Reader/BaseReader.php | 18 +- src/PhpSpreadsheet/Reader/Csv.php | 32 +- src/PhpSpreadsheet/Reader/Csv/Delimiter.php | 8 +- src/PhpSpreadsheet/Reader/Gnumeric.php | 11 +- src/PhpSpreadsheet/Reader/Gnumeric/Styles.php | 3 +- src/PhpSpreadsheet/Reader/Html.php | 24 +- .../Reader/Ods/PageSettings.php | 29 +- src/PhpSpreadsheet/Reader/Slk.php | 24 +- src/PhpSpreadsheet/Reader/Xls.php | 141 +-- .../Reader/Xls/ConditionalFormatting.php | 4 +- .../Reader/Xls/DataValidationHelper.php | 6 +- src/PhpSpreadsheet/Reader/Xls/Escher.php | 12 +- src/PhpSpreadsheet/Reader/Xls/MD5.php | 20 +- src/PhpSpreadsheet/Reader/Xls/RC4.php | 8 +- .../Reader/Xls/Style/Border.php | 2 +- .../Reader/Xls/Style/CellAlignment.php | 4 +- .../Reader/Xls/Style/CellFont.php | 2 +- .../Reader/Xls/Style/FillPattern.php | 2 +- src/PhpSpreadsheet/Reader/Xlsx.php | 13 +- .../Reader/Xlsx/ConditionalStyles.php | 5 +- src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php | 3 +- src/PhpSpreadsheet/Reader/Xlsx/Styles.php | 17 +- src/PhpSpreadsheet/Reader/Xlsx/Theme.php | 10 +- src/PhpSpreadsheet/Reader/Xml.php | 7 +- src/PhpSpreadsheet/Reader/Xml/Style.php | 4 +- src/PhpSpreadsheet/ReferenceHelper.php | 7 +- src/PhpSpreadsheet/RichText/Run.php | 2 +- src/PhpSpreadsheet/RichText/TextElement.php | 4 +- src/PhpSpreadsheet/Settings.php | 15 +- src/PhpSpreadsheet/Shared/CodePage.php | 3 +- src/PhpSpreadsheet/Shared/Date.php | 12 +- src/PhpSpreadsheet/Shared/Escher.php | 4 +- .../Escher/DgContainer/SpgrContainer.php | 4 +- .../DgContainer/SpgrContainer/SpContainer.php | 80 +- .../Shared/Escher/DggContainer.php | 22 +- .../Escher/DggContainer/BstoreContainer.php | 2 +- .../DggContainer/BstoreContainer/BSE.php | 10 +- .../DggContainer/BstoreContainer/BSE/Blip.php | 4 +- src/PhpSpreadsheet/Shared/File.php | 4 +- src/PhpSpreadsheet/Shared/Font.php | 16 +- src/PhpSpreadsheet/Shared/OLE.php | 22 +- .../Shared/OLE/ChainedBlockStream.php | 14 +- src/PhpSpreadsheet/Shared/OLE/PPS.php | 42 +- src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 4 +- src/PhpSpreadsheet/Shared/OLERead.php | 62 +- src/PhpSpreadsheet/Shared/StringHelper.php | 20 +- src/PhpSpreadsheet/Shared/TimeZone.php | 4 +- src/PhpSpreadsheet/Shared/Trend/BestFit.php | 60 +- .../Shared/Trend/ExponentialBestFit.php | 4 +- .../Shared/Trend/LinearBestFit.php | 4 +- .../Shared/Trend/LogarithmicBestFit.php | 4 +- .../Shared/Trend/PolynomialBestFit.php | 8 +- .../Shared/Trend/PowerBestFit.php | 4 +- src/PhpSpreadsheet/Shared/Trend/Trend.php | 6 +- src/PhpSpreadsheet/Shared/XMLWriter.php | 3 +- src/PhpSpreadsheet/Shared/Xls.php | 12 +- src/PhpSpreadsheet/Spreadsheet.php | 66 +- src/PhpSpreadsheet/Style/Alignment.php | 28 +- src/PhpSpreadsheet/Style/Border.php | 9 +- src/PhpSpreadsheet/Style/Borders.php | 20 +- src/PhpSpreadsheet/Style/Color.php | 7 +- src/PhpSpreadsheet/Style/Conditional.php | 14 +- .../ConditionalFormatting/CellMatcher.php | 30 +- .../ConditionalDataBarExtension.php | 65 +- .../Wizard/CellValue.php | 8 +- .../Wizard/DateValue.php | 3 +- .../Wizard/Expression.php | 5 +- .../Wizard/TextValue.php | 11 +- .../Wizard/WizardAbstract.php | 27 +- src/PhpSpreadsheet/Style/Fill.php | 21 +- src/PhpSpreadsheet/Style/Font.php | 60 +- src/PhpSpreadsheet/Style/NumberFormat.php | 12 +- src/PhpSpreadsheet/Style/Style.php | 10 +- src/PhpSpreadsheet/Style/Supervisor.php | 8 +- src/PhpSpreadsheet/Theme.php | 6 +- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 5 +- .../Worksheet/AutoFilter/Column.php | 20 +- .../Worksheet/AutoFilter/Column/Rule.php | 12 +- src/PhpSpreadsheet/Worksheet/BaseDrawing.php | 48 +- src/PhpSpreadsheet/Worksheet/CellIterator.php | 16 +- .../Worksheet/ColumnCellIterator.php | 8 +- .../Worksheet/ColumnDimension.php | 8 +- .../Worksheet/ColumnIterator.php | 16 +- src/PhpSpreadsheet/Worksheet/Dimension.php | 12 +- src/PhpSpreadsheet/Worksheet/HeaderFooter.php | 42 +- src/PhpSpreadsheet/Worksheet/Iterator.php | 4 +- src/PhpSpreadsheet/Worksheet/PageMargins.php | 24 +- src/PhpSpreadsheet/Worksheet/PageSetup.php | 51 +- src/PhpSpreadsheet/Worksheet/Protection.php | 8 +- src/PhpSpreadsheet/Worksheet/Row.php | 4 +- .../Worksheet/RowCellIterator.php | 12 +- src/PhpSpreadsheet/Worksheet/RowDimension.php | 8 +- src/PhpSpreadsheet/Worksheet/RowIterator.php | 16 +- src/PhpSpreadsheet/Worksheet/SheetView.php | 12 +- src/PhpSpreadsheet/Worksheet/Table.php | 14 +- src/PhpSpreadsheet/Worksheet/Table/Column.php | 4 +- .../Worksheet/Table/TableStyle.php | 16 +- src/PhpSpreadsheet/Worksheet/Worksheet.php | 106 +- src/PhpSpreadsheet/Writer/BaseWriter.php | 21 +- src/PhpSpreadsheet/Writer/Csv.php | 23 +- src/PhpSpreadsheet/Writer/Html.php | 56 +- src/PhpSpreadsheet/Writer/Ods.php | 4 +- src/PhpSpreadsheet/Writer/Ods/Formula.php | 3 +- src/PhpSpreadsheet/Writer/Pdf.php | 10 +- src/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 4 +- src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 3 +- src/PhpSpreadsheet/Writer/Xls.php | 35 +- src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php | 14 +- .../Writer/Xls/CellDataValidation.php | 6 +- .../Writer/Xls/ConditionalHelper.php | 5 +- src/PhpSpreadsheet/Writer/Xls/ErrorCode.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Escher.php | 12 +- src/PhpSpreadsheet/Writer/Xls/Font.php | 5 +- src/PhpSpreadsheet/Writer/Xls/Parser.php | 27 +- .../Writer/Xls/Style/CellAlignment.php | 4 +- .../Writer/Xls/Style/CellBorder.php | 2 +- .../Writer/Xls/Style/CellFill.php | 2 +- .../Writer/Xls/Style/ColorMap.php | 2 +- src/PhpSpreadsheet/Writer/Xls/Workbook.php | 44 +- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 42 +- src/PhpSpreadsheet/Writer/Xlsx.php | 17 +- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 5 +- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 12 +- .../Calculation/Engine/RangeTest.php | 3 +- .../Database/SetupTeardownDatabases.php | 4 +- .../Functions/Financial/AllSetupTeardown.php | 4 +- .../Functions/Logical/AllSetupTeardown.php | 4 +- .../Functions/LookupRef/AllSetupTeardown.php | 9 +- .../Functions/LookupRef/IndirectTest.php | 3 +- .../Functions/MathTrig/AllSetupTeardown.php | 4 +- .../Statistical/AllSetupTeardown.php | 4 +- .../Functions/TextData/AllSetupTeardown.php | 4 +- .../Functions/Web/WebServiceTest.php | 2 +- .../Calculation/RowColumnReferenceTest.php | 5 +- .../Cell/CellDetachTest.php | 2 +- .../Chart/Charts32CatAxValAxTest.php | 3 +- .../Custom/ComplexAssert.php | 3 +- .../Document/PropertiesTest.php | 8 +- tests/PhpSpreadsheetTests/NamedRange2Test.php | 2 +- .../Reader/Csv/CsvContiguousFilter.php | 15 +- .../Reader/Csv/CsvContiguousTest.php | 5 +- .../Reader/Csv/CsvLineEndingTest.php | 3 +- .../Reader/Csv/CsvNumberFormatLocaleTest.php | 10 +- .../Reader/Csv/CsvNumberFormatTest.php | 10 +- .../Reader/Ods/EmptyFileTest.php | 3 +- .../Reader/Ods/OdsTest.php | 3 +- .../Reader/Slk/SlkTest.php | 12 +- .../Reader/Xls/LoadSheetsOnlyTest.php | 7 +- .../Reader/Xlsx/EmptyFileTest.php | 3 +- .../Reader/Xlsx/ExplicitDateTest.php | 5 +- .../Reader/Xlsx/Issue1482Test.php | 5 +- .../Reader/Xlsx/Issue2301Test.php | 5 +- .../Reader/Xlsx/Issue2488Test.php | 5 +- .../Reader/Xlsx/Issue2490Test.php | 10 +- .../Reader/Xlsx/Issue2501Test.php | 5 +- .../Reader/Xlsx/Issue2516Test.php | 5 +- .../Reader/Xlsx/Issue2542Test.php | 5 +- .../Reader/Xlsx/Issue2778Test.php | 5 +- .../Reader/Xlsx/Issue2885Test.php | 5 +- .../Reader/Xlsx/Issue3435Test.php | 5 +- .../Reader/Xlsx/Issue3464Test.php | 5 +- .../Reader/Xlsx/Issue3495Test.php | 5 +- .../Reader/Xlsx/Issue3534Test.php | 5 +- .../Reader/Xlsx/Issue3552Test.php | 5 +- .../Reader/Xlsx/Issue3553Test.php | 5 +- .../Reader/Xlsx/Issue3665Test.php | 5 +- .../Reader/Xlsx/LoadSheetsOnlyTest.php | 7 +- .../Reader/Xlsx/NamespaceIssue2109bTest.php | 5 +- .../Reader/Xlsx/NamespaceNonStdTest.php | 5 +- .../Reader/Xlsx/NamespaceOpenpyxl35Test.php | 5 +- .../Reader/Xlsx/NamespacePurlTest.php | 5 +- .../Reader/Xlsx/NamespaceStdTest.php | 5 +- .../Reader/Xlsx/SharedFormulaTest.php | 5 +- .../Reader/Xlsx/SplitsTest.php | 5 +- .../Reader/Xlsx/XlsxRootZipFilesTest.php | 5 +- .../Reader/Xml/DataValidationsTest.php | 3 +- .../Reader/Xml/PageSetupTest.php | 5 +- .../Reader/Xml/SplitsTest.php | 5 +- .../Reader/Xml/XmlLoadTest.php | 2 +- .../Reader/Xml/XmlOddTest.php | 5 +- .../Reader/Xml/XmlPropertiesTest.php | 3 +- .../ReferenceHelper3Test.php | 3 +- .../PhpSpreadsheetTests/Shared/Date2Test.php | 2 +- tests/PhpSpreadsheetTests/Shared/FileTest.php | 3 +- .../SpreadsheetCoverageTest.php | 4 +- tests/PhpSpreadsheetTests/SpreadsheetTest.php | 2 +- .../Style/AlignmentMiddleTest.php | 5 +- .../Style/AlignmentTest.php | 2 +- .../Style/ConditionalBoolTest.php | 3 +- .../ConditionalFormatting/CellMatcherTest.php | 2 +- .../Wizard/BlankWizardTest.php | 19 +- .../Wizard/CellValueWizardTest.php | 15 +- .../Wizard/DateValueWizardTest.php | 15 +- .../Wizard/DuplicatesWizardTest.php | 19 +- .../Wizard/ErrorWizardTest.php | 19 +- .../Wizard/ExpressionWizardTest.php | 15 +- .../Wizard/TextValueWizardTest.php | 19 +- .../Wizard/WizardFactoryTest.php | 5 +- .../Worksheet/AutoFilter/SetupTeardown.php | 9 +- .../ByColumnAndRowUndeprecatedTest.php | 2 +- .../Worksheet/ConditionalStyleTest.php | 5 +- .../Worksheet/MergeBehaviourTest.php | 10 +- .../Worksheet/RemoveTest.php | 2 +- .../Worksheet/Table/SetupTeardown.php | 9 +- .../Writer/Dompdf/PaperSizeArrayTest.php | 3 +- .../Writer/Html/HtmlCommentsTest.php | 5 +- .../Writer/Html/ImageCopyTest.php | 3 +- .../Writer/Mpdf/ImageCopyPdfTest.php | 3 +- .../Writer/Ods/ContentTest.php | 5 +- .../Writer/PreCalcTest.php | 3 +- .../Writer/Xls/FormulaErrTest.php | 4 +- .../Writer/Xls/ParserTest.php | 2 +- .../Writer/Xls/WorkbookTest.php | 7 +- .../Writer/Xls/XlsGifBmpTest.php | 5 +- .../Writer/Xlsx/CalculationErrorTest.php | 4 +- .../Writer/Xlsx/ConditionalTest.php | 10 +- .../Writer/Xlsx/LocaleFloatsTest.php | 4 +- .../Writer/Xlsx/Unparsed2396Test.php | 3 +- 264 files changed, 1909 insertions(+), 2385 deletions(-) diff --git a/infra/LocaleGenerator.php b/infra/LocaleGenerator.php index 5e570f7f0f..f7df3de553 100644 --- a/infra/LocaleGenerator.php +++ b/infra/LocaleGenerator.php @@ -28,38 +28,23 @@ class LocaleGenerator private const ENGLISH_REFERENCE_COLUMN = 'B'; private const EOL = "\n"; // not PHP_EOL - /** - * @var string - */ - protected $translationSpreadsheetName; + protected string $translationSpreadsheetName; - /** - * @var string - */ - protected $translationBaseFolder; + protected string $translationBaseFolder; protected $phpSpreadsheetFunctions; - /** - * @var Spreadsheet - */ - protected $translationSpreadsheet; + protected Spreadsheet $translationSpreadsheet; protected $verbose; - /** - * @var Worksheet - */ - protected $localeTranslations; + protected Worksheet $localeTranslations; protected $localeLanguageMap = []; protected $errorCodeMap = []; - /** - * @var Worksheet - */ - private $functionNameTranslations; + private Worksheet $functionNameTranslations; protected $functionNameLanguageMap = []; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index ff99e79fcc..02b3e86709 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -225,20 +225,975 @@ parameters: count: 1 path: samples/Wizards/NumberFormat/Scientific.php + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateParts.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateParts.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/NetworkDays.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BesselI.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BesselI.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BesselJ.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BesselK.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BesselK.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BesselY.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BesselY.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/Compare.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/Compare.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/Complex.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/Complex.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ComplexFunctions.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ComplexOperations.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ConvertBase.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ConvertBase.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/Erf.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/Erf.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ErfC.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Engineering/ErfC.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php + - message: "#^Cannot call method getTokenSubType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" count: 4 - path: src/PhpSpreadsheet/Calculation/FormulaParser.php + path: src/PhpSpreadsheet/Calculation/FormulaParser.php + + - + message: "#^Cannot call method getTokenType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" + count: 8 + path: src/PhpSpreadsheet/Calculation/FormulaParser.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Information/ErrorValue.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Information/ErrorValue.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Information/ExcelError.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Information/ExcelError.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Information/Value.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Information/Value.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Logical/Conditional.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Logical/Conditional.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Logical/Operations.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Logical/Operations.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/Address.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/Address.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/HLookup.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/HLookup.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/Selection.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/Selection.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Absolute.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Absolute.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Angle.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Angle.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Base.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Base.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Ceiling.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Ceiling.php + + - + message: "#^Binary operation \"/\" between float and array\\|float\\|int\\|string results in an error\\.$#" + count: 1 + path: src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Exp.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Exp.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Floor.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Floor.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/IntClass.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Logarithms.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Logarithms.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Operations.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Operations.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Random.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Random.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Roman.php - - message: "#^Cannot call method getTokenType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" - count: 8 - path: src/PhpSpreadsheet/Calculation/FormulaParser.php + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Roman.php - - message: "#^Binary operation \"/\" between float and array\\|float\\|int\\|string results in an error\\.$#" + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Round.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Round.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Sign.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Sign.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Sqrt.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Sqrt.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosecant.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosecant.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosine.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cosine.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cotangent.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Cotangent.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Secant.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Secant.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Sine.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Sine.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trig/Tangent.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Confidence.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Confidence.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Exponential.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/F.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Gamma.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/HyperGeometric.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Normal.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/StudentT.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/StudentT.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Weibull.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Weibull.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Permutations.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Permutations.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Standardize.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Standardize.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/CaseConvert.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/CharacterConvert.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/CharacterConvert.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Concatenate.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Concatenate.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Extract.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Extract.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Format.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Format.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Replace.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Replace.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Search.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Search.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Text.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Text.php + + - + message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Trim.php + + - + message: "#^Parameter \\#1 \\$arrayArgumentHelper of static method PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentProcessor\\:\\:processArguments\\(\\) expects PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper, PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null given\\.$#" + count: 4 + path: src/PhpSpreadsheet/Calculation/TextData/Trim.php + + - + message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#" count: 1 - path: src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php + path: src/PhpSpreadsheet/Chart/DataSeriesValues.php + + - + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeriesValues\\:\\:getDataValues\\(\\) should return array but returns array\\|null\\.$#" + count: 1 + path: src/PhpSpreadsheet/Chart/DataSeriesValues.php + + - + message: "#^Offset 0 does not exist on array\\|null\\.$#" + count: 1 + path: src/PhpSpreadsheet/Chart/DataSeriesValues.php + + - + message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\|null given\\.$#" + count: 1 + path: src/PhpSpreadsheet/Chart/DataSeriesValues.php + + - + message: "#^Cannot call method beforeCellAddress\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\CellReferenceHelper\\|null\\.$#" + count: 1 + path: src/PhpSpreadsheet/ReferenceHelper.php + + - + message: "#^Cannot call method cellAddressInDeleteRange\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\CellReferenceHelper\\|null\\.$#" + count: 3 + path: src/PhpSpreadsheet/ReferenceHelper.php + + - + message: "#^Cannot call method updateCellReference\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\CellReferenceHelper\\|null\\.$#" + count: 4 + path: src/PhpSpreadsheet/ReferenceHelper.php - message: "#^Offset 2 does not exist on array\\{int, int, int, int\\}\\|array\\{int, int\\}\\.$#" @@ -250,6 +1205,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Worksheet/Validations.php + - + message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:getChartType\\(\\) should return array\\ but returns array\\, string\\|null\\>\\.$#" + count: 1 + path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php + - message: "#^Parameter \\#2 \\$value of function ini_set expects string, int given\\.$#" count: 1 diff --git a/src/PhpSpreadsheet/Calculation/ArrayEnabled.php b/src/PhpSpreadsheet/Calculation/ArrayEnabled.php index e20203ad32..934813e813 100644 --- a/src/PhpSpreadsheet/Calculation/ArrayEnabled.php +++ b/src/PhpSpreadsheet/Calculation/ArrayEnabled.php @@ -7,10 +7,7 @@ trait ArrayEnabled { - /** - * @var ArrayArgumentHelper - */ - private static $arrayArgumentHelper; + private static ?ArrayArgumentHelper $arrayArgumentHelper = null; /** * @param array|false $arguments Can be changed to array for Php8.1+ diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index d8d0557399..4156051a52 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -62,15 +62,14 @@ class Calculation const FORMULA_CLOSE_MATRIX_BRACE = '}'; const FORMULA_STRING_QUOTE = '"'; - /** @var string */ - private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE; + private static string $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE; /** * Instance of this class. * * @var ?Calculation */ - private static $instance; + private static ?Calculation $instance = null; /** * Instance of the spreadsheet this Calculation Engine is using. @@ -79,24 +78,17 @@ class Calculation /** * Calculation cache. - * - * @var array */ - private $calculationCache = []; + private array $calculationCache = []; /** * Calculation cache enabled. - * - * @var bool */ - private $calculationCacheEnabled = true; + private bool $calculationCacheEnabled = true; private BranchPruner $branchPruner; - /** - * @var bool - */ - private $branchPruningEnabled = true; + private bool $branchPruningEnabled = true; /** * List of operators that can be used within formulae @@ -134,17 +126,14 @@ class Calculation * * @deprecated 1.25.2 use setSuppressFormulaErrors() instead */ - public $suppressFormulaErrors; + public ?bool $suppressFormulaErrors = null; - /** @var bool */ - private $suppressFormulaErrorsNew = false; + private bool $suppressFormulaErrorsNew = false; /** * Error message for any error that was raised/thrown by the calculation engine. - * - * @var null|string */ - public $formulaError; + public ?string $formulaError = null; /** * Reference Helper. @@ -156,34 +145,26 @@ class Calculation */ private CyclicReferenceStack $cyclicReferenceStack; - /** @var array */ - private $cellStack = []; + private array $cellStack = []; /** * Current iteration counter for cyclic formulae * If the value is 0 (or less) then cyclic formulae will throw an exception, * otherwise they will iterate to the limit defined here before returning a result. - * - * @var int */ - private $cyclicFormulaCounter = 1; + private int $cyclicFormulaCounter = 1; - /** @var string */ - private $cyclicFormulaCell = ''; + private string $cyclicFormulaCell = ''; /** * Number of iterations for cyclic formulae. - * - * @var int */ - public $cyclicFormulaCount = 1; + public int $cyclicFormulaCount = 1; /** * The current locale setting. - * - * @var string */ - private static $localeLanguage = 'en_us'; // US English (default locale) + private static string $localeLanguage = 'en_us'; // US English (default locale) /** * List of available locale settings @@ -191,26 +172,23 @@ class Calculation * * @var string[] */ - private static $validLocaleLanguages = [ + private static array $validLocaleLanguages = [ 'en', // English (default language) ]; /** * Locale-specific argument separator for function arguments. - * - * @var string */ - private static $localeArgumentSeparator = ','; + private static string $localeArgumentSeparator = ','; - /** @var array */ - private static $localeFunctions = []; + private static array $localeFunctions = []; /** * Locale-specific translations for Excel constants (True, False and Null). * * @var array */ - private static $localeBoolean = [ + private static array $localeBoolean = [ 'TRUE' => 'TRUE', 'FALSE' => 'FALSE', 'NULL' => 'NULL', @@ -227,7 +205,7 @@ public static function getLocaleBoolean(string $index): string * * @var array */ - private static $excelConstants = [ + private static array $excelConstants = [ 'TRUE' => true, 'FALSE' => false, 'NULL' => null, @@ -248,10 +226,8 @@ public static function getExcelConstants(string $key) * Array of functions usable on Spreadsheet. * In theory, this could be const rather than static; * however, Phpstan breaks trying to analyze it when attempted. - * - *@var array */ - private static $phpSpreadsheetFunctions = [ + private static array $phpSpreadsheetFunctions = [ 'ABS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, 'functionCall' => [MathTrig\Absolute::class, 'evaluate'], @@ -2891,10 +2867,8 @@ public static function getExcelConstants(string $key) /** * Internal functions used for special control purposes. - * - * @var array */ - private static $controlFunctions = [ + private static array $controlFunctions = [ 'MKMATRIX' => [ 'argumentCount' => '*', 'functionCall' => [Internal\MakeMatrix::class, 'make'], @@ -2945,7 +2919,7 @@ public static function getInstance(?Spreadsheet $spreadsheet = null): self } } - if (!isset(self::$instance) || (self::$instance === null)) { + if (!self::$instance) { self::$instance = new self(); } @@ -3321,10 +3295,10 @@ private static function translateFormula(array $from, array $to, string $formula } /** @var ?array */ - private static $functionReplaceFromExcel; + private static ?array $functionReplaceFromExcel; /** @var ?array */ - private static $functionReplaceToLocale; + private static ?array $functionReplaceToLocale; public function _translateFormulaToLocale(string $formula): string { @@ -3359,10 +3333,10 @@ public function _translateFormulaToLocale(string $formula): string } /** @var ?array */ - private static $functionReplaceFromLocale; + private static ?array $functionReplaceFromLocale; /** @var ?array */ - private static $functionReplaceToExcel; + private static ?array $functionReplaceToExcel; public function _translateFormulaToEnglish(string $formula): string { @@ -4034,10 +4008,8 @@ private function convertMatrixReferences(string $formula): false|string * Binary Operators. * These operators always work on two values. * Array key is the operator, the value indicates whether this is a left or right associative operator. - * - * @var array */ - private static $operatorAssociativity = [ + private static array $operatorAssociativity = [ '^' => 0, // Exponentiation '*' => 0, '/' => 0, // Multiplication and Division '+' => 0, '-' => 0, // Addition and Subtraction @@ -4049,19 +4021,15 @@ private function convertMatrixReferences(string $formula): false|string /** * Comparison (Boolean) Operators. * These operators work on two values, but always return a boolean result. - * - * @var array */ - private static $comparisonOperators = ['>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true]; + private static array $comparisonOperators = ['>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true]; /** * Operator Precedence. * This list includes all valid operators, whether binary (including boolean) or unary (such as %). * Array key is the operator, the value is its precedence. - * - * @var array */ - private static $operatorPrecedence = [ + private static array $operatorPrecedence = [ ':' => 9, // Range '∩' => 8, // Intersect '∪' => 7, // Union diff --git a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php index bd019ac8a9..29fc490234 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php +++ b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php @@ -6,30 +6,15 @@ class ArrayArgumentHelper { - /** - * @var int - */ - protected $indexStart = 0; - - /** - * @var array - */ - protected $arguments; - - /** - * @var int - */ - protected $argumentCount; - - /** - * @var array - */ - protected $rows; - - /** - * @var array - */ - protected $columns; + protected int $indexStart = 0; + + protected array $arguments; + + protected int $argumentCount; + + protected array $rows; + + protected array $columns; public function initialise(array $arguments): void { diff --git a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentProcessor.php b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentProcessor.php index 0b1ec58a83..fb2c853b3e 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentProcessor.php +++ b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentProcessor.php @@ -6,10 +6,7 @@ class ArrayArgumentProcessor { - /** - * @var ArrayArgumentHelper - */ - private static $arrayArgumentHelper; + private static ArrayArgumentHelper $arrayArgumentHelper; public static function processArguments( ArrayArgumentHelper $arrayArgumentHelper, diff --git a/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php b/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php index 00328fb629..1c58d04ac9 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php +++ b/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php @@ -10,42 +10,40 @@ class BranchPruner /** * Used to generate unique store keys. - * - * @var int */ - private $branchStoreKeyCounter = 0; + private int $branchStoreKeyCounter = 0; /** * currently pending storeKey (last item of the storeKeysStack. * * @var ?string */ - protected $pendingStoreKey; + protected ?string $pendingStoreKey = null; /** * @var string[] */ - protected $storeKeysStack = []; + protected array $storeKeysStack = []; /** * @var bool[] */ - protected $conditionMap = []; + protected array $conditionMap = []; /** * @var bool[] */ - protected $thenMap = []; + protected array $thenMap = []; /** * @var bool[] */ - protected $elseMap = []; + protected array $elseMap = []; /** * @var int[] */ - protected $braceDepthMap = []; + protected array $braceDepthMap = []; protected ?string $currentCondition = null; @@ -53,10 +51,7 @@ class BranchPruner protected ?string $currentOnlyIfNot = null; - /** - * @var null|string - */ - protected $previousStoreKey; + protected ?string $previousStoreKey = null; public function __construct(bool $branchPruningEnabled) { diff --git a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php index f76ced9119..b13865761f 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php +++ b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php @@ -9,7 +9,7 @@ class CyclicReferenceStack * * @var mixed[] */ - private $stack = []; + private array $stack = []; /** * Return the number of entries on the stack. diff --git a/src/PhpSpreadsheet/Calculation/Engine/Logger.php b/src/PhpSpreadsheet/Calculation/Engine/Logger.php index 106731f2b0..20f8e92c0a 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/Logger.php +++ b/src/PhpSpreadsheet/Calculation/Engine/Logger.php @@ -24,7 +24,7 @@ class Logger * * @var string[] */ - private $debugLog = []; + private array $debugLog = []; /** * The calculation engine cell reference stack. diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php index 9d897576f1..ac4787fda4 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php @@ -29,7 +29,7 @@ class ConvertUOM * * @var mixed[] */ - private static $conversionUnits = [ + private static array $conversionUnits = [ // Weight and Mass 'g' => ['Group' => self::CATEGORY_WEIGHT_AND_MASS, 'Unit Name' => 'Gram', 'AllowPrefix' => true], 'sg' => ['Group' => self::CATEGORY_WEIGHT_AND_MASS, 'Unit Name' => 'Slug', 'AllowPrefix' => false], @@ -203,7 +203,7 @@ class ConvertUOM * * @var mixed[] */ - private static $conversionMultipliers = [ + private static array $conversionMultipliers = [ 'Y' => ['multiplier' => 1E24, 'name' => 'yotta'], 'Z' => ['multiplier' => 1E21, 'name' => 'zetta'], 'E' => ['multiplier' => 1E18, 'name' => 'exa'], @@ -232,7 +232,7 @@ class ConvertUOM * * @var mixed[] */ - private static $binaryConversionMultipliers = [ + private static array $binaryConversionMultipliers = [ 'Yi' => ['multiplier' => 2 ** 80, 'name' => 'yobi'], 'Zi' => ['multiplier' => 2 ** 70, 'name' => 'zebi'], 'Ei' => ['multiplier' => 2 ** 60, 'name' => 'exbi'], @@ -248,7 +248,7 @@ class ConvertUOM * * @var mixed[] */ - private static $unitConversions = [ + private static array $unitConversions = [ // Conversion uses gram (g) as an intermediate unit self::CATEGORY_WEIGHT_AND_MASS => [ 'g' => 1.0, diff --git a/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php b/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php index b9396456f4..6ef1899957 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Depreciation.php @@ -8,8 +8,7 @@ class Depreciation { - /** @var float */ - private static $zeroPointZero = 0.0; + private static float $zeroPointZero = 0.0; /** * DB. diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index cffce179c6..40dfe52391 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -54,7 +54,7 @@ class FormulaParser * * @var FormulaToken[] */ - private $tokens = []; + private array $tokens = []; /** * Create a new FormulaParser. diff --git a/src/PhpSpreadsheet/Calculation/FormulaToken.php b/src/PhpSpreadsheet/Calculation/FormulaToken.php index 68e5eead81..8186a06703 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaToken.php +++ b/src/PhpSpreadsheet/Calculation/FormulaToken.php @@ -54,24 +54,18 @@ class FormulaToken /** * Value. - * - * @var string */ - private $value; + private string $value; /** * Token Type (represented by TOKEN_TYPE_*). - * - * @var string */ - private $tokenType; + private string $tokenType; /** * Token SubType (represented by TOKEN_SUBTYPE_*). - * - * @var string */ - private $tokenSubType; + private string $tokenSubType; /** * Create a new FormulaToken. diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 9cde3351c1..33a79ed606 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -28,17 +28,13 @@ class Functions /** * Compatibility mode to use for error checking and responses. - * - * @var string */ - protected static $compatibilityMode = self::COMPATIBILITY_EXCEL; + protected static string $compatibilityMode = self::COMPATIBILITY_EXCEL; /** * Data Type to use when returning date values. - * - * @var string */ - protected static $returnDateType = self::RETURNDATE_EXCEL; + protected static string $returnDateType = self::RETURNDATE_EXCEL; /** * Set the Compatibility Mode. diff --git a/src/PhpSpreadsheet/Calculation/Information/ExcelError.php b/src/PhpSpreadsheet/Calculation/Information/ExcelError.php index 083feee203..b1514cf9a5 100644 --- a/src/PhpSpreadsheet/Calculation/Information/ExcelError.php +++ b/src/PhpSpreadsheet/Calculation/Information/ExcelError.php @@ -39,7 +39,7 @@ class ExcelError * * @var array */ - public static $errorCodes = self::ERROR_CODES; + public static array $errorCodes = self::ERROR_CODES; public static function throwError(mixed $value): string { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php index fe18965f3a..16817ce6a5 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Beta.php @@ -179,14 +179,12 @@ public static function incompleteBeta(float $x, float $p, float $q): float } // Function cache for logBeta function - /** @var float */ - private static $logBetaCacheP = 0.0; - /** @var float */ - private static $logBetaCacheQ = 0.0; + private static float $logBetaCacheP = 0.0; - /** @var float */ - private static $logBetaCacheResult = 0.0; + private static float $logBetaCacheQ = 0.0; + + private static float $logBetaCacheResult = 0.0; /** * The natural logarithm of the beta function. diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php index f199bbfbef..01901a60c5 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php @@ -217,11 +217,10 @@ public static function gammaValue(float $value): float private const PNT68 = 0.6796875; // Function cache for logGamma - /** @var float */ - private static $logGammaCacheResult = 0.0; - /** @var float */ - private static $logGammaCacheX = 0.0; + private static float $logGammaCacheResult = 0.0; + + private static float $logGammaCacheX = 0.0; /** * logGamma function. diff --git a/src/PhpSpreadsheet/Calculation/Token/Stack.php b/src/PhpSpreadsheet/Calculation/Token/Stack.php index 7617e3e868..13c6e5b1ac 100644 --- a/src/PhpSpreadsheet/Calculation/Token/Stack.php +++ b/src/PhpSpreadsheet/Calculation/Token/Stack.php @@ -14,14 +14,12 @@ class Stack * * @var mixed[] */ - private $stack = []; + private array $stack = []; /** * Count of entries in the parser stack. - * - * @var int */ - private $count = 0; + private int $count = 0; public function __construct(BranchPruner $branchPruner) { diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index 8ebc115a88..edff0aebf0 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -22,10 +22,8 @@ class Cell implements Stringable { /** * Value binder to use. - * - * @var IValueBinder */ - private static $valueBinder; + private static ?IValueBinder $valueBinder = null; /** * Value of the cell. @@ -60,10 +58,8 @@ class Cell implements Stringable /** * Index to the cellXf reference for the styling of this cell. - * - * @var int */ - private $xfIndex = 0; + private int $xfIndex = 0; /** * Attributes of the formula. @@ -310,15 +306,14 @@ public function setValueExplicit(mixed $value, string $dataType = DataType::TYPE public const CALCULATE_DATE_TIME_FLOAT = 1; public const CALCULATE_TIME_FLOAT = 2; - /** @var int */ - private static $calculateDateTimeType = self::CALCULATE_DATE_TIME_ASIS; + private static int $calculateDateTimeType = self::CALCULATE_DATE_TIME_ASIS; public static function getCalculateDateTimeType(): int { return self::$calculateDateTimeType; } - /** @throws CalculationException*/ + /** @throws CalculationException */ public static function setCalculateDateTimeType(int $calculateDateTimeType): void { self::$calculateDateTimeType = match ($calculateDateTimeType) { @@ -688,7 +683,7 @@ public function isInRange(string $range): bool // Verify if cell is in range return ($rangeStart[0] <= $myColumn) && ($rangeEnd[0] >= $myColumn) - && ($rangeStart[1] <= $myRow) && ($rangeEnd[1] >= $myRow); + && ($rangeStart[1] <= $myRow) && ($rangeEnd[1] >= $myRow); } /** diff --git a/src/PhpSpreadsheet/Cell/CellRange.php b/src/PhpSpreadsheet/Cell/CellRange.php index 3063aa825d..c3445637de 100644 --- a/src/PhpSpreadsheet/Cell/CellRange.php +++ b/src/PhpSpreadsheet/Cell/CellRange.php @@ -8,15 +8,9 @@ class CellRange implements AddressRange, Stringable { - /** - * @var CellAddress - */ - protected $from; - - /** - * @var CellAddress - */ - protected $to; + protected CellAddress $from; + + protected CellAddress $to; public function __construct(CellAddress $from, CellAddress $to) { diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php index c887d5f891..e24e694e2e 100644 --- a/src/PhpSpreadsheet/Cell/DataType.php +++ b/src/PhpSpreadsheet/Cell/DataType.php @@ -23,7 +23,7 @@ class DataType * * @var array */ - private static $errorCodes = [ + private static array $errorCodes = [ '#NULL!' => 0, '#DIV/0!' => 1, '#VALUE!' => 2, diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php index 0c6b9a6599..1cea89d557 100644 --- a/src/PhpSpreadsheet/Cell/DataValidation.php +++ b/src/PhpSpreadsheet/Cell/DataValidation.php @@ -41,80 +41,58 @@ class DataValidation /** * Type. - * - * @var string */ - private $type = self::TYPE_NONE; + private string $type = self::TYPE_NONE; /** * Error style. - * - * @var string */ - private $errorStyle = self::STYLE_STOP; + private string $errorStyle = self::STYLE_STOP; /** * Operator. - * - * @var string */ - private $operator = self::OPERATOR_BETWEEN; + private string $operator = self::OPERATOR_BETWEEN; /** * Allow Blank. - * - * @var bool */ - private $allowBlank = false; + private bool $allowBlank = false; /** * Show DropDown. - * - * @var bool */ - private $showDropDown = false; + private bool $showDropDown = false; /** * Show InputMessage. - * - * @var bool */ - private $showInputMessage = false; + private bool $showInputMessage = false; /** * Show ErrorMessage. - * - * @var bool */ - private $showErrorMessage = false; + private bool $showErrorMessage = false; /** * Error title. - * - * @var string */ - private $errorTitle = ''; + private string $errorTitle = ''; /** * Error. - * - * @var string */ - private $error = ''; + private string $error = ''; /** * Prompt title. - * - * @var string */ - private $promptTitle = ''; + private string $promptTitle = ''; /** * Prompt. - * - * @var string */ - private $prompt = ''; + private string $prompt = ''; /** * Create a new DataValidation. diff --git a/src/PhpSpreadsheet/Cell/Hyperlink.php b/src/PhpSpreadsheet/Cell/Hyperlink.php index a296c6277d..e8e550603b 100644 --- a/src/PhpSpreadsheet/Cell/Hyperlink.php +++ b/src/PhpSpreadsheet/Cell/Hyperlink.php @@ -6,17 +6,13 @@ class Hyperlink { /** * URL to link the cell to. - * - * @var string */ - private $url; + private string $url; /** * Tooltip to display on the hyperlink. - * - * @var string */ - private $tooltip; + private string $tooltip; /** * Create a new Hyperlink. diff --git a/src/PhpSpreadsheet/Cell/IgnoredErrors.php b/src/PhpSpreadsheet/Cell/IgnoredErrors.php index ee4b515620..a7c4d19dd2 100644 --- a/src/PhpSpreadsheet/Cell/IgnoredErrors.php +++ b/src/PhpSpreadsheet/Cell/IgnoredErrors.php @@ -4,17 +4,13 @@ class IgnoredErrors { - /** @var bool */ - private $numberStoredAsText = false; + private bool $numberStoredAsText = false; - /** @var bool */ - private $formula = false; + private bool $formula = false; - /** @var bool */ - private $twoDigitTextYear = false; + private bool $twoDigitTextYear = false; - /** @var bool */ - private $evalError = false; + private bool $evalError = false; public function setNumberStoredAsText(bool $value): self { diff --git a/src/PhpSpreadsheet/Cell/StringValueBinder.php b/src/PhpSpreadsheet/Cell/StringValueBinder.php index f4c6321cba..30e6dfddea 100644 --- a/src/PhpSpreadsheet/Cell/StringValueBinder.php +++ b/src/PhpSpreadsheet/Cell/StringValueBinder.php @@ -10,25 +10,13 @@ class StringValueBinder implements IValueBinder { - /** - * @var bool - */ - protected $convertNull = true; + protected bool $convertNull = true; - /** - * @var bool - */ - protected $convertBoolean = true; + protected bool $convertBoolean = true; - /** - * @var bool - */ - protected $convertNumeric = true; + protected bool $convertNumeric = true; - /** - * @var bool - */ - protected $convertFormula = true; + protected bool $convertFormula = true; public function setNullConversion(bool $suppressConversion = false): self { diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index 3054759024..2b31baf1e7 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -39,7 +39,7 @@ public function __construct() * * @var mixed[] */ - private $axisNumber = [ + private array $axisNumber = [ 'format' => self::FORMAT_CODE_GENERAL, 'source_linked' => 1, 'numeric' => null, @@ -83,8 +83,7 @@ public function __construct() Properties::FORMAT_CODE_DATE_ISO8601, ]; - /** @var bool */ - private $noFill = false; + private bool $noFill = false; /** * Get Series Data Type. diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index b86b19cdd0..22feb14434 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -9,10 +9,8 @@ class Chart { /** * Chart Name. - * - * @var string */ - private $name = ''; + private string $name = ''; /** * Worksheet. @@ -46,17 +44,13 @@ class Chart /** * Plot Visible Only. - * - * @var bool */ - private $plotVisibleOnly = true; + private bool $plotVisibleOnly = true; /** * Display Blanks as. - * - * @var string */ - private $displayBlanksAs = DataSeries::EMPTY_AS_GAP; + private string $displayBlanksAs = DataSeries::EMPTY_AS_GAP; /** * Chart Asix Y as. @@ -70,24 +64,18 @@ class Chart /** * Top-Left Cell Position. - * - * @var string */ - private $topLeftCellRef = 'A1'; + private string $topLeftCellRef = 'A1'; /** * Top-Left X-Offset. - * - * @var int */ - private $topLeftXOffset = 0; + private int $topLeftXOffset = 0; /** * Top-Left Y-Offset. - * - * @var int */ - private $topLeftYOffset = 0; + private int $topLeftYOffset = 0; /** * Bottom-Right Cell Position. @@ -96,17 +84,13 @@ class Chart /** * Bottom-Right X-Offset. - * - * @var int */ - private $bottomRightXOffset = 10; + private int $bottomRightXOffset = 10; /** * Bottom-Right Y-Offset. - * - * @var int */ - private $bottomRightYOffset = 10; + private int $bottomRightYOffset = 10; private ?int $rotX = null; @@ -116,17 +100,13 @@ class Chart private ?int $perspective = null; - /** @var bool */ - private $oneCellAnchor = false; + private bool $oneCellAnchor = false; - /** @var bool */ - private $autoTitleDeleted = false; + private bool $autoTitleDeleted = false; - /** @var bool */ - private $noFill = false; + private bool $noFill = false; - /** @var bool */ - private $roundedCorners = false; + private bool $roundedCorners = false; private GridLines $borderLines; diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index d0391c22da..baadcf56a3 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -46,31 +46,23 @@ class DataSeries /** * Series Plot Type. - * - * @var string */ - private $plotType; + private ?string $plotType; /** * Plot Grouping Type. - * - * @var string */ - private $plotGrouping; + private ?string $plotGrouping; /** * Plot Direction. - * - * @var string */ - private $plotDirection; + private string $plotDirection; /** * Plot Style. - * - * @var null|string */ - private $plotStyle; + private ?string $plotStyle = null; /** * Order of plots in Series. @@ -95,10 +87,8 @@ class DataSeries /** * Smooth Line. Must be specified for both DataSeries and DataSeriesValues. - * - * @var bool */ - private $smoothLine; + private bool $smoothLine; /** * Plot Values. @@ -112,13 +102,12 @@ class DataSeries * * @var DataSeriesValues[] */ - private $plotBubbleSizes = []; + private array $plotBubbleSizes = []; /** * Create a new DataSeries. * * @param null|mixed $plotType - * @param null|mixed $plotGrouping * @param int[] $plotOrder * @param DataSeriesValues[] $plotLabel * @param DataSeriesValues[] $plotCategory @@ -129,7 +118,7 @@ class DataSeries */ public function __construct( $plotType = null, - $plotGrouping = null, + null|string $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], array $plotCategory = [], @@ -164,10 +153,8 @@ public function __construct( /** * Get Plot Type. - * - * @return string */ - public function getPlotType() + public function getPlotType(): ?string { return $this->plotType; } @@ -175,11 +162,9 @@ public function getPlotType() /** * Set Plot Type. * - * @param string $plotType - * * @return $this */ - public function setPlotType($plotType): static + public function setPlotType(string $plotType): static { $this->plotType = $plotType; @@ -188,10 +173,8 @@ public function setPlotType($plotType): static /** * Get Plot Grouping Type. - * - * @return string */ - public function getPlotGrouping() + public function getPlotGrouping(): ?string { return $this->plotGrouping; } @@ -199,11 +182,9 @@ public function getPlotGrouping() /** * Set Plot Grouping Type. * - * @param string $groupingType - * * @return $this */ - public function setPlotGrouping($groupingType): static + public function setPlotGrouping(string $groupingType): static { $this->plotGrouping = $groupingType; diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index d076391adb..fbdc3adfbc 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -19,31 +19,25 @@ class DataSeriesValues extends Properties /** * Series Data Type. - * - * @var string */ - private $dataType; + private string $dataType; /** * Series Data Source. * * @var ?string */ - private $dataSource; + private ?string $dataSource; /** * Format Code. - * - * @var string */ - private $formatCode; + private ?string $formatCode; /** * Series Point Marker. - * - * @var string */ - private $pointMarker; + private ?string $pointMarker; private ChartColor $markerFillColor; @@ -51,24 +45,18 @@ class DataSeriesValues extends Properties /** * Series Point Size. - * - * @var int */ - private $pointSize = 3; + private int $pointSize = 3; /** * Point Count (The number of datapoints in the dataseries). - * - * @var int */ - private $pointCount = 0; + private int $pointCount; /** * Data Values. - * - * @var mixed[] */ - private $dataValues = []; + private ?array $dataValues; /** * Fill color (can be array with colors if dataseries have custom colors). @@ -77,30 +65,30 @@ class DataSeriesValues extends Properties */ private $fillColor; - /** @var bool */ - private $scatterLines = true; + private bool $scatterLines = true; - /** @var bool */ - private $bubble3D = false; + private bool $bubble3D = false; private ?Layout $labelLayout = null; /** @var TrendLine[] */ - private $trendLines = []; + private array $trendLines = []; /** * Create a new DataSeriesValues object. * - * @param string $dataType - * @param string $dataSource - * @param null|mixed $formatCode - * @param int $pointCount - * @param mixed $dataValues - * @param null|mixed $marker * @param null|ChartColor|ChartColor[]|string|string[] $fillColor */ - public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null, $fillColor = null, int|string $pointSize = '3') - { + public function __construct( + string $dataType = self::DATASERIES_TYPE_NUMBER, + ?string $dataSource = null, + ?string $formatCode = null, + int $pointCount = 0, + ?array $dataValues = [], + ?string $marker = null, + null|ChartColor|array|string $fillColor = null, + int|string $pointSize = 3 + ) { parent::__construct(); $this->markerFillColor = new ChartColor(); $this->markerBorderColor = new ChartColor(); @@ -176,10 +164,8 @@ public function setDataSource($dataSource): static /** * Get Point Marker. - * - * @return string */ - public function getPointMarker() + public function getPointMarker(): ?string { return $this->pointMarker; } @@ -187,11 +173,9 @@ public function getPointMarker() /** * Set Point Marker. * - * @param string $marker - * * @return $this */ - public function setPointMarker($marker): static + public function setPointMarker(string $marker): static { $this->pointMarker = $marker; @@ -230,10 +214,8 @@ public function setPointSize(int $size = 3): static /** * Get Series Format Code. - * - * @return string */ - public function getFormatCode() + public function getFormatCode(): ?string { return $this->formatCode; } @@ -241,11 +223,9 @@ public function getFormatCode() /** * Set Series Format Code. * - * @param string $formatCode - * * @return $this */ - public function setFormatCode($formatCode): static + public function setFormatCode(string $formatCode): static { $this->formatCode = $formatCode; @@ -534,10 +514,8 @@ public function setBubble3D(bool $bubble3D): self /** * Smooth Line. Must be specified for both DataSeries and DataSeriesValues. - * - * @var bool */ - private $smoothLine; + private bool $smoothLine = false; /** * Get Smooth Line. diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index 7c5fa1833f..f6cbfccb4b 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -29,17 +29,13 @@ class Legend /** * Legend position. - * - * @var string */ - private $position = self::POSITION_RIGHT; + private string $position = self::POSITION_RIGHT; /** * Allow overlay of other elements? - * - * @var bool */ - private $overlay = true; + private bool $overlay = true; /** * Legend Layout. diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php index aa72fda165..91fc669cd6 100644 --- a/src/PhpSpreadsheet/Chart/PlotArea.php +++ b/src/PhpSpreadsheet/Chart/PlotArea.php @@ -8,10 +8,8 @@ class PlotArea { /** * No fill in plot area (show Excel gridlines through chart). - * - * @var bool */ - private $noFill = false; + private bool $noFill = false; /** * PlotArea Gradient Stop list. @@ -21,7 +19,7 @@ class PlotArea * * @var array[] */ - private $gradientFillStops = []; + private array $gradientFillStops = []; /** * PlotArea Gradient Angle. @@ -160,11 +158,9 @@ public function getGradientFillStops() private ?int $gapWidth = null; - /** @var bool */ - private $useUpBars = false; + private bool $useUpBars = false; - /** @var bool */ - private $useDownBars = false; + private bool $useDownBars = false; public function getGapWidth(): ?int { diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index ead6b3afc2..4245b114d5 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -112,21 +112,18 @@ abstract class Properties const ANGLE_MULTIPLIER = 60000; // direction and size-kx size-ky const PERCENTAGE_MULTIPLIER = 100000; // size sx and sy - /** @var bool */ - protected $objectState = false; // used only for minor gridlines + protected bool $objectState = false; // used only for minor gridlines /** @var ?float */ - protected $glowSize; + protected ?float $glowSize = null; protected ChartColor $glowColor; - /** @var array */ - protected $softEdges = [ + protected array $softEdges = [ 'size' => null, ]; - /** @var array */ - protected $shadowProperties = self::PRESETS_OPTIONS[0]; + protected array $shadowProperties = self::PRESETS_OPTIONS[0]; protected ChartColor $shadowColor; @@ -719,8 +716,7 @@ public function getShadowArray(): array protected ChartColor $lineColor; - /** @var array */ - protected $lineStyleProperties = [ + protected array $lineStyleProperties = [ 'width' => null, //'9525', 'compound' => '', //self::LINE_STYLE_COMPOUND_SIMPLE, 'dash' => '', //self::LINE_STYLE_DASH_SOLID, diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index d8e6e7497f..4d7c303cdf 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -15,10 +15,8 @@ class Title /** * Allow overlay of other elements? - * - * @var bool */ - private $overlay = true; + private bool $overlay = true; /** * Title Layout. diff --git a/src/PhpSpreadsheet/Chart/TrendLine.php b/src/PhpSpreadsheet/Chart/TrendLine.php index 7ea2bde815..5814fea470 100644 --- a/src/PhpSpreadsheet/Chart/TrendLine.php +++ b/src/PhpSpreadsheet/Chart/TrendLine.php @@ -21,28 +21,21 @@ class TrendLine extends Properties private string $trendLineType = 'linear'; // TRENDLINE_LINEAR - /** @var int */ - private $order = 2; + private int $order = 2; - /** @var int */ - private $period = 3; + private int $period = 3; - /** @var bool */ - private $dispRSqr = false; + private bool $dispRSqr = false; - /** @var bool */ - private $dispEq = false; + private bool $dispEq = false; private string $name = ''; - /** @var float */ - private $backward = 0.0; + private float $backward = 0.0; - /** @var float */ - private $forward = 0.0; + private float $forward = 0.0; - /** @var float */ - private $intercept = 0.0; + private float $intercept = 0.0; /** * Create a new TrendLine object. diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index c0a1dbaa56..a55bd6736d 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -18,31 +18,23 @@ class Cells /** * Parent worksheet. - * - * @var null|Worksheet */ - private $parent; + private ?Worksheet $parent = null; /** * The currently active Cell. - * - * @var null|Cell */ - private $currentCell; + private ?Cell $currentCell = null; /** * Coordinate of the currently active Cell. - * - * @var null|string */ - private $currentCoordinate; + private ?string $currentCoordinate = null; /** * Flag indicating whether the currently active Cell requires saving. - * - * @var bool */ - private $currentCellIsDirty = false; + private bool $currentCellIsDirty = false; /** * An index of existing cells. int pointer to the coordinate (0-base-indexed row * 16,384 + 1-base indexed column) @@ -50,7 +42,7 @@ class Cells * * @var int[] */ - private $index = []; + private array $index = []; /** * Prefix used to uniquely identify cache data for this worksheet. diff --git a/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php b/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php index a0eb6ec221..2dae6de81b 100644 --- a/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php +++ b/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php @@ -16,7 +16,7 @@ class SimpleCache1 implements CacheInterface /** * @var array Cell Cache */ - private $cache = []; + private array $cache = []; /** * @return bool diff --git a/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php b/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php index 34f644705c..dab9f4eedd 100644 --- a/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php +++ b/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php @@ -16,7 +16,7 @@ class SimpleCache3 implements CacheInterface /** * @var array Cell Cache */ - private $cache = []; + private array $cache = []; public function clear(): bool { diff --git a/src/PhpSpreadsheet/Comment.php b/src/PhpSpreadsheet/Comment.php index f61e1728bf..1c07b5154e 100644 --- a/src/PhpSpreadsheet/Comment.php +++ b/src/PhpSpreadsheet/Comment.php @@ -40,10 +40,8 @@ class Comment implements IComparable, Stringable /** * Visible. - * - * @var bool */ - private $visible = false; + private bool $visible = false; /** * Comment height (CSS style, i.e. XXpx or YYpt). diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index 4ec9a2b1b0..1ebf0bedea 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -83,7 +83,7 @@ class Properties * * @var array{value: mixed, type: string}[] */ - private $customProperties = []; + private array $customProperties = []; private string $hyperlinkBase = ''; diff --git a/src/PhpSpreadsheet/Document/Security.php b/src/PhpSpreadsheet/Document/Security.php index b542718fa0..31a32beb42 100644 --- a/src/PhpSpreadsheet/Document/Security.php +++ b/src/PhpSpreadsheet/Document/Security.php @@ -8,24 +8,18 @@ class Security { /** * LockRevision. - * - * @var bool */ - private $lockRevision = false; + private bool $lockRevision = false; /** * LockStructure. - * - * @var bool */ - private $lockStructure = false; + private bool $lockStructure = false; /** * LockWindows. - * - * @var bool */ - private $lockWindows = false; + private bool $lockWindows = false; /** * RevisionsPassword. diff --git a/src/PhpSpreadsheet/HashTable.php b/src/PhpSpreadsheet/HashTable.php index 3647332219..c9762ab478 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -12,14 +12,14 @@ class HashTable * * @var array */ - protected $items = []; + protected array $items = []; /** * HashTable key map. * * @var array */ - protected $keyMap = []; + protected array $keyMap = []; /** * Create a new HashTable. diff --git a/src/PhpSpreadsheet/Helper/Dimension.php b/src/PhpSpreadsheet/Helper/Dimension.php index 7afb803c40..cb053da836 100644 --- a/src/PhpSpreadsheet/Helper/Dimension.php +++ b/src/PhpSpreadsheet/Helper/Dimension.php @@ -50,10 +50,7 @@ class Dimension */ protected float|int $size; - /** - * @var null|string - */ - protected $unit; + protected ?string $unit = null; /** * Phpstan bug has been fixed; this function allows us to diff --git a/src/PhpSpreadsheet/Helper/Handler.php b/src/PhpSpreadsheet/Helper/Handler.php index d05197cef0..fb1b9a04d5 100644 --- a/src/PhpSpreadsheet/Helper/Handler.php +++ b/src/PhpSpreadsheet/Helper/Handler.php @@ -4,8 +4,7 @@ class Handler { - /** @var string */ - private static $invalidHex = 'Y'; + private static string $invalidHex = 'Y'; // A bunch of methods to show that we continue // to capture messages even using PhpUnit 10. diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index 9b2d1d5236..05b47176e8 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -533,34 +533,28 @@ class Html ]; /** @var ?string */ - private $face; + private ?string $face = null; /** @var ?string */ - private $size; + private ?string $size = null; /** @var ?string */ - private $color; + private ?string $color = null; - /** @var bool */ - private $bold = false; + private bool $bold = false; - /** @var bool */ - private $italic = false; + private bool $italic = false; - /** @var bool */ - private $underline = false; + private bool $underline = false; - /** @var bool */ - private $superscript = false; + private bool $superscript = false; - /** @var bool */ - private $subscript = false; + private bool $subscript = false; - /** @var bool */ - private $strikethrough = false; + private bool $strikethrough = false; /** @var callable[] */ - private $startTagCallbacks = [ + private array $startTagCallbacks = [ 'font' => [self::class, 'startFontTag'], 'b' => [self::class, 'startBoldTag'], 'strong' => [self::class, 'startBoldTag'], @@ -574,7 +568,7 @@ class Html ]; /** @var callable[] */ - private $endTagCallbacks = [ + private array $endTagCallbacks = [ 'font' => [self::class, 'endFontTag'], 'b' => [self::class, 'endBoldTag'], 'strong' => [self::class, 'endBoldTag'], @@ -595,15 +589,11 @@ class Html 'h6' => [self::class, 'breakTag'], ]; - /** @var array */ - private $stack = []; + private array $stack = []; public string $stringData = ''; - /** - * @var RichText - */ - private $richTextObject; + private RichText $richTextObject; private function initialise(): void { diff --git a/src/PhpSpreadsheet/Helper/TextGrid.php b/src/PhpSpreadsheet/Helper/TextGrid.php index 8088560d02..f706b58fbe 100644 --- a/src/PhpSpreadsheet/Helper/TextGrid.php +++ b/src/PhpSpreadsheet/Helper/TextGrid.php @@ -12,10 +12,7 @@ class TextGrid protected array $columns; - /** - * @var string - */ - private $gridDisplay; + private string $gridDisplay; public function __construct(array $matrix, bool $isCli = true) { diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php index 454b2aae40..b895b6e603 100644 --- a/src/PhpSpreadsheet/IOFactory.php +++ b/src/PhpSpreadsheet/IOFactory.php @@ -31,7 +31,7 @@ abstract class IOFactory public const WRITER_HTML = 'Html'; /** @var string[] */ - private static $readers = [ + private static array $readers = [ self::READER_XLSX => Reader\Xlsx::class, self::READER_XLS => Reader\Xls::class, self::READER_XML => Reader\Xml::class, @@ -43,7 +43,7 @@ abstract class IOFactory ]; /** @var string[] */ - private static $writers = [ + private static array $writers = [ self::WRITER_XLS => Writer\Xls::class, self::WRITER_XLSX => Writer\Xlsx::class, self::WRITER_ODS => Writer\Ods::class, diff --git a/src/PhpSpreadsheet/Reader/BaseReader.php b/src/PhpSpreadsheet/Reader/BaseReader.php index 435926531f..23fdf9917c 100644 --- a/src/PhpSpreadsheet/Reader/BaseReader.php +++ b/src/PhpSpreadsheet/Reader/BaseReader.php @@ -14,27 +14,21 @@ abstract class BaseReader implements IReader * Read data only? * Identifies whether the Reader should only read data values for cells, and ignore any formatting information; * or whether it should read both data and formatting. - * - * @var bool */ - protected $readDataOnly = false; + protected bool $readDataOnly = false; /** * Read empty cells? * Identifies whether the Reader should read data values for cells all cells, or should ignore cells containing * null value or empty string. - * - * @var bool */ - protected $readEmptyCells = true; + protected bool $readEmptyCells = true; /** * Read charts that are defined in the workbook? * Identifies whether the Reader should read the definitions for any charts that exist in the workbook;. - * - * @var bool */ - protected $includeCharts = false; + protected bool $includeCharts = false; /** * Restrict which sheets should be loaded? @@ -43,14 +37,12 @@ abstract class BaseReader implements IReader * * @var null|string[] */ - protected $loadSheetsOnly; + protected ?array $loadSheetsOnly = null; /** * IReadFilter instance. - * - * @var IReadFilter */ - protected $readFilter; + protected IReadFilter $readFilter; /** @var resource */ protected $fileHandle; diff --git a/src/PhpSpreadsheet/Reader/Csv.php b/src/PhpSpreadsheet/Reader/Csv.php index a93bbcf4c7..35a4742002 100644 --- a/src/PhpSpreadsheet/Reader/Csv.php +++ b/src/PhpSpreadsheet/Reader/Csv.php @@ -37,10 +37,8 @@ class Csv extends BaseReader /** * Fallback encoding if guess strikes out. - * - * @var string */ - private $fallbackEncoding = self::DEFAULT_FALLBACK_ENCODING; + private string $fallbackEncoding = self::DEFAULT_FALLBACK_ENCODING; /** * Delimiter. @@ -54,17 +52,13 @@ class Csv extends BaseReader /** * Sheet index to read. - * - * @var int */ - private $sheetIndex = 0; + private int $sheetIndex = 0; /** * Load rows contiguously. - * - * @var bool */ - private $contiguous = false; + private bool $contiguous = false; /** * The character that can escape the enclosure. @@ -80,26 +74,16 @@ class Csv extends BaseReader /** * Attempt autodetect line endings (deprecated after PHP8.1)? - * - * @var bool */ - private $testAutodetect = true; + private bool $testAutodetect = true; - /** - * @var bool - */ - protected $castFormattedNumberToNumeric = false; + protected bool $castFormattedNumberToNumeric = false; - /** - * @var bool - */ - protected $preserveNumericFormatting = false; + protected bool $preserveNumericFormatting = false; - /** @var bool */ - private $preserveNullString = false; + private bool $preserveNullString = false; - /** @var bool */ - private $sheetNameIsFileName = false; + private bool $sheetNameIsFileName = false; private string $getTrue = 'true'; diff --git a/src/PhpSpreadsheet/Reader/Csv/Delimiter.php b/src/PhpSpreadsheet/Reader/Csv/Delimiter.php index 8721be164f..d13156f315 100644 --- a/src/PhpSpreadsheet/Reader/Csv/Delimiter.php +++ b/src/PhpSpreadsheet/Reader/Csv/Delimiter.php @@ -13,14 +13,12 @@ class Delimiter protected string $enclosure; - /** @var array */ - protected $counts = []; + protected array $counts = []; - /** @var int */ - protected $numberLines = 0; + protected int $numberLines = 0; /** @var ?string */ - protected $delimiter; + protected ?string $delimiter = null; /** * @param resource $fileHandle diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index 729745f140..ebf4aae037 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -36,22 +36,17 @@ class Gnumeric extends BaseReader /** * Shared Expressions. - * - * @var array */ - private $expressions = []; + private array $expressions = []; /** * Spreadsheet shared across all functions. - * - * @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; private ReferenceHelper $referenceHelper; - /** @var array */ - public static $mappings = [ + public static array $mappings = [ 'dataType' => [ '10' => DataType::TYPE_NULL, '20' => DataType::TYPE_BOOL, diff --git a/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php b/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php index 4b75165879..f901c4a9bb 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric/Styles.php @@ -18,8 +18,7 @@ class Styles protected bool $readDataOnly; - /** @var array */ - public static $mappings = [ + public static array $mappings = [ 'borderStyle' => [ '0' => Border::BORDER_NONE, '1' => Border::BORDER_THIN, diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 6fcf31d7da..ad249cb1ce 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -30,24 +30,18 @@ class Html extends BaseReader /** * Input encoding. - * - * @var string */ - protected $inputEncoding = 'ANSI'; + protected string $inputEncoding = 'ANSI'; /** * Sheet index to read. - * - * @var int */ - protected $sheetIndex = 0; + protected int $sheetIndex = 0; /** * Formats. - * - * @var array */ - protected $formats = [ + protected array $formats = [ 'h1' => [ 'font' => [ 'bold' => true, @@ -124,8 +118,7 @@ class Html extends BaseReader ], // Italic ]; - /** @var array */ - protected $rowspan = []; + protected array $rowspan = []; /** * Create a new HTML Reader instance. @@ -246,14 +239,11 @@ public function getInputEncoding() // Data Array used for testing only, should write to Spreadsheet object on completion of tests - /** @var array */ - protected $dataArray = []; + protected array $dataArray = []; - /** @var int */ - protected $tableLevel = 0; + protected int $tableLevel = 0; - /** @var array */ - protected $nestedColumn = ['A']; + protected array $nestedColumn = ['A']; protected function setTableStartColumn(string $column): string { diff --git a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php index 0abc1f00de..f3e956c91f 100644 --- a/src/PhpSpreadsheet/Reader/Ods/PageSettings.php +++ b/src/PhpSpreadsheet/Reader/Ods/PageSettings.php @@ -8,43 +8,30 @@ class PageSettings { - /** - * @var string - */ - private $officeNs = ''; + private string $officeNs = ''; - /** - * @var string - */ - private $stylesNs = ''; + private string $stylesNs = ''; - /** - * @var string - */ - private $stylesFo = ''; + private string $stylesFo = ''; - /** - * @var string - */ - private $tableNs = ''; + private string $tableNs = ''; /** * @var string[] */ - private $tableStylesCrossReference = []; + private array $tableStylesCrossReference = []; - /** @var array */ - private $pageLayoutStyles = []; + private array $pageLayoutStyles = []; /** * @var string[] */ - private $masterStylesCrossReference = []; + private array $masterStylesCrossReference = []; /** * @var string[] */ - private $masterPrintStylesCrossReference = []; + private array $masterPrintStylesCrossReference = []; public function __construct(DOMDocument $styleDom) { diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 275d0971b9..466e6068c0 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -16,45 +16,33 @@ class Slk extends BaseReader { /** * Input encoding. - * - * @var string */ - private $inputEncoding = 'ANSI'; + private string $inputEncoding = 'ANSI'; /** * Sheet index to read. - * - * @var int */ - private $sheetIndex = 0; + private int $sheetIndex = 0; /** * Formats. - * - * @var array */ - private $formats = []; + private array $formats = []; /** * Format Count. - * - * @var int */ - private $format = 0; + private int $format = 0; /** * Fonts. - * - * @var array */ - private $fonts = []; + private array $fonts = []; /** * Font Count. - * - * @var int */ - private $fontcount = 0; + private int $fontcount = 0; /** * Create a new SYLK Reader instance. diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 4b4a8e4844..b9cd6de0dd 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -164,56 +164,44 @@ class Xls extends BaseReader * * @var ?string */ - private $summaryInformation; + private ?string $summaryInformation = null; /** * Extended Summary Information stream data. * * @var ?string */ - private $documentSummaryInformation; + private ?string $documentSummaryInformation = null; /** * Workbook stream data. (Includes workbook globals substream as well as sheet substreams). - * - * @var string */ - private $data; + private string $data; /** * Size in bytes of $this->data. - * - * @var int */ - private $dataSize; + private int $dataSize; /** * Current position in stream. - * - * @var int */ - private $pos; + private int $pos; /** * Workbook to be returned by the reader. - * - * @var Spreadsheet */ - private $spreadsheet; + private Spreadsheet $spreadsheet; /** * Worksheet that is currently being built by the reader. - * - * @var Worksheet */ - private $phpSheet; + private Worksheet $phpSheet; /** * BIFF version. - * - * @var int */ - private $version = 0; + private int $version = 0; /** * Codepage set in the Excel file being read. Only important for BIFF5 (Excel 5.0 - Excel 95) @@ -223,200 +211,145 @@ class Xls extends BaseReader /** * Shared formats. - * - * @var array */ - private $formats; + private array $formats; /** * Shared fonts. * * @var Font[] */ - private $objFonts; + private array $objFonts; /** * Color palette. - * - * @var array */ - private $palette; + private array $palette; /** * Worksheets. - * - * @var array */ - private $sheets; + private array $sheets; /** * External books. - * - * @var array */ - private $externalBooks; + private array $externalBooks; /** * REF structures. Only applies to BIFF8. - * - * @var array */ - private $ref; + private array $ref; /** * External names. - * - * @var array */ - private $externalNames; + private array $externalNames; /** * Defined names. - * - * @var array */ - private $definedname; + private array $definedname; /** * Shared strings. Only applies to BIFF8. - * - * @var array */ - private $sst; + private array $sst; /** * Panes are frozen? (in sheet currently being read). See WINDOW2 record. - * - * @var bool */ - private $frozen; + private bool $frozen; /** * Fit printout to number of pages? (in sheet currently being read). See SHEETPR record. - * - * @var bool */ - private $isFitToPages; + private bool $isFitToPages; /** * Objects. One OBJ record contributes with one entry. - * - * @var array */ - private $objs; + private array $objs; /** * Text Objects. One TXO record corresponds with one entry. - * - * @var array */ - private $textObjects; + private array $textObjects; /** * Cell Annotations (BIFF8). - * - * @var array */ - private $cellNotes; + private array $cellNotes; /** * The combined MSODRAWINGGROUP data. - * - * @var string */ - private $drawingGroupData; + private string $drawingGroupData; /** * The combined MSODRAWING data (per sheet). - * - * @var string */ - private $drawingData; + private string $drawingData; /** * Keep track of XF index. - * - * @var int */ - private $xfIndex; + private int $xfIndex; /** * Mapping of XF index (that is a cell XF) to final index in cellXf collection. - * - * @var array */ - private $mapCellXfIndex; + private array $mapCellXfIndex; /** * Mapping of XF index (that is a style XF) to final index in cellStyleXf collection. - * - * @var array */ - private $mapCellStyleXfIndex; + private array $mapCellStyleXfIndex; /** * The shared formulas in a sheet. One SHAREDFMLA record contributes with one value. - * - * @var array */ - private $sharedFormulas; + private array $sharedFormulas; /** * The shared formula parts in a sheet. One FORMULA record contributes with one value if it * refers to a shared formula. - * - * @var array */ - private $sharedFormulaParts; + private array $sharedFormulaParts; /** * The type of encryption in use. - * - * @var int */ - private $encryption = 0; + private int $encryption = 0; /** * The position in the stream after which contents are encrypted. - * - * @var int */ - private $encryptionStartPos = 0; + private int $encryptionStartPos = 0; /** * The current RC4 decryption object. * * @var ?Xls\RC4 */ - private $rc4Key; + private ?Xls\RC4 $rc4Key = null; /** * The position in the stream that the RC4 decryption object was left at. - * - * @var int */ - private $rc4Pos = 0; + private int $rc4Pos = 0; /** * The current MD5 context state. * It is never set in the program, so code which uses it is suspect. - * - * @var string */ - private $md5Ctxt; // @phpstan-ignore-line + private string $md5Ctxt; // @phpstan-ignore-line - /** - * @var int - */ - private $textObjRef; + private int $textObjRef; - /** - * @var string - */ - private $baseCell; + private string $baseCell; - /** @var bool */ - private $activeSheetSet = false; + private bool $activeSheetSet = false; /** * Create a new Xls Reader instance. diff --git a/src/PhpSpreadsheet/Reader/Xls/ConditionalFormatting.php b/src/PhpSpreadsheet/Reader/Xls/ConditionalFormatting.php index 8400efb940..fbd31d565e 100644 --- a/src/PhpSpreadsheet/Reader/Xls/ConditionalFormatting.php +++ b/src/PhpSpreadsheet/Reader/Xls/ConditionalFormatting.php @@ -9,7 +9,7 @@ class ConditionalFormatting /** * @var array */ - private static $types = [ + private static array $types = [ 0x01 => Conditional::CONDITION_CELLIS, 0x02 => Conditional::CONDITION_EXPRESSION, ]; @@ -17,7 +17,7 @@ class ConditionalFormatting /** * @var array */ - private static $operators = [ + private static array $operators = [ 0x00 => Conditional::OPERATOR_NONE, 0x01 => Conditional::OPERATOR_BETWEEN, 0x02 => Conditional::OPERATOR_NOTBETWEEN, diff --git a/src/PhpSpreadsheet/Reader/Xls/DataValidationHelper.php b/src/PhpSpreadsheet/Reader/Xls/DataValidationHelper.php index 02f844e314..874e6994fd 100644 --- a/src/PhpSpreadsheet/Reader/Xls/DataValidationHelper.php +++ b/src/PhpSpreadsheet/Reader/Xls/DataValidationHelper.php @@ -9,7 +9,7 @@ class DataValidationHelper /** * @var array */ - private static $types = [ + private static array $types = [ 0x00 => DataValidation::TYPE_NONE, 0x01 => DataValidation::TYPE_WHOLE, 0x02 => DataValidation::TYPE_DECIMAL, @@ -23,7 +23,7 @@ class DataValidationHelper /** * @var array */ - private static $errorStyles = [ + private static array $errorStyles = [ 0x00 => DataValidation::STYLE_STOP, 0x01 => DataValidation::STYLE_WARNING, 0x02 => DataValidation::STYLE_INFORMATION, @@ -32,7 +32,7 @@ class DataValidationHelper /** * @var array */ - private static $operators = [ + private static array $operators = [ 0x00 => DataValidation::OPERATOR_BETWEEN, 0x01 => DataValidation::OPERATOR_NOTBETWEEN, 0x02 => DataValidation::OPERATOR_EQUAL, diff --git a/src/PhpSpreadsheet/Reader/Xls/Escher.php b/src/PhpSpreadsheet/Reader/Xls/Escher.php index 66c6298ce4..feefb4fa43 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Escher.php +++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php @@ -35,24 +35,18 @@ class Escher /** * Escher stream data (binary). - * - * @var string */ - private $data; + private string $data; /** * Size in bytes of the Escher stream data. - * - * @var int */ - private $dataSize; + private int $dataSize; /** * Current position of stream pointer in Escher stream data. - * - * @var int */ - private $pos; + private int $pos; /** * The object to be returned by the reader. Modified during load. diff --git a/src/PhpSpreadsheet/Reader/Xls/MD5.php b/src/PhpSpreadsheet/Reader/Xls/MD5.php index 8f02130fe4..7da2eeee5f 100644 --- a/src/PhpSpreadsheet/Reader/Xls/MD5.php +++ b/src/PhpSpreadsheet/Reader/Xls/MD5.php @@ -4,25 +4,13 @@ class MD5 { - /** - * @var int - */ - private $a; + private int $a; - /** - * @var int - */ - private $b; + private int $b; - /** - * @var int - */ - private $c; + private int $c; - /** - * @var int - */ - private $d; + private int $d; private static int $allOneBits; diff --git a/src/PhpSpreadsheet/Reader/Xls/RC4.php b/src/PhpSpreadsheet/Reader/Xls/RC4.php index b7c7c900c8..b5458f68b9 100644 --- a/src/PhpSpreadsheet/Reader/Xls/RC4.php +++ b/src/PhpSpreadsheet/Reader/Xls/RC4.php @@ -5,13 +5,11 @@ class RC4 { /** @var int[] */ - protected $s = []; // Context + protected array $s = []; // Context - /** @var int */ - protected $i = 0; + protected int $i = 0; - /** @var int */ - protected $j = 0; + protected int $j = 0; /** * RC4 stream decryption/encryption constrcutor. diff --git a/src/PhpSpreadsheet/Reader/Xls/Style/Border.php b/src/PhpSpreadsheet/Reader/Xls/Style/Border.php index d832eb020f..97cebbd44e 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Style/Border.php +++ b/src/PhpSpreadsheet/Reader/Xls/Style/Border.php @@ -9,7 +9,7 @@ class Border /** * @var array */ - protected static $borderStyleMap = [ + protected static array $borderStyleMap = [ 0x00 => StyleBorder::BORDER_NONE, 0x01 => StyleBorder::BORDER_THIN, 0x02 => StyleBorder::BORDER_MEDIUM, diff --git a/src/PhpSpreadsheet/Reader/Xls/Style/CellAlignment.php b/src/PhpSpreadsheet/Reader/Xls/Style/CellAlignment.php index f03d47fae6..6b89d27e0a 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Style/CellAlignment.php +++ b/src/PhpSpreadsheet/Reader/Xls/Style/CellAlignment.php @@ -9,7 +9,7 @@ class CellAlignment /** * @var array */ - protected static $horizontalAlignmentMap = [ + protected static array $horizontalAlignmentMap = [ 0 => Alignment::HORIZONTAL_GENERAL, 1 => Alignment::HORIZONTAL_LEFT, 2 => Alignment::HORIZONTAL_CENTER, @@ -22,7 +22,7 @@ class CellAlignment /** * @var array */ - protected static $verticalAlignmentMap = [ + protected static array $verticalAlignmentMap = [ 0 => Alignment::VERTICAL_TOP, 1 => Alignment::VERTICAL_CENTER, 2 => Alignment::VERTICAL_BOTTOM, diff --git a/src/PhpSpreadsheet/Reader/Xls/Style/CellFont.php b/src/PhpSpreadsheet/Reader/Xls/Style/CellFont.php index e975be4dce..2c6d2f7f9e 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Style/CellFont.php +++ b/src/PhpSpreadsheet/Reader/Xls/Style/CellFont.php @@ -23,7 +23,7 @@ public static function escapement(Font $font, int $escapement): void /** * @var array */ - protected static $underlineMap = [ + protected static array $underlineMap = [ 0x01 => Font::UNDERLINE_SINGLE, 0x02 => Font::UNDERLINE_DOUBLE, 0x21 => Font::UNDERLINE_SINGLEACCOUNTING, diff --git a/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php b/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php index 32ab5c859b..a688386889 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php +++ b/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php @@ -9,7 +9,7 @@ class FillPattern /** * @var array */ - protected static $fillPatternMap = [ + protected static array $fillPatternMap = [ 0x00 => Fill::FILL_NONE, 0x01 => Fill::FILL_SOLID, 0x02 => Fill::FILL_PATTERN_MEDIUMGRAY, diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 99fb3937d5..32b09bc19d 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -52,18 +52,11 @@ class Xlsx extends BaseReader */ private ReferenceHelper $referenceHelper; - /** - * @var ZipArchive - */ - private $zip; + private ZipArchive $zip; - /** @var Styles */ - private $styleReader; + private Styles $styleReader; - /** - * @var array - */ - private $sharedFormulae = []; + private array $sharedFormulae = []; /** * Create a new Xlsx Reader instance. diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php index 280c75eb09..d8a3dfb1f4 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php @@ -20,10 +20,7 @@ class ConditionalStyles private SimpleXMLElement $worksheetXml; - /** - * @var array - */ - private $ns; + private array $ns; private array $dxfs; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php b/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php index e047f236ae..0c5b9a1ba0 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Hyperlinks.php @@ -11,8 +11,7 @@ class Hyperlinks { private Worksheet $worksheet; - /** @var array */ - private $hyperlinks = []; + private array $hyperlinks = []; public function __construct(Worksheet $workSheet) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php index 46ecd3e675..8158937fed 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php @@ -22,22 +22,17 @@ class Styles extends BaseParserClass * * @var ?Theme */ - private $theme; + private ?Theme $theme = null; - /** @var array */ - private $workbookPalette = []; + private array $workbookPalette = []; - /** @var array */ - private $styles = []; + private array $styles = []; - /** @var array */ - private $cellStyles = []; + private array $cellStyles = []; - /** @var SimpleXMLElement */ - private $styleXml; + private SimpleXMLElement $styleXml; - /** @var string */ - private $namespace = ''; + private string $namespace = ''; public function setNamespace(string $namespace): void { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Theme.php b/src/PhpSpreadsheet/Reader/Xlsx/Theme.php index 706c4d1931..bfd322126e 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Theme.php @@ -6,24 +6,20 @@ class Theme { /** * Theme Name. - * - * @var string */ - private $themeName; + private string $themeName; /** * Colour Scheme Name. - * - * @var string */ - private $colourSchemeName; + private string $colourSchemeName; /** * Colour Map. * * @var string[] */ - private $colourMap; + private array $colourMap; /** * Create a new Theme. diff --git a/src/PhpSpreadsheet/Reader/Xml.php b/src/PhpSpreadsheet/Reader/Xml.php index 09baf33214..5199c44e9e 100644 --- a/src/PhpSpreadsheet/Reader/Xml.php +++ b/src/PhpSpreadsheet/Reader/Xml.php @@ -31,10 +31,8 @@ class Xml extends BaseReader /** * Formats. - * - * @var array */ - protected $styles = []; + protected array $styles = []; /** * Create a new Excel2003XML Reader instance. @@ -45,8 +43,7 @@ public function __construct() $this->securityScanner = XmlScanner::getInstance($this); } - /** @var string */ - private $fileContents = ''; + private string $fileContents = ''; public static function xmlMappings(): array { diff --git a/src/PhpSpreadsheet/Reader/Xml/Style.php b/src/PhpSpreadsheet/Reader/Xml/Style.php index 698acf6ac0..2ad2d6dfd1 100644 --- a/src/PhpSpreadsheet/Reader/Xml/Style.php +++ b/src/PhpSpreadsheet/Reader/Xml/Style.php @@ -9,10 +9,8 @@ class Style { /** * Formats. - * - * @var array */ - protected $styles = []; + protected array $styles = []; public function parseStyles(SimpleXMLElement $xml, array $namespaces): array { diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 5ec7967084..827da85309 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -25,12 +25,9 @@ class ReferenceHelper * * @var ?ReferenceHelper */ - private static $instance; + private static ?ReferenceHelper $instance = null; - /** - * @var CellReferenceHelper - */ - private $cellReferenceHelper; + private ?CellReferenceHelper $cellReferenceHelper = null; /** * Get an instance of this class. diff --git a/src/PhpSpreadsheet/RichText/Run.php b/src/PhpSpreadsheet/RichText/Run.php index 4acc155c24..3a18b4a4a4 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -11,7 +11,7 @@ class Run extends TextElement implements ITextElement * * @var ?Font */ - private $font; + private ?Font $font = null; /** * Create a new Run instance. diff --git a/src/PhpSpreadsheet/RichText/TextElement.php b/src/PhpSpreadsheet/RichText/TextElement.php index 073dd7a8c9..c56fe51e66 100644 --- a/src/PhpSpreadsheet/RichText/TextElement.php +++ b/src/PhpSpreadsheet/RichText/TextElement.php @@ -8,10 +8,8 @@ class TextElement implements ITextElement { /** * Text. - * - * @var string */ - private $text; + private string $text; /** * Create a new TextElement instance. diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 9f2ef0cd89..e8bcf61770 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -18,33 +18,28 @@ class Settings * * @var ?string */ - private static $chartRenderer; + private static ?string $chartRenderer = null; /** * Default options for libxml loader. * * @var ?int */ - private static $libXmlLoaderOptions; + private static ?int $libXmlLoaderOptions = null; /** * The cache implementation to be used for cell collection. * * @var ?CacheInterface */ - private static $cache; + private static ?CacheInterface $cache = null; /** * The HTTP client implementation to be used for network request. - * - * @var null|ClientInterface */ - private static $httpClient; + private static ?ClientInterface $httpClient = null; - /** - * @var null|RequestFactoryInterface - */ - private static $requestFactory; + private static ?RequestFactoryInterface $requestFactory = null; /** * Set the locale code to use for formula translations and any special formatting. diff --git a/src/PhpSpreadsheet/Shared/CodePage.php b/src/PhpSpreadsheet/Shared/CodePage.php index 8718a6135e..307f8d931b 100644 --- a/src/PhpSpreadsheet/Shared/CodePage.php +++ b/src/PhpSpreadsheet/Shared/CodePage.php @@ -8,8 +8,7 @@ class CodePage { public const DEFAULT_CODE_PAGE = 'CP1252'; - /** @var array */ - private static $pageArray = [ + private static array $pageArray = [ 0 => 'CP1252', // CodePage is not always correctly set when the xls file was saved by Apple's Numbers program 367 => 'ASCII', // ASCII 437 => 'CP437', // OEM US diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index faa80cd064..66bbb801eb 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -25,7 +25,7 @@ class Date * * @var string[] */ - public static $monthNames = [ + public static array $monthNames = [ 'Jan' => 'January', 'Feb' => 'February', 'Mar' => 'March', @@ -43,7 +43,7 @@ class Date /** * @var string[] */ - public static $numberSuffixes = [ + public static array $numberSuffixes = [ 'st', 'nd', 'rd', @@ -53,17 +53,13 @@ class Date /** * Base calendar year to use for calculations * Value is either CALENDAR_WINDOWS_1900 (1900) or CALENDAR_MAC_1904 (1904). - * - * @var int */ - protected static $excelCalendar = self::CALENDAR_WINDOWS_1900; + protected static int $excelCalendar = self::CALENDAR_WINDOWS_1900; /** * Default timezone to use for DateTime objects. - * - * @var null|DateTimeZone */ - protected static $defaultTimeZone; + protected static ?DateTimeZone $defaultTimeZone = null; /** * Set the Excel calendar (Windows 1900 or Mac 1904). diff --git a/src/PhpSpreadsheet/Shared/Escher.php b/src/PhpSpreadsheet/Shared/Escher.php index 466e7e8254..49c1baabe9 100644 --- a/src/PhpSpreadsheet/Shared/Escher.php +++ b/src/PhpSpreadsheet/Shared/Escher.php @@ -9,14 +9,14 @@ class Escher * * @var ?Escher\DggContainer */ - private $dggContainer; + private ?Escher\DggContainer $dggContainer = null; /** * Drawing Container. * * @var ?Escher\DgContainer */ - private $dgContainer; + private ?Escher\DgContainer $dgContainer = null; /** * Get Drawing Group Container. diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php index 01cbecc26e..6f2751f7c9 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer.php @@ -11,10 +11,8 @@ class SpgrContainer /** * Shape Container collection. - * - * @var array */ - private $children = []; + private array $children = []; /** * Set parent Shape Group Container. diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index 7f010c5c03..10b62ad073 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -8,87 +8,63 @@ class SpContainer { /** * Parent Shape Group Container. - * - * @var SpgrContainer */ - private $parent; + private SpgrContainer $parent; /** * Is this a group shape? - * - * @var bool */ - private $spgr = false; + private bool $spgr = false; /** * Shape type. - * - * @var int */ - private $spType; + private int $spType; /** * Shape flag. - * - * @var int */ - private $spFlag; + private int $spFlag; /** * Shape index (usually group shape has index 0, and the rest: 1,2,3...). - * - * @var int */ - private $spId; + private int $spId; /** * Array of options. - * - * @var array */ - private $OPT; + private array $OPT = []; /** * Cell coordinates of upper-left corner of shape, e.g. 'A1'. - * - * @var string */ - private $startCoordinates; + private string $startCoordinates = ''; /** * Horizontal offset of upper-left corner of shape measured in 1/1024 of column width. - * - * @var int */ - private $startOffsetX; + private int|float $startOffsetX; /** * Vertical offset of upper-left corner of shape measured in 1/256 of row height. - * - * @var int */ - private $startOffsetY; + private int|float $startOffsetY; /** * Cell coordinates of bottom-right corner of shape, e.g. 'B2'. - * - * @var string */ - private $endCoordinates; + private string $endCoordinates; /** * Horizontal offset of bottom-right corner of shape measured in 1/1024 of column width. - * - * @var int */ - private $endOffsetX; + private int|float $endOffsetX; /** * Vertical offset of bottom-right corner of shape measured in 1/256 of row height. - * - * @var int */ - private $endOffsetY; + private int|float $endOffsetY; /** * Set parent Shape Group Container. @@ -248,40 +224,32 @@ public function getStartCoordinates() /** * Set offset in x-direction of upper-left corner of shape measured in 1/1024 of column width. - * - * @param int $startOffsetX */ - public function setStartOffsetX($startOffsetX): void + public function setStartOffsetX(int|float $startOffsetX): void { $this->startOffsetX = $startOffsetX; } /** * Get offset in x-direction of upper-left corner of shape measured in 1/1024 of column width. - * - * @return int */ - public function getStartOffsetX() + public function getStartOffsetX(): int|float { return $this->startOffsetX; } /** * Set offset in y-direction of upper-left corner of shape measured in 1/256 of row height. - * - * @param int $startOffsetY */ - public function setStartOffsetY($startOffsetY): void + public function setStartOffsetY(int|float $startOffsetY): void { $this->startOffsetY = $startOffsetY; } /** * Get offset in y-direction of upper-left corner of shape measured in 1/256 of row height. - * - * @return int */ - public function getStartOffsetY() + public function getStartOffsetY(): int|float { return $this->startOffsetY; } @@ -308,40 +276,32 @@ public function getEndCoordinates() /** * Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width. - * - * @param int $endOffsetX */ - public function setEndOffsetX($endOffsetX): void + public function setEndOffsetX(int|float $endOffsetX): void { $this->endOffsetX = $endOffsetX; } /** * Get offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width. - * - * @return int */ - public function getEndOffsetX() + public function getEndOffsetX(): int|float { return $this->endOffsetX; } /** * Set offset in y-direction of bottom-right corner of shape measured in 1/256 of row height. - * - * @param int $endOffsetY */ - public function setEndOffsetY($endOffsetY): void + public function setEndOffsetY(int|float $endOffsetY): void { $this->endOffsetY = $endOffsetY; } /** * Get offset in y-direction of bottom-right corner of shape measured in 1/256 of row height. - * - * @return int */ - public function getEndOffsetY() + public function getEndOffsetY(): int|float { return $this->endOffsetY; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php index 3a4011095f..36d9e30c0d 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php @@ -6,45 +6,35 @@ class DggContainer { /** * Maximum shape index of all shapes in all drawings increased by one. - * - * @var int */ - private $spIdMax; + private int $spIdMax; /** * Total number of drawings saved. - * - * @var int */ - private $cDgSaved; + private int $cDgSaved; /** * Total number of shapes saved (including group shapes). - * - * @var int */ - private $cSpSaved; + private int $cSpSaved; /** * BLIP Store Container. * * @var ?DggContainer\BstoreContainer */ - private $bstoreContainer; + private ?DggContainer\BstoreContainer $bstoreContainer = null; /** * Array of options for the drawing group. - * - * @var array */ - private $OPT = []; + private array $OPT = []; /** * Array of identifier clusters containg information about the maximum shape identifiers. - * - * @var array */ - private $IDCLs = []; + private array $IDCLs = []; /** * Get maximum shape index of all shapes in all drawings (plus one). diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php index 7203b66bea..a7ed4bae8b 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php @@ -9,7 +9,7 @@ class BstoreContainer * * @var BstoreContainer\BSE[] */ - private $BSECollection = []; + private array $BSECollection = []; /** * Add a BLIP Store Entry. diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php index 328ac6b6c2..9b175a0e7a 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php @@ -20,24 +20,20 @@ class BSE /** * The parent BLIP Store Entry Container. * Property is never currently read. - * - * @var BstoreContainer */ - private $parent; // @phpstan-ignore-line + private BstoreContainer $parent; // @phpstan-ignore-line /** * The BLIP (Big Large Image or Picture). * * @var ?BSE\Blip */ - private $blip; + private ?BSE\Blip $blip = null; /** * The BLIP type. - * - * @var int */ - private $blipType; + private int $blipType; /** * Set parent BLIP Store Entry Container. diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php index ea036afff2..849c6c2238 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php @@ -13,10 +13,8 @@ class Blip /** * Raw image data. - * - * @var string */ - private $data; + private string $data; /** * Get the raw image data. diff --git a/src/PhpSpreadsheet/Shared/File.php b/src/PhpSpreadsheet/Shared/File.php index 737a6eb591..ecd9cb575a 100644 --- a/src/PhpSpreadsheet/Shared/File.php +++ b/src/PhpSpreadsheet/Shared/File.php @@ -10,10 +10,8 @@ class File { /** * Use Temp or File Upload Temp for temporary files. - * - * @var bool */ - protected static $useUploadTempDirectory = false; + protected static bool $useUploadTempDirectory = false; /** * Set the flag indicating whether the File Upload Temp directory should be used for temporary files. diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index fb335a7f5b..dde5193d52 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -202,10 +202,8 @@ class Font /** * Array that can be used to supplement FONT_FILE_NAMES for calculating exact width. - * - * @var array */ - private static $extraFontArray = []; + private static array $extraFontArray = []; public static function setExtraFontArray(array $extraFontArray): void { @@ -219,17 +217,13 @@ public static function getExtraFontArray(): array /** * AutoSize method. - * - * @var string */ - private static $autoSizeMethod = self::AUTOSIZE_METHOD_APPROX; + private static string $autoSizeMethod = self::AUTOSIZE_METHOD_APPROX; /** * Path to folder containing TrueType font .ttf files. - * - * @var string */ - private static $trueTypeFontPath = ''; + private static string $trueTypeFontPath = ''; /** * How wide is a default column for a given default font and size? @@ -284,10 +278,8 @@ public static function getExtraFontArray(): array * user to make inappropriate alterations. * * @deprecated 1.25.0 Use DEFAULT_COLUMN_WIDTHS constant instead. - * - * @var array */ - public static $defaultColumnWidths = self::DEFAULT_COLUMN_WIDTHS; + public static array $defaultColumnWidths = self::DEFAULT_COLUMN_WIDTHS; /** * Set autoSize method. diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index 8db78c4065..4c29018cea 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -58,52 +58,46 @@ class OLE /** * Array of PPS's found on the OLE container. - * - * @var array */ - public $_list = []; + public array $_list = []; /** * Root directory of OLE container. - * - * @var Root */ - public $root; + public Root $root; /** * Big Block Allocation Table. * * @var array (blockId => nextBlockId) */ - public $bbat; + public array $bbat; /** * Short Block Allocation Table. * * @var array (blockId => nextBlockId) */ - public $sbat; + public array $sbat; /** * Size of big blocks. This is usually 512. * * @var int number of octets per block */ - public $bigBlockSize; + public int $bigBlockSize; /** * Size of small blocks. This is usually 64. * * @var int number of octets per block */ - public $smallBlockSize; + public int $smallBlockSize; /** * Threshold for big blocks. - * - * @var int */ - public $bigBlockThreshold; + public int $bigBlockThreshold; /** * Reads an OLE container from the contents of the file given. @@ -345,7 +339,7 @@ public function readPpsWks($blockId): bool $this->_list[] = $pps; // check if the PPS tree (starting from root) is complete - if (isset($this->root) && $this->ppsTreeComplete($this->root->No)) { //* @phpstan-ignore-line + if (isset($this->root) && $this->ppsTreeComplete($this->root->No)) { break; } } diff --git a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php index f95c9025fd..4d13e68f18 100644 --- a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php +++ b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php @@ -11,31 +11,25 @@ class ChainedBlockStream /** * The OLE container of the file that is being read. - * - * @var null|OLE */ - public $ole; + public ?OLE $ole = null; /** * Parameters specified by fopen(). - * - * @var array */ - public $params; + public array $params = []; /** * The binary data of the file. - * - * @var string */ - public $data; + public string $data; /** * The file pointer. * * @var int byte offset */ - public $pos; + public int $pos = 0; /** * Implements support for fopen(). diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index 76f6bf86e8..c033ebd79a 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -31,45 +31,33 @@ class PPS { /** * The PPS index. - * - * @var int */ - public $No; + public int $No; /** * The PPS name (in Unicode). - * - * @var string */ - public $Name; + public string $Name; /** * The PPS type. Dir, Root or File. - * - * @var int */ - public $Type; + public int $Type; /** * The index of the previous PPS. - * - * @var int */ - public $PrevPps; + public int $PrevPps; /** * The index of the next PPS. - * - * @var int */ - public $NextPps; + public int $NextPps; /** * The index of it's first child if this is a Dir or Root PPS. - * - * @var int */ - public $DirPps; + public int $DirPps; /** * A timestamp. @@ -90,35 +78,27 @@ class PPS * * @var ?int */ - public $startBlock; + public ?int $startBlock = null; /** * The size of the PPS's data (in bytes). - * - * @var int */ - public $Size; + public int $Size; /** * The PPS's data (only used if it's not using a temporary file). - * - * @var string */ - public $_data = ''; + public string $_data = ''; /** * Array of child PPS's (only used by Root and Dir PPS's). - * - * @var array */ - public $children = []; + public array $children = []; /** * Pointer to OLE container. - * - * @var OLE */ - public $ole; + public OLE $ole; /** * The constructor. diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index 5cd43c1dcb..d25c535dbf 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -38,12 +38,12 @@ class Root extends PPS /** * @var ?int */ - private $smallBlockSize; + private ?int $smallBlockSize = null; /** * @var ?int */ - private $bigBlockSize; + private ?int $bigBlockSize = null; /** * @param null|float|int $time_1st A timestamp diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index f2718fc85a..ac22a18485 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -6,8 +6,7 @@ class OLERead { - /** @var string */ - private $data = ''; + private string $data = ''; // Size of a sector = 512 bytes const BIG_BLOCK_SIZE = 0x200; @@ -35,64 +34,31 @@ class OLERead const START_BLOCK_POS = 0x74; const SIZE_POS = 0x78; - /** @var int */ - public $wrkbook; + public ?int $wrkbook = null; - /** @var int */ - public $summaryInformation; + public ?int $summaryInformation = null; - /** @var int */ - public $documentSummaryInformation; + public ?int $documentSummaryInformation = null; - /** - * @var int - */ - private $numBigBlockDepotBlocks; + private int $numBigBlockDepotBlocks; - /** - * @var int - */ - private $rootStartBlock; + private int $rootStartBlock; - /** - * @var int - */ - private $sbdStartBlock; + private int $sbdStartBlock; - /** - * @var int - */ - private $extensionBlock; + private int $extensionBlock; - /** - * @var int - */ - private $numExtensionBlocks; + private int $numExtensionBlocks; - /** - * @var string - */ - private $bigBlockChain; + private string $bigBlockChain; - /** - * @var string - */ - private $smallBlockChain; + private string $smallBlockChain; - /** - * @var string - */ - private $entry; + private string $entry; - /** - * @var int - */ - private $rootentry; + private int $rootentry; - /** - * @var array - */ - private $props = []; + private array $props = []; /** * Read the file. diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index 9a8fa86551..3e9de1eea3 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -9,49 +9,43 @@ class StringHelper * * @var string[] */ - private static $controlCharacters = []; + private static array $controlCharacters = []; /** * SYLK Characters array. - * - * @var array */ - private static $SYLKCharacters = []; + private static array $SYLKCharacters = []; /** * Decimal separator. * * @var ?string */ - private static $decimalSeparator; + private static ?string $decimalSeparator; /** * Thousands separator. * * @var ?string */ - private static $thousandsSeparator; + private static ?string $thousandsSeparator; /** * Currency code. - * - * @var string */ - private static $currencyCode; + private static string $currencyCode; /** * Is iconv extension avalable? * * @var ?bool */ - private static $isIconvEnabled; + private static ?bool $isIconvEnabled; /** * iconv options. - * - * @var string */ - private static $iconvOptions = '//IGNORE//TRANSLIT'; + private static string $iconvOptions = '//IGNORE//TRANSLIT'; /** * Build control characters array. diff --git a/src/PhpSpreadsheet/Shared/TimeZone.php b/src/PhpSpreadsheet/Shared/TimeZone.php index 324e3424dd..f6e8500b86 100644 --- a/src/PhpSpreadsheet/Shared/TimeZone.php +++ b/src/PhpSpreadsheet/Shared/TimeZone.php @@ -9,10 +9,8 @@ class TimeZone { /** * Default Timezone used for date/time conversions. - * - * @var string */ - protected static $timezone = 'UTC'; + protected static string $timezone = 'UTC'; /** * Validate a Timezone name. diff --git a/src/PhpSpreadsheet/Shared/Trend/BestFit.php b/src/PhpSpreadsheet/Shared/Trend/BestFit.php index b2eb033ef5..731a677933 100644 --- a/src/PhpSpreadsheet/Shared/Trend/BestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/BestFit.php @@ -6,17 +6,13 @@ abstract class BestFit { /** * Indicator flag for a calculation error. - * - * @var bool */ - protected $error = false; + protected bool $error = false; /** * Algorithm type to use for best-fit. - * - * @var string */ - protected $bestFitType = 'undetermined'; + protected string $bestFitType = 'undetermined'; /** * Number of entries in the sets of x- and y-value arrays. @@ -28,70 +24,54 @@ abstract class BestFit * * @var float[] */ - protected $xValues = []; + protected array $xValues = []; /** * Y-value dataseries of values. * * @var float[] */ - protected $yValues = []; + protected array $yValues = []; /** * Flag indicating whether values should be adjusted to Y=0. - * - * @var bool */ - protected $adjustToZero = false; + protected bool $adjustToZero = false; /** * Y-value series of best-fit values. * * @var float[] */ - protected $yBestFitValues = []; + protected array $yBestFitValues = []; - /** @var float */ - protected $goodnessOfFit = 1; + protected float $goodnessOfFit = 1; - /** @var float */ - protected $stdevOfResiduals = 0; + protected float $stdevOfResiduals = 0; - /** @var float */ - protected $covariance = 0; + protected float $covariance = 0; - /** @var float */ - protected $correlation = 0; + protected float $correlation = 0; - /** @var float */ - protected $SSRegression = 0; + protected float $SSRegression = 0; - /** @var float */ - protected $SSResiduals = 0; + protected float $SSResiduals = 0; - /** @var float */ - protected $DFResiduals = 0; + protected float $DFResiduals = 0; - /** @var float */ - protected $f = 0; + protected float $f = 0; - /** @var float */ - protected $slope = 0; + protected float $slope = 0; - /** @var float */ - protected $slopeSE = 0; + protected float $slopeSE = 0; - /** @var float */ - protected $intersect = 0; + protected float $intersect = 0; - /** @var float */ - protected $intersectSE = 0; + protected float $intersectSE = 0; - /** @var float */ - protected $xOffset = 0; + protected float $xOffset = 0; - /** @var float */ - protected $yOffset = 0; + protected float $yOffset = 0; /** @return bool */ public function getError() diff --git a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php index 67b96f56b7..62a7f95d7e 100644 --- a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php @@ -7,10 +7,8 @@ class ExponentialBestFit extends BestFit /** * Algorithm type to use for best-fit * (Name of this Trend class). - * - * @var string */ - protected $bestFitType = 'exponential'; + protected string $bestFitType = 'exponential'; /** * Return the Y-Value for a specified value of X. diff --git a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php index ef03b84050..54ba089fff 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -7,10 +7,8 @@ class LinearBestFit extends BestFit /** * Algorithm type to use for best-fit * (Name of this Trend class). - * - * @var string */ - protected $bestFitType = 'linear'; + protected string $bestFitType = 'linear'; /** * Return the Y-Value for a specified value of X. diff --git a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php index e6981d5468..27238e7d6c 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php @@ -7,10 +7,8 @@ class LogarithmicBestFit extends BestFit /** * Algorithm type to use for best-fit * (Name of this Trend class). - * - * @var string */ - protected $bestFitType = 'logarithmic'; + protected string $bestFitType = 'logarithmic'; /** * Return the Y-Value for a specified value of X. diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index 4089afccc7..205dbcf2a3 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -13,17 +13,13 @@ class PolynomialBestFit extends BestFit /** * Algorithm type to use for best-fit * (Name of this Trend class). - * - * @var string */ - protected $bestFitType = 'polynomial'; + protected string $bestFitType = 'polynomial'; /** * Polynomial order. - * - * @var int */ - protected $order = 0; + protected int $order = 0; /** * Return the order of this polynomial. diff --git a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php index bb3bf4f384..288e4bb6be 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php @@ -7,10 +7,8 @@ class PowerBestFit extends BestFit /** * Algorithm type to use for best-fit * (Name of this Trend class). - * - * @var string */ - protected $bestFitType = 'power'; + protected string $bestFitType = 'power'; /** * Return the Y-Value for a specified value of X. diff --git a/src/PhpSpreadsheet/Shared/Trend/Trend.php b/src/PhpSpreadsheet/Shared/Trend/Trend.php index 62399ca3ad..abb80a57ea 100644 --- a/src/PhpSpreadsheet/Shared/Trend/Trend.php +++ b/src/PhpSpreadsheet/Shared/Trend/Trend.php @@ -21,7 +21,7 @@ class Trend * * @var string[] */ - private static $trendTypes = [ + private static array $trendTypes = [ self::TREND_LINEAR, self::TREND_LOGARITHMIC, self::TREND_EXPONENTIAL, @@ -33,7 +33,7 @@ class Trend * * @var string[] */ - private static $trendTypePolynomialOrders = [ + private static array $trendTypePolynomialOrders = [ self::TREND_POLYNOMIAL_2, self::TREND_POLYNOMIAL_3, self::TREND_POLYNOMIAL_4, @@ -46,7 +46,7 @@ class Trend * * @var BestFit[] */ - private static $trendCache = []; + private static array $trendCache = []; /** * @param array $yValues diff --git a/src/PhpSpreadsheet/Shared/XMLWriter.php b/src/PhpSpreadsheet/Shared/XMLWriter.php index 28a567fc19..44ca8f477e 100644 --- a/src/PhpSpreadsheet/Shared/XMLWriter.php +++ b/src/PhpSpreadsheet/Shared/XMLWriter.php @@ -6,8 +6,7 @@ class XMLWriter extends \XMLWriter { - /** @var bool */ - public static $debugEnabled = false; + public static bool $debugEnabled = false; /** Temporary storage method */ const STORAGE_MEMORY = 1; diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php index 8c16e3cd46..c5b43fe173 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -99,13 +99,13 @@ public static function sizeRow(Worksheet $worksheet, $row = 1): int * The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets. * * @param string $startColumn - * @param int $startOffsetX Offset within start cell measured in 1/1024 of the cell width + * @param float|int $startOffsetX Offset within start cell measured in 1/1024 of the cell width * @param string $endColumn - * @param int $endOffsetX Offset within end cell measured in 1/1024 of the cell width + * @param float|int $endOffsetX Offset within end cell measured in 1/1024 of the cell width * * @return int Horizontal measured in pixels */ - public static function getDistanceX(Worksheet $worksheet, $startColumn = 'A', $startOffsetX = 0, $endColumn = 'A', $endOffsetX = 0): int + public static function getDistanceX(Worksheet $worksheet, $startColumn = 'A', float|int $startOffsetX = 0, $endColumn = 'A', float|int $endOffsetX = 0): int { $distanceX = 0; @@ -130,13 +130,13 @@ public static function getDistanceX(Worksheet $worksheet, $startColumn = 'A', $s * The distanceY is found as sum of all the spanning rows minus two offsets. * * @param int $startRow (1-based) - * @param int $startOffsetY Offset within start cell measured in 1/256 of the cell height + * @param float|int $startOffsetY Offset within start cell measured in 1/256 of the cell height * @param int $endRow (1-based) - * @param int $endOffsetY Offset within end cell measured in 1/256 of the cell height + * @param float|int $endOffsetY Offset within end cell measured in 1/256 of the cell height * * @return int Vertical distance measured in pixels */ - public static function getDistanceY(Worksheet $worksheet, $startRow = 1, $startOffsetY = 0, $endRow = 1, $endOffsetY = 0): int + public static function getDistanceY(Worksheet $worksheet, $startRow = 1, float|int $startOffsetY = 0, $endRow = 1, float|int $endOffsetY = 0): int { $distanceY = 0; diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index fa8cbcca7a..2618321d16 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -51,14 +51,12 @@ class Spreadsheet implements JsonSerializable * * @var Worksheet[] */ - private $workSheetCollection = []; + private array $workSheetCollection = []; /** * Calculation Engine. - * - * @var null|Calculation */ - private $calculationEngine; + private ?Calculation $calculationEngine = null; /** * Active sheet index. @@ -70,7 +68,7 @@ class Spreadsheet implements JsonSerializable * * @var DefinedName[] */ - private $definedNames = []; + private array $definedNames = []; /** * CellXf supervisor. @@ -82,119 +80,93 @@ class Spreadsheet implements JsonSerializable * * @var Style[] */ - private $cellXfCollection = []; + private array $cellXfCollection = []; /** * CellStyleXf collection. * * @var Style[] */ - private $cellStyleXfCollection = []; + private array $cellStyleXfCollection = []; /** * hasMacros : this workbook have macros ? - * - * @var bool */ - private $hasMacros = false; + private bool $hasMacros = false; /** * macrosCode : all macros code as binary data (the vbaProject.bin file, this include form, code, etc.), null if no macro. - * - * @var null|string */ - private $macrosCode; + private ?string $macrosCode = null; /** * macrosCertificate : if macros are signed, contains binary data vbaProjectSignature.bin file, null if not signed. - * - * @var null|string */ - private $macrosCertificate; + private ?string $macrosCertificate = null; /** * ribbonXMLData : null if workbook is'nt Excel 2007 or not contain a customized UI. * * @var null|array{target: string, data: string} */ - private $ribbonXMLData; + private ?array $ribbonXMLData = null; /** * ribbonBinObjects : null if workbook is'nt Excel 2007 or not contain embedded objects (picture(s)) for Ribbon Elements * ignored if $ribbonXMLData is null. - * - * @var null|array */ - private $ribbonBinObjects; + private ?array $ribbonBinObjects = null; /** * List of unparsed loaded data for export to same format with better compatibility. * It has to be minimized when the library start to support currently unparsed data. - * - * @var array */ - private $unparsedLoadedData = []; + private array $unparsedLoadedData = []; /** * Controls visibility of the horizonal scroll bar in the application. - * - * @var bool */ - private $showHorizontalScroll = true; + private bool $showHorizontalScroll = true; /** * Controls visibility of the horizonal scroll bar in the application. - * - * @var bool */ - private $showVerticalScroll = true; + private bool $showVerticalScroll = true; /** * Controls visibility of the sheet tabs in the application. - * - * @var bool */ - private $showSheetTabs = true; + private bool $showSheetTabs = true; /** * Specifies a boolean value that indicates whether the workbook window * is minimized. - * - * @var bool */ - private $minimized = false; + private bool $minimized = false; /** * Specifies a boolean value that indicates whether to group dates * when presenting the user with filtering optiomd in the user * interface. - * - * @var bool */ - private $autoFilterDateGrouping = true; + private bool $autoFilterDateGrouping = true; /** * Specifies the index to the first sheet in the book view. - * - * @var int */ - private $firstSheetIndex = 0; + private int $firstSheetIndex = 0; /** * Specifies the visible status of the workbook. - * - * @var string */ - private $visibility = self::VISIBILITY_VISIBLE; + private string $visibility = self::VISIBILITY_VISIBLE; /** * Specifies the ratio between the workbook tabs bar and the horizontal * scroll bar. TabRatio is assumed to be out of 1000 of the horizontal * window width. - * - * @var int */ - private $tabRatio = 600; + private int $tabRatio = 600; private Theme $theme; diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 6f87fd6b5d..21bc447983 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -94,52 +94,38 @@ class Alignment extends Supervisor /** * Horizontal alignment. - * - * @var null|string */ - protected $horizontal = self::HORIZONTAL_GENERAL; + protected ?string $horizontal = self::HORIZONTAL_GENERAL; /** * Vertical alignment. - * - * @var null|string */ - protected $vertical = self::VERTICAL_BOTTOM; + protected ?string $vertical = self::VERTICAL_BOTTOM; /** * Text rotation. - * - * @var null|int */ - protected $textRotation = 0; + protected ?int $textRotation = 0; /** * Wrap text. - * - * @var bool */ - protected $wrapText = false; + protected bool $wrapText = false; /** * Shrink to fit. - * - * @var bool */ - protected $shrinkToFit = false; + protected bool $shrinkToFit = false; /** * Indent - only possible with horizontal alignment left and right. - * - * @var int */ - protected $indent = 0; + protected int $indent = 0; /** * Read order. - * - * @var int */ - protected $readOrder = 0; + protected int $readOrder = 0; /** * Create a new Alignment. diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 691962d569..db14285ec8 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -25,20 +25,15 @@ class Border extends Supervisor /** * Border style. - * - * @var string */ - protected $borderStyle = self::BORDER_NONE; + protected string $borderStyle = self::BORDER_NONE; /** * Border color. */ protected Color $color; - /** - * @var null|int - */ - public $colorIndex; + public ?int $colorIndex = null; /** * Create a new Border. diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index 9189db8bd5..7f5fef02a3 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -44,38 +44,28 @@ class Borders extends Supervisor /** * All borders pseudo-border. Only applies to supervisor. - * - * @var Border */ - protected $allBorders; + protected Border $allBorders; /** * Outline pseudo-border. Only applies to supervisor. - * - * @var Border */ - protected $outline; + protected Border $outline; /** * Inside pseudo-border. Only applies to supervisor. - * - * @var Border */ - protected $inside; + protected Border $inside; /** * Vertical pseudo-border. Only applies to supervisor. - * - * @var Border */ - protected $vertical; + protected Border $vertical; /** * Horizontal pseudo-border. Only applies to supervisor. - * - * @var Border */ - protected $horizontal; + protected Border $horizontal; /** * Create a new Borders. diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index fdc0a971f8..7b5acc8879 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -106,13 +106,10 @@ class Color extends Supervisor /** * ARGB - Alpha RGB. - * - * @var null|string */ - protected $argb; + protected ?string $argb = null; - /** @var bool */ - private $hasChanged = false; + private bool $hasChanged = false; /** * Create a new Color. diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index 9f6e8c7dce..e3804e5dab 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -73,24 +73,18 @@ class Conditional implements IComparable /** * Condition type. - * - * @var string */ - private $conditionType = self::CONDITION_NONE; + private string $conditionType = self::CONDITION_NONE; /** * Operator type. - * - * @var string */ - private $operatorType = self::OPERATOR_NONE; + private string $operatorType = self::OPERATOR_NONE; /** * Text. - * - * @var string */ - private $text; + private string $text; /** * Stop on this condition, if it matches. @@ -102,7 +96,7 @@ class Conditional implements IComparable * * @var (bool|float|int|string)[] */ - private $condition = []; + private array $condition = []; private ?ConditionalDataBar $dataBar = null; diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php index 3c815e4ac7..d5cee1d24a 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php @@ -32,37 +32,19 @@ class CellMatcher protected Cell $cell; - /** - * @var int - */ - protected $cellRow; + protected int $cellRow; protected Worksheet $worksheet; - /** - * @var int - */ - protected $cellColumn; + protected int $cellColumn; - /** - * @var string - */ - protected $conditionalRange; + protected string $conditionalRange; - /** - * @var string - */ - protected $referenceCell; + protected string $referenceCell; - /** - * @var int - */ - protected $referenceRow; + protected int $referenceRow; - /** - * @var int - */ - protected $referenceColumn; + protected int $referenceColumn; protected Calculation $engine; diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php index 0260d731c2..dc71222f75 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php @@ -5,47 +5,33 @@ class ConditionalDataBarExtension { /** attributes */ + private int $minLength; - /** @var int */ - private $minLength; + private int $maxLength; - /** @var int */ - private $maxLength; + private ?bool $border = null; - /** @var null|bool */ - private $border; + private ?bool $gradient = null; - /** @var null|bool */ - private $gradient; + private ?string $direction = null; - /** @var string */ - private $direction; + private ?bool $negativeBarBorderColorSameAsPositive = null; - /** @var null|bool */ - private $negativeBarBorderColorSameAsPositive; - - /** @var string */ - private $axisPosition; + private ?string $axisPosition = null; // children - /** @var ConditionalFormatValueObject */ - private $maximumConditionalFormatValueObject; + private ConditionalFormatValueObject $maximumConditionalFormatValueObject; - /** @var ConditionalFormatValueObject */ - private $minimumConditionalFormatValueObject; + private ConditionalFormatValueObject $minimumConditionalFormatValueObject; - /** @var string */ - private $borderColor; + private ?string $borderColor = null; - /** @var string */ - private $negativeFillColor; + private ?string $negativeFillColor = null; - /** @var string */ - private $negativeBorderColor; + private ?string $negativeBorderColor = null; - /** @var array */ - private $axisColor = [ + private array $axisColor = [ 'rgb' => null, 'theme' => null, 'tint' => null, @@ -147,10 +133,7 @@ public function setGradient(bool $gradient): self return $this; } - /** - * @return string - */ - public function getDirection() + public function getDirection(): ?string { return $this->direction; } @@ -177,10 +160,7 @@ public function setNegativeBarBorderColorSameAsPositive(bool $negativeBarBorderC return $this; } - /** - * @return string - */ - public function getAxisPosition() + public function getAxisPosition(): ?string { return $this->axisPosition; } @@ -222,10 +202,7 @@ public function setMinimumConditionalFormatValueObject(ConditionalFormatValueObj return $this; } - /** - * @return string - */ - public function getBorderColor() + public function getBorderColor(): ?string { return $this->borderColor; } @@ -237,10 +214,7 @@ public function setBorderColor(string $borderColor): self return $this; } - /** - * @return string - */ - public function getNegativeFillColor() + public function getNegativeFillColor(): ?string { return $this->negativeFillColor; } @@ -252,10 +226,7 @@ public function setNegativeFillColor(string $negativeFillColor): self return $this; } - /** - * @return string - */ - public function getNegativeBorderColor() + public function getNegativeBorderColor(): ?string { return $this->negativeBorderColor; } diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php index ccdc081144..c58b0578d8 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php @@ -36,16 +36,14 @@ class CellValue extends WizardAbstract implements WizardInterface protected const RANGE_OPERATORS = CellMatcher::COMPARISON_RANGE_OPERATORS; - /** @var string */ - protected $operator = Conditional::OPERATOR_EQUAL; + protected string $operator = Conditional::OPERATOR_EQUAL; - /** @var array */ - protected $operand = [0]; + protected array $operand = [0]; /** * @var string[] */ - protected $operandValueType = []; + protected array $operandValueType = []; public function __construct(string $cellRange) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php index 453dcdf91b..be26466dcb 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php @@ -46,8 +46,7 @@ class DateValue extends WizardAbstract implements WizardInterface Conditional::TIMEPERIOD_NEXT_MONTH => 'AND(MONTH(%s)=MONTH(EDATE(TODAY(),0+1)),YEAR(%s)=YEAR(EDATE(TODAY(),0+1)))', ]; - /** @var string */ - protected $operator; + protected string $operator; public function __construct(string $cellRange) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php index 01ef47af45..38ab967d30 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php @@ -11,10 +11,7 @@ */ class Expression extends WizardAbstract implements WizardInterface { - /** - * @var string - */ - protected $expression; + protected string $expression; public function __construct(string $cellRange) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php index 0b845dd0c3..1867f86eaa 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php @@ -40,16 +40,11 @@ class TextValue extends WizardAbstract implements WizardInterface Conditional::OPERATOR_ENDSWITH => 'RIGHT(%s,LEN(%s))=%s', ]; - /** @var string */ - protected $operator; + protected string $operator; - /** @var string */ - protected $operand; + protected string $operand; - /** - * @var string - */ - protected $operandValueType; + protected string $operandValueType; public function __construct(string $cellRange) { diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php index 8f8848ca9e..02d0680932 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php @@ -12,34 +12,19 @@ abstract class WizardAbstract /** * @var ?Style */ - protected $style; + protected ?Style $style = null; - /** - * @var string - */ - protected $expression; + protected string $expression; protected string $cellRange; - /** - * @var string - */ - protected $referenceCell; + protected string $referenceCell; - /** - * @var int - */ - protected $referenceRow; + protected int $referenceRow; - /** - * @var bool - */ - protected $stopIfTrue = false; + protected bool $stopIfTrue = false; - /** - * @var int - */ - protected $referenceColumn; + protected int $referenceColumn; public function __construct(string $cellRange) { diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index fe2adc3fad..828e0cbfe2 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -27,29 +27,19 @@ class Fill extends Supervisor const FILL_PATTERN_LIGHTVERTICAL = 'lightVertical'; const FILL_PATTERN_MEDIUMGRAY = 'mediumGray'; - /** - * @var null|int - */ - public $startcolorIndex; + public ?int $startcolorIndex = null; - /** - * @var null|int - */ - public $endcolorIndex; + public ?int $endcolorIndex = null; /** * Fill type. - * - * @var null|string */ - protected $fillType = self::FILL_NONE; + protected ?string $fillType = self::FILL_NONE; /** * Rotation. - * - * @var float */ - protected $rotation = 0.0; + protected float $rotation = 0.0; /** * Start color. @@ -61,8 +51,7 @@ class Fill extends Supervisor */ protected Color $endColor; - /** @var bool */ - private $colorChanged = false; + private bool $colorChanged = false; /** * Create a new Fill. diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index b2e73d1cfb..07a418ae0a 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -15,98 +15,72 @@ class Font extends Supervisor /** * Font Name. - * - * @var null|string */ - protected $name = 'Calibri'; + protected ?string $name = 'Calibri'; /** * The following 7 are used only for chart titles, I think. - * - *@var string */ - private $latin = ''; + private string $latin = ''; - /** @var string */ - private $eastAsian = ''; + private string $eastAsian = ''; - /** @var string */ - private $complexScript = ''; + private string $complexScript = ''; - /** @var int */ - private $baseLine = 0; + private int $baseLine = 0; - /** @var string */ - private $strikeType = ''; + private string $strikeType = ''; /** @var ?ChartColor */ - private $underlineColor; + private ?ChartColor $underlineColor = null; /** @var ?ChartColor */ - private $chartColor; + private ?ChartColor $chartColor = null; // end of chart title items /** * Font Size. - * - * @var null|float */ - protected $size = 11; + protected ?float $size = 11; /** * Bold. - * - * @var null|bool */ - protected $bold = false; + protected ?bool $bold = false; /** * Italic. - * - * @var null|bool */ - protected $italic = false; + protected ?bool $italic = false; /** * Superscript. - * - * @var null|bool */ - protected $superscript = false; + protected ?bool $superscript = false; /** * Subscript. - * - * @var null|bool */ - protected $subscript = false; + protected ?bool $subscript = false; /** * Underline. - * - * @var null|string */ - protected $underline = self::UNDERLINE_NONE; + protected ?string $underline = self::UNDERLINE_NONE; /** * Strikethrough. - * - * @var null|bool */ - protected $strikethrough = false; + protected ?bool $strikethrough = false; /** * Foreground color. */ protected Color $color; - /** - * @var null|int - */ - public $colorIndex; + public ?int $colorIndex = null; - /** @var string */ - protected $scheme = ''; + protected string $scheme = ''; /** * Create a new Font. diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index c494a38dc8..39395797c3 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -92,24 +92,18 @@ class NumberFormat extends Supervisor /** * Excel built-in number formats. - * - * @var array */ - protected static $builtInFormats; + protected static array $builtInFormats; /** * Excel built-in number formats (flipped, for faster lookups). - * - * @var array */ - protected static $flippedBuiltInFormats; + protected static array $flippedBuiltInFormats; /** * Format Code. - * - * @var null|string */ - protected $formatCode = self::FORMAT_GENERAL; + protected ?string $formatCode = self::FORMAT_GENERAL; /** * Built-in format Code. diff --git a/src/PhpSpreadsheet/Style/Style.php b/src/PhpSpreadsheet/Style/Style.php index 45b6fef3dc..553b81f90a 100644 --- a/src/PhpSpreadsheet/Style/Style.php +++ b/src/PhpSpreadsheet/Style/Style.php @@ -42,17 +42,13 @@ class Style extends Supervisor /** * Index of style in collection. Only used for real style. - * - * @var int */ - protected $index; + protected int $index; /** * Use Quote Prefix when displaying in cell editor. Only used for real style. - * - * @var bool */ - protected $quotePrefix = false; + protected bool $quotePrefix = false; /** * Internal cache for styles @@ -71,7 +67,7 @@ class Style extends Supervisor * * @var null|array */ - private static $cachedStyles; + private static ?array $cachedStyles = null; /** * Create a new Style. diff --git a/src/PhpSpreadsheet/Style/Supervisor.php b/src/PhpSpreadsheet/Style/Supervisor.php index 2929a71c5f..346bee7e1d 100644 --- a/src/PhpSpreadsheet/Style/Supervisor.php +++ b/src/PhpSpreadsheet/Style/Supervisor.php @@ -10,10 +10,8 @@ abstract class Supervisor implements IComparable { /** * Supervisor? - * - * @var bool */ - protected $isSupervisor; + protected bool $isSupervisor; /** * Parent. Only used for supervisor. @@ -24,10 +22,8 @@ abstract class Supervisor implements IComparable /** * Parent property name. - * - * @var null|string */ - protected $parentPropertyName; + protected ?string $parentPropertyName = null; /** * Create a new Supervisor. diff --git a/src/PhpSpreadsheet/Theme.php b/src/PhpSpreadsheet/Theme.php index ac4dbe560c..081009708f 100644 --- a/src/PhpSpreadsheet/Theme.php +++ b/src/PhpSpreadsheet/Theme.php @@ -41,7 +41,7 @@ class Theme ]; /** @var string[] */ - private $themeColors = self::COLOR_SCHEME_2007_2010; + private array $themeColors = self::COLOR_SCHEME_2007_2010; private string $majorFontLatin = 'Cambria'; @@ -60,14 +60,14 @@ class Theme * * @var string[] */ - private $majorFontSubstitutions = self::FONTS_TIMES_SUBSTITUTIONS; + private array $majorFontSubstitutions = self::FONTS_TIMES_SUBSTITUTIONS; /** * Map of Minor (body) fonts to write. * * @var string[] */ - private $minorFontSubstitutions = self::FONTS_ARIAL_SUBSTITUTIONS; + private array $minorFontSubstitutions = self::FONTS_ARIAL_SUBSTITUTIONS; public const FONTS_TIMES_SUBSTITUTIONS = [ 'Jpan' => 'MS Pゴシック', diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index 58c19f97de..a0d9167726 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -31,10 +31,9 @@ class AutoFilter implements Stringable * * @var AutoFilter\Column[] */ - private $columns = []; + private array $columns = []; - /** @var bool */ - private $evaluated = false; + private bool $evaluated = false; public function getEvaluated(): bool { diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index 361ccf045b..1fe05ac8d4 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -21,7 +21,7 @@ class Column * * @var string[] */ - private static $filterTypes = [ + private static array $filterTypes = [ // Currently we're not handling // colorFilter // extLst @@ -41,7 +41,7 @@ class Column * * @var string[] */ - private static $ruleJoins = [ + private static array $ruleJoins = [ self::AUTOFILTER_COLUMN_JOIN_AND, self::AUTOFILTER_COLUMN_JOIN_OR, ]; @@ -53,38 +53,32 @@ class Column /** * Autofilter Column Index. - * - * @var string */ - private $columnIndex = ''; + private string $columnIndex = ''; /** * Autofilter Column Filter Type. - * - * @var string */ - private $filterType = self::AUTOFILTER_FILTERTYPE_FILTER; + private string $filterType = self::AUTOFILTER_FILTERTYPE_FILTER; /** * Autofilter Multiple Rules And/Or. - * - * @var string */ - private $join = self::AUTOFILTER_COLUMN_JOIN_OR; + private string $join = self::AUTOFILTER_COLUMN_JOIN_OR; /** * Autofilter Column Rules. * * @var Column\Rule[] */ - private $ruleset = []; + private array $ruleset = []; /** * Autofilter Column Dynamic Attributes. * * @var mixed[] */ - private $attributes = []; + private array $attributes = []; /** * Create a new Column. diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index 276bb28576..b70bccd26f 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -176,10 +176,8 @@ class Rule /** * Autofilter Rule Type. - * - * @var string */ - private $ruleType = self::AUTOFILTER_RULETYPE_FILTER; + private string $ruleType = self::AUTOFILTER_RULETYPE_FILTER; /** * Autofilter Rule Value. @@ -190,17 +188,13 @@ class Rule /** * Autofilter Rule Operator. - * - * @var string */ - private $operator = self::AUTOFILTER_COLUMN_RULE_EQUAL; + private string $operator = self::AUTOFILTER_COLUMN_RULE_EQUAL; /** * DateTimeGrouping Group Value. - * - * @var string */ - private $grouping = ''; + private string $grouping = ''; /** * Create a new Rule. diff --git a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php index 2310e64ea2..530744fe1b 100644 --- a/src/PhpSpreadsheet/Worksheet/BaseDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/BaseDrawing.php @@ -26,10 +26,8 @@ class BaseDrawing implements IComparable /** * Image counter. - * - * @var int */ - private static $imageCounter = 0; + private static int $imageCounter = 0; /** * Image index. @@ -58,17 +56,13 @@ class BaseDrawing implements IComparable /** * Offset X. - * - * @var int */ - protected $offsetX = 0; + protected int $offsetX = 0; /** * Offset Y. - * - * @var int */ - protected $offsetY = 0; + protected int $offsetY = 0; /** * Coordinates2. @@ -77,59 +71,43 @@ class BaseDrawing implements IComparable /** * Offset X2. - * - * @var int */ - protected $offsetX2 = 0; + protected int $offsetX2 = 0; /** * Offset Y2. - * - * @var int */ - protected $offsetY2 = 0; + protected int $offsetY2 = 0; /** * Width. - * - * @var int */ - protected $width = 0; + protected int $width = 0; /** * Height. - * - * @var int */ - protected $height = 0; + protected int $height = 0; /** * Pixel width of image. See $width for the size the Drawing will be in the sheet. - * - * @var int */ - protected $imageWidth = 0; + protected int $imageWidth = 0; /** * Pixel width of image. See $height for the size the Drawing will be in the sheet. - * - * @var int */ - protected $imageHeight = 0; + protected int $imageHeight = 0; /** * Proportional resize. - * - * @var bool */ - protected $resizeProportional = true; + protected bool $resizeProportional = true; /** * Rotation. - * - * @var int */ - protected $rotation = 0; + protected int $rotation = 0; /** * Shadow. @@ -143,10 +121,8 @@ class BaseDrawing implements IComparable /** * Image type. - * - * @var int */ - protected $type = IMAGETYPE_UNKNOWN; + protected int $type = IMAGETYPE_UNKNOWN; /** @var null|SimpleXMLElement|string[] */ protected $srcRect = []; diff --git a/src/PhpSpreadsheet/Worksheet/CellIterator.php b/src/PhpSpreadsheet/Worksheet/CellIterator.php index 96adee7882..2522c336f6 100644 --- a/src/PhpSpreadsheet/Worksheet/CellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/CellIterator.php @@ -23,32 +23,24 @@ abstract class CellIterator implements NativeIterator /** * Worksheet to iterate. - * - * @var Worksheet */ - protected $worksheet; + protected Worksheet $worksheet; /** * Cell Collection to iterate. - * - * @var Cells */ - protected $cellCollection; + protected Cells $cellCollection; /** * Iterate only existing cells. - * - * @var bool */ - protected $onlyExistingCells = false; + protected bool $onlyExistingCells = false; /** * If iterating all cells, and a cell doesn't exist, identifies whether a new cell should be created, * or if the iterator should return a null value. - * - * @var bool */ - protected $ifNotExists = self::IF_NOT_EXISTS_CREATE_NEW; + protected bool $ifNotExists = self::IF_NOT_EXISTS_CREATE_NEW; /** * Destructor. diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index 309cb411a3..2d77835e91 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -23,17 +23,13 @@ class ColumnCellIterator extends CellIterator /** * Start position. - * - * @var int */ - private $startRow = 1; + private int $startRow = 1; /** * End position. - * - * @var int */ - private $endRow = 1; + private int $endRow = 1; /** * Create a new row iterator. diff --git a/src/PhpSpreadsheet/Worksheet/ColumnDimension.php b/src/PhpSpreadsheet/Worksheet/ColumnDimension.php index 07f7413426..5b76d1f44b 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnDimension.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnDimension.php @@ -16,17 +16,13 @@ class ColumnDimension extends Dimension * Column width. * * When this is set to a negative value, the column width should be ignored by IWriter - * - * @var float */ - private $width = -1; + private float $width = -1; /** * Auto size? - * - * @var bool */ - private $autoSize = false; + private bool $autoSize = false; /** * Create a new ColumnDimension. diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index b788caa7cd..5bd7b70234 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -14,31 +14,23 @@ class ColumnIterator implements NativeIterator { /** * Worksheet to iterate. - * - * @var Worksheet */ - private $worksheet; + private Worksheet $worksheet; /** * Current iterator position. - * - * @var int */ - private $currentColumnIndex = 1; + private int $currentColumnIndex = 1; /** * Start position. - * - * @var int */ - private $startColumnIndex = 1; + private int $startColumnIndex = 1; /** * End position. - * - * @var int */ - private $endColumnIndex = 1; + private int $endColumnIndex = 1; /** * Create a new column iterator. diff --git a/src/PhpSpreadsheet/Worksheet/Dimension.php b/src/PhpSpreadsheet/Worksheet/Dimension.php index 8549b16954..76eeb1bfe0 100644 --- a/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -8,24 +8,18 @@ abstract class Dimension { /** * Visible? - * - * @var bool */ - private $visible = true; + private bool $visible = true; /** * Outline level. - * - * @var int */ - private $outlineLevel = 0; + private int $outlineLevel = 0; /** * Collapsed. - * - * @var bool */ - private $collapsed = false; + private bool $collapsed = false; /** * Index to cellXf. Null value means row has no explicit cellXf format. diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index 5772afc608..4421cc5f2f 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -75,80 +75,60 @@ class HeaderFooter /** * OddHeader. - * - * @var string */ - private $oddHeader = ''; + private string $oddHeader = ''; /** * OddFooter. - * - * @var string */ - private $oddFooter = ''; + private string $oddFooter = ''; /** * EvenHeader. - * - * @var string */ - private $evenHeader = ''; + private string $evenHeader = ''; /** * EvenFooter. - * - * @var string */ - private $evenFooter = ''; + private string $evenFooter = ''; /** * FirstHeader. - * - * @var string */ - private $firstHeader = ''; + private string $firstHeader = ''; /** * FirstFooter. - * - * @var string */ - private $firstFooter = ''; + private string $firstFooter = ''; /** * Different header for Odd/Even, defaults to false. - * - * @var bool */ - private $differentOddEven = false; + private bool $differentOddEven = false; /** * Different header for first page, defaults to false. - * - * @var bool */ - private $differentFirst = false; + private bool $differentFirst = false; /** * Scale with document, defaults to true. - * - * @var bool */ - private $scaleWithDocument = true; + private bool $scaleWithDocument = true; /** * Align with margins, defaults to true. - * - * @var bool */ - private $alignWithMargins = true; + private bool $alignWithMargins = true; /** * Header/footer images. * * @var HeaderFooterDrawing[] */ - private $headerFooterImages = []; + private array $headerFooterImages = []; /** * Create a new HeaderFooter. diff --git a/src/PhpSpreadsheet/Worksheet/Iterator.php b/src/PhpSpreadsheet/Worksheet/Iterator.php index a56404642d..9223718484 100644 --- a/src/PhpSpreadsheet/Worksheet/Iterator.php +++ b/src/PhpSpreadsheet/Worksheet/Iterator.php @@ -16,10 +16,8 @@ class Iterator implements \Iterator /** * Current iterator position. - * - * @var int */ - private $position = 0; + private int $position = 0; /** * Create a new worksheet iterator. diff --git a/src/PhpSpreadsheet/Worksheet/PageMargins.php b/src/PhpSpreadsheet/Worksheet/PageMargins.php index 8039cc3303..d19834c616 100644 --- a/src/PhpSpreadsheet/Worksheet/PageMargins.php +++ b/src/PhpSpreadsheet/Worksheet/PageMargins.php @@ -6,45 +6,33 @@ class PageMargins { /** * Left. - * - * @var float */ - private $left = 0.7; + private float $left = 0.7; /** * Right. - * - * @var float */ - private $right = 0.7; + private float $right = 0.7; /** * Top. - * - * @var float */ - private $top = 0.75; + private float $top = 0.75; /** * Bottom. - * - * @var float */ - private $bottom = 0.75; + private float $bottom = 0.75; /** * Header. - * - * @var float */ - private $header = 0.3; + private float $header = 0.3; /** * Footer. - * - * @var float */ - private $footer = 0.3; + private float $footer = 0.3; /** * Create a new PageMargins. diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 92e24c438b..17c8a0edb6 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -161,110 +161,89 @@ class PageSetup /** * Paper size default. - * - * @var int */ - private static $paperSizeDefault = self::PAPERSIZE_LETTER; + private static int $paperSizeDefault = self::PAPERSIZE_LETTER; /** * Paper size. * * @var ?int */ - private $paperSize; + private ?int $paperSize = null; /** * Orientation default. - * - * @var string */ - private static $orientationDefault = self::ORIENTATION_DEFAULT; + private static string $orientationDefault = self::ORIENTATION_DEFAULT; /** * Orientation. - * - * @var string */ - private $orientation; + private string $orientation; /** * Scale (Print Scale). * * Print scaling. Valid values range from 10 to 400 * This setting is overridden when fitToWidth and/or fitToHeight are in use - * - * @var null|int */ - private $scale = 100; + private ?int $scale = 100; /** * Fit To Page * Whether scale or fitToWith / fitToHeight applies. - * - * @var bool */ - private $fitToPage = false; + private bool $fitToPage = false; /** * Fit To Height * Number of vertical pages to fit on. - * - * @var null|int */ - private $fitToHeight = 1; + private ?int $fitToHeight = 1; /** * Fit To Width * Number of horizontal pages to fit on. - * - * @var null|int */ - private $fitToWidth = 1; + private ?int $fitToWidth = 1; /** * Columns to repeat at left. * * @var array Containing start column and end column, empty array if option unset */ - private $columnsToRepeatAtLeft = ['', '']; + private array $columnsToRepeatAtLeft = ['', '']; /** * Rows to repeat at top. * * @var array Containing start row number and end row number, empty array if option unset */ - private $rowsToRepeatAtTop = [0, 0]; + private array $rowsToRepeatAtTop = [0, 0]; /** * Center page horizontally. - * - * @var bool */ - private $horizontalCentered = false; + private bool $horizontalCentered = false; /** * Center page vertically. - * - * @var bool */ - private $verticalCentered = false; + private bool $verticalCentered = false; /** * Print area. - * - * @var null|string */ - private $printArea; + private ?string $printArea = null; /** * First page number. * * @var ?int */ - private $firstPageNumber; + private ?int $firstPageNumber = null; - /** @var string */ - private $pageOrder = self::PAGEORDER_DOWN_THEN_OVER; + private string $pageOrder = self::PAGEORDER_DOWN_THEN_OVER; /** * Create a new PageSetup. diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index a6bb4aabf7..4f347902ce 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -99,10 +99,8 @@ class Protection /** * Hashed password. - * - * @var string */ - private $password = ''; + private string $password = ''; /** * Algorithm name. @@ -116,10 +114,8 @@ class Protection /** * Spin count. - * - * @var int */ - private $spinCount = 10000; + private int $spinCount = 10000; /** * Create a new Protection. diff --git a/src/PhpSpreadsheet/Worksheet/Row.php b/src/PhpSpreadsheet/Worksheet/Row.php index ae05b0ffaf..0f974271ba 100644 --- a/src/PhpSpreadsheet/Worksheet/Row.php +++ b/src/PhpSpreadsheet/Worksheet/Row.php @@ -8,10 +8,8 @@ class Row /** * Row index. - * - * @var int */ - private $rowIndex = 0; + private int $rowIndex = 0; /** * Create a new row. diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 7998ba9c0a..4524e54168 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -18,24 +18,18 @@ class RowCellIterator extends CellIterator /** * Row index. - * - * @var int */ - private $rowIndex = 1; + private int $rowIndex = 1; /** * Start position. - * - * @var int */ - private $startColumnIndex = 1; + private int $startColumnIndex = 1; /** * End position. - * - * @var int */ - private $endColumnIndex = 1; + private int $endColumnIndex = 1; /** * Create a new column iterator. diff --git a/src/PhpSpreadsheet/Worksheet/RowDimension.php b/src/PhpSpreadsheet/Worksheet/RowDimension.php index b3c213a96b..f18686863c 100644 --- a/src/PhpSpreadsheet/Worksheet/RowDimension.php +++ b/src/PhpSpreadsheet/Worksheet/RowDimension.php @@ -15,17 +15,13 @@ class RowDimension extends Dimension * Row height (in pt). * * When this is set to a negative value, the row height should be ignored by IWriter - * - * @var float */ - private $height = -1; + private float $height = -1; /** * ZeroHeight for Row? - * - * @var bool */ - private $zeroHeight = false; + private bool $zeroHeight = false; /** * Create a new RowDimension. diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index 377a078f1b..1a256879d2 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -12,31 +12,23 @@ class RowIterator implements NativeIterator { /** * Worksheet to iterate. - * - * @var Worksheet */ - private $subject; + private Worksheet $subject; /** * Current iterator position. - * - * @var int */ - private $position = 1; + private int $position = 1; /** * Start position. - * - * @var int */ - private $startRow = 1; + private int $startRow = 1; /** * End position. - * - * @var int */ - private $endRow = 1; + private int $endRow = 1; /** * Create a new row iterator. diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index f61fe6a690..fda64e68ca 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -24,7 +24,7 @@ class SheetView * * @var ?int */ - private $zoomScale = 100; + private ?int $zoomScale = 100; /** * ZoomScaleNormal. @@ -33,26 +33,22 @@ class SheetView * * @var ?int */ - private $zoomScaleNormal = 100; + private ?int $zoomScaleNormal = 100; /** * ShowZeros. * * If true, "null" values from a calculation will be shown as "0". This is the default Excel behaviour and can be changed * with the advanced worksheet option "Show a zero in cells that have zero value" - * - * @var bool */ - private $showZeros = true; + private bool $showZeros = true; /** * View. * * Valid values range from 10 to 400. - * - * @var string */ - private $sheetviewType = self::SHEETVIEW_NORMAL; + private string $sheetviewType = self::SHEETVIEW_NORMAL; /** * Create a new SheetView. diff --git a/src/PhpSpreadsheet/Worksheet/Table.php b/src/PhpSpreadsheet/Worksheet/Table.php index 8f8b7be987..c5699e4c82 100644 --- a/src/PhpSpreadsheet/Worksheet/Table.php +++ b/src/PhpSpreadsheet/Worksheet/Table.php @@ -20,17 +20,13 @@ class Table implements Stringable /** * Show Header Row. - * - * @var bool */ - private $showHeaderRow = true; + private bool $showHeaderRow = true; /** * Show Totals Row. - * - * @var bool */ - private $showTotalsRow = false; + private bool $showTotalsRow = false; /** * Table Range. @@ -44,17 +40,15 @@ class Table implements Stringable /** * Table allow filter. - * - * @var bool */ - private $allowFilter = true; + private bool $allowFilter = true; /** * Table Column. * * @var Table\Column[] */ - private $columns = []; + private array $columns = []; /** * Table Style. diff --git a/src/PhpSpreadsheet/Worksheet/Table/Column.php b/src/PhpSpreadsheet/Worksheet/Table/Column.php index f697423894..65e6363643 100644 --- a/src/PhpSpreadsheet/Worksheet/Table/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Table/Column.php @@ -17,10 +17,8 @@ class Column /** * Show Filter Button. - * - * @var bool */ - private $showFilterButton = true; + private bool $showFilterButton = true; /** * Total Row Label. diff --git a/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php b/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php index c0744c995b..81153027da 100644 --- a/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php +++ b/src/PhpSpreadsheet/Worksheet/Table/TableStyle.php @@ -75,31 +75,23 @@ class TableStyle /** * Show First Column. - * - * @var bool */ - private $showFirstColumn = false; + private bool $showFirstColumn = false; /** * Show Last Column. - * - * @var bool */ - private $showLastColumn = false; + private bool $showLastColumn = false; /** * Show Row Stripes. - * - * @var bool */ - private $showRowStripes = false; + private bool $showRowStripes = false; /** * Show Column Stripes. - * - * @var bool */ - private $showColumnStripes = false; + private bool $showColumnStripes = false; /** * Table. diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 45c1c02f52..fa557daebb 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -61,10 +61,8 @@ class Worksheet implements IComparable /** * Invalid characters in sheet title. - * - * @var array */ - private static $invalidCharacters = ['*', ':', '/', '\\', '?', '[', ']']; + private static array $invalidCharacters = ['*', ':', '/', '\\', '?', '[', ']']; /** * Parent spreadsheet. @@ -81,7 +79,7 @@ class Worksheet implements IComparable * * @var RowDimension[] */ - private $rowDimensions = []; + private array $rowDimensions = []; /** * Default row dimension. @@ -93,7 +91,7 @@ class Worksheet implements IComparable * * @var ColumnDimension[] */ - private $columnDimensions = []; + private array $columnDimensions = []; /** * Default column dimension. @@ -123,17 +121,13 @@ class Worksheet implements IComparable /** * Worksheet title. - * - * @var string */ - private $title; + private string $title = ''; /** * Sheet state. - * - * @var string */ - private $sheetState; + private string $sheetState; /** * Page setup. @@ -165,42 +159,40 @@ class Worksheet implements IComparable * * @var Style[] */ - private $styles = []; + private array $styles = []; /** * Conditional styles. Indexed by cell coordinate, e.g. 'A1'. - * - * @var array */ - private $conditionalStylesCollection = []; + private array $conditionalStylesCollection = []; /** * Collection of row breaks. * * @var PageBreak[] */ - private $rowBreaks = []; + private array $rowBreaks = []; /** * Collection of column breaks. * * @var PageBreak[] */ - private $columnBreaks = []; + private array $columnBreaks = []; /** * Collection of merged cell ranges. * * @var string[] */ - private $mergeCells = []; + private array $mergeCells = []; /** * Collection of protected cell ranges. * * @var string[] */ - private $protectedCells = []; + private array $protectedCells = []; /** * Autofilter Range and selection. @@ -209,17 +201,13 @@ class Worksheet implements IComparable /** * Freeze pane. - * - * @var null|string */ - private $freezePane; + private ?string $freezePane = null; /** * Default position of the right bottom pane. - * - * @var null|string */ - private $topLeftCell; + private ?string $topLeftCell = null; private string $paneTopLeftCell = ''; @@ -236,7 +224,7 @@ class Worksheet implements IComparable * * @var (null|Pane)[] */ - private $panes = [ + private array $panes = [ 'bottomRight' => null, 'bottomLeft' => null, 'topRight' => null, @@ -245,122 +233,90 @@ class Worksheet implements IComparable /** * Show gridlines? - * - * @var bool */ - private $showGridlines = true; + private bool $showGridlines = true; /** * Print gridlines? - * - * @var bool */ - private $printGridlines = false; + private bool $printGridlines = false; /** * Show row and column headers? - * - * @var bool */ - private $showRowColHeaders = true; + private bool $showRowColHeaders = true; /** * Show summary below? (Row/Column outline). - * - * @var bool */ - private $showSummaryBelow = true; + private bool $showSummaryBelow = true; /** * Show summary right? (Row/Column outline). - * - * @var bool */ - private $showSummaryRight = true; + private bool $showSummaryRight = true; /** * Collection of comments. * * @var Comment[] */ - private $comments = []; + private array $comments = []; /** * Active cell. (Only one!). - * - * @var string */ - private $activeCell = 'A1'; + private string $activeCell = 'A1'; /** * Selected cells. - * - * @var string */ - private $selectedCells = 'A1'; + private string $selectedCells = 'A1'; /** * Cached highest column. - * - * @var int */ - private $cachedHighestColumn = 1; + private int $cachedHighestColumn = 1; /** * Cached highest row. - * - * @var int */ - private $cachedHighestRow = 1; + private int $cachedHighestRow = 1; /** * Right-to-left? - * - * @var bool */ - private $rightToLeft = false; + private bool $rightToLeft = false; /** * Hyperlinks. Indexed by cell coordinate, e.g. 'A1'. - * - * @var array */ - private $hyperlinkCollection = []; + private array $hyperlinkCollection = []; /** * Data validation objects. Indexed by cell coordinate, e.g. 'A1'. - * - * @var array */ - private $dataValidationCollection = []; + private array $dataValidationCollection = []; /** * Tab color. - * - * @var null|Color */ - private $tabColor; + private ?Color $tabColor = null; /** * Dirty flag. - * - * @var bool */ - private $dirty = true; + private bool $dirty = true; /** * Hash. - * - * @var string */ - private $hash; + private string $hash; /** * CodeName. - * - * @var string */ - private $codeName; + private ?string $codeName = null; /** * Create a new worksheet. diff --git a/src/PhpSpreadsheet/Writer/BaseWriter.php b/src/PhpSpreadsheet/Writer/BaseWriter.php index df862f7c55..3883244156 100644 --- a/src/PhpSpreadsheet/Writer/BaseWriter.php +++ b/src/PhpSpreadsheet/Writer/BaseWriter.php @@ -7,43 +7,32 @@ abstract class BaseWriter implements IWriter /** * Write charts that are defined in the workbook? * Identifies whether the Writer should write definitions for any charts that exist in the PhpSpreadsheet object. - * - * @var bool */ - protected $includeCharts = false; + protected bool $includeCharts = false; /** * Pre-calculate formulas * Forces PhpSpreadsheet to recalculate all formulae in a workbook when saving, so that the pre-calculated values are * immediately available to MS Excel or other office spreadsheet viewer when opening the file. - * - * @var bool */ - protected $preCalculateFormulas = true; + protected bool $preCalculateFormulas = true; /** * Use disk caching where possible? - * - * @var bool */ - private $useDiskCaching = false; + private bool $useDiskCaching = false; /** * Disk caching directory. - * - * @var string */ - private $diskCachingDirectory = './'; + private string $diskCachingDirectory = './'; /** * @var resource */ protected $fileHandle; - /** - * @var bool - */ - private $shouldCloseFile; + private bool $shouldCloseFile; public function getIncludeCharts(): bool { diff --git a/src/PhpSpreadsheet/Writer/Csv.php b/src/PhpSpreadsheet/Writer/Csv.php index d43feda9da..73165d67c2 100644 --- a/src/PhpSpreadsheet/Writer/Csv.php +++ b/src/PhpSpreadsheet/Writer/Csv.php @@ -24,39 +24,29 @@ class Csv extends BaseWriter /** * Line ending. - * - * @var string */ - private $lineEnding = PHP_EOL; + private string $lineEnding = PHP_EOL; /** * Sheet index to write. - * - * @var int */ - private $sheetIndex = 0; + private int $sheetIndex = 0; /** * Whether to write a UTF8 BOM. - * - * @var bool */ - private $useBOM = false; + private bool $useBOM = false; /** * Whether to write a Separator line as the first line of the file * sep=x. - * - * @var bool */ - private $includeSeparatorLine = false; + private bool $includeSeparatorLine = false; /** * Whether to write a fully Excel compatible CSV file. - * - * @var bool */ - private $excelCompatibility = false; + private bool $excelCompatibility = false; /** * Output encoding. @@ -243,8 +233,7 @@ public function setOutputEncoding(string $outputEnconding): self return $this; } - /** @var bool */ - private $enclosureRequired = true; + private bool $enclosureRequired = true; public function setEnclosureRequired(bool $value): self { diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index ecb99219d1..a523d80f6f 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -42,52 +42,38 @@ class Html extends BaseWriter /** * Sheet index to write. - * - * @var null|int */ - private $sheetIndex = 0; + private ?int $sheetIndex = 0; /** * Images root. - * - * @var string */ - private $imagesRoot = ''; + private string $imagesRoot = ''; /** * embed images, or link to images. - * - * @var bool */ - protected $embedImages = false; + protected bool $embedImages = false; /** * Use inline CSS? - * - * @var bool */ - private $useInlineCss = false; + private bool $useInlineCss = false; /** * Use embedded CSS? - * - * @var bool */ - private $useEmbeddedCSS = true; + private bool $useEmbeddedCSS = true; /** * Array of CSS styles. - * - * @var array */ - private $cssStyles; + private ?array $cssStyles = null; /** * Array of column widths in points. - * - * @var array */ - private $columnWidths; + private array $columnWidths; /** * Default font. @@ -96,52 +82,38 @@ class Html extends BaseWriter /** * Flag whether spans have been calculated. - * - * @var bool */ - private $spansAreCalculated = false; + private bool $spansAreCalculated = false; /** * Excel cells that should not be written as HTML cells. - * - * @var array */ - private $isSpannedCell = []; + private array $isSpannedCell = []; /** * Excel cells that are upper-left corner in a cell merge. - * - * @var array */ - private $isBaseCell = []; + private array $isBaseCell = []; /** * Excel rows that should not be written as HTML rows. - * - * @var array */ - private $isSpannedRow = []; + private array $isSpannedRow = []; /** * Is the current writer creating PDF? - * - * @var bool */ - protected $isPdf = false; + protected bool $isPdf = false; /** * Is the current writer creating mPDF? - * - * @var bool */ - protected $isMPdf = false; + protected bool $isMPdf = false; /** * Generate the Navigation block. - * - * @var bool */ - private $generateSheetNavigationBlock = true; + private bool $generateSheetNavigationBlock = true; /** * Callback for editing generated html. diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index 4b229b78e1..fd5a8a825e 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -18,10 +18,8 @@ class Ods extends BaseWriter { /** * Private PhpSpreadsheet. - * - * @var Spreadsheet */ - private $spreadSheet; + private Spreadsheet $spreadSheet; private Content $writerPartContent; diff --git a/src/PhpSpreadsheet/Writer/Ods/Formula.php b/src/PhpSpreadsheet/Writer/Ods/Formula.php index f0b5d78f53..9385607be4 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Formula.php +++ b/src/PhpSpreadsheet/Writer/Ods/Formula.php @@ -7,8 +7,7 @@ class Formula { - /** @var array */ - private $definedNames = []; + private array $definedNames = []; /** * @param DefinedName[] $definedNames diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index e74bb8f38a..0ba4ba5379 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -16,10 +16,8 @@ abstract class Pdf extends Html /** * Font. - * - * @var string */ - protected $font = 'freesans'; + protected string $font = 'freesans'; /** * Orientation (Over-ride). @@ -31,14 +29,12 @@ abstract class Pdf extends Html * * @var ?int */ - protected $paperSize; + protected ?int $paperSize = null; /** * Paper Sizes xRef List. - * - * @var array */ - protected static $paperSizes = [ + protected static array $paperSizes = [ PageSetup::PAPERSIZE_LETTER => 'LETTER', // (8.5 in. by 11 in.) PageSetup::PAPERSIZE_LETTER_SMALL => 'LETTER', // (8.5 in. by 11 in.) PageSetup::PAPERSIZE_TABLOID => [792.00, 1224.00], // (11 in. by 17 in.) diff --git a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php index 690b0c54a3..f9cafb043b 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -9,10 +9,8 @@ class Dompdf extends Pdf { /** * embed images, or link to images. - * - * @var bool */ - protected $embedImages = true; + protected bool $embedImages = true; /** * Gets the implementation of external PDF library that should be used. diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index 3e9e94ebeb..53b79d2ad1 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -10,8 +10,7 @@ class Mpdf extends Pdf public const SIMULATED_BODY_START = ''; private const BODY_TAG = ''; - /** @var bool */ - protected $isMPdf = true; + protected bool $isMPdf = true; /** * Gets the implementation of external PDF library that should be used. diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 1b96579e03..49835e9fd3 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -36,31 +36,23 @@ class Xls extends BaseWriter /** * Total number of shared strings in workbook. - * - * @var int */ - private $strTotal = 0; + private int $strTotal = 0; /** * Number of unique shared strings in workbook. - * - * @var int */ - private $strUnique = 0; + private int $strUnique = 0; /** * Array of unique shared strings in workbook. - * - * @var array */ - private $strTable = []; + private array $strTable = []; /** * Color cache. Mapping between RGB value and color index. - * - * @var array */ - private $colors; + private array $colors; /** * Formula parser. @@ -69,34 +61,25 @@ class Xls extends BaseWriter /** * Identifier clusters for drawings. Used in MSODRAWINGGROUP record. - * - * @var array */ - private $IDCLs; + private array $IDCLs; /** * Basic OLE object summary information. - * - * @var string */ - private $summaryInformation; + private string $summaryInformation; /** * Extended OLE object document summary information. - * - * @var string */ - private $documentSummaryInformation; + private string $documentSummaryInformation; - /** - * @var Workbook - */ - private $writerWorkbook; + private Workbook $writerWorkbook; /** * @var Worksheet[] */ - private $writerWorksheets; + private array $writerWorksheets; /** * Create a new Xls Writer. diff --git a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php index 9d961b7128..b4fcb208b1 100644 --- a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php @@ -44,30 +44,24 @@ class BIFFwriter * * @var ?int */ - private static $byteOrder; + private static ?int $byteOrder; /** * The string containing the data of the BIFF stream. - * - * @var null|string */ - public $_data; + public ?string $_data; /** * The size of the data in bytes. Should be the same as strlen($this->_data). - * - * @var int */ - public $_datasize; + public int $_datasize; /** * The maximum length for a BIFF record (excluding record header and length field). See addContinue(). * - * @var int - * * @see addContinue() */ - private $limit = 8224; + private int $limit = 8224; /** * Constructor. diff --git a/src/PhpSpreadsheet/Writer/Xls/CellDataValidation.php b/src/PhpSpreadsheet/Writer/Xls/CellDataValidation.php index 7e9b3cfa4e..fee123f551 100644 --- a/src/PhpSpreadsheet/Writer/Xls/CellDataValidation.php +++ b/src/PhpSpreadsheet/Writer/Xls/CellDataValidation.php @@ -9,7 +9,7 @@ class CellDataValidation /** * @var array */ - protected static $validationTypeMap = [ + protected static array $validationTypeMap = [ DataValidation::TYPE_NONE => 0x00, DataValidation::TYPE_WHOLE => 0x01, DataValidation::TYPE_DECIMAL => 0x02, @@ -23,7 +23,7 @@ class CellDataValidation /** * @var array */ - protected static $errorStyleMap = [ + protected static array $errorStyleMap = [ DataValidation::STYLE_STOP => 0x00, DataValidation::STYLE_WARNING => 0x01, DataValidation::STYLE_INFORMATION => 0x02, @@ -32,7 +32,7 @@ class CellDataValidation /** * @var array */ - protected static $operatorMap = [ + protected static array $operatorMap = [ DataValidation::OPERATOR_BETWEEN => 0x00, DataValidation::OPERATOR_NOTBETWEEN => 0x01, DataValidation::OPERATOR_EQUAL => 0x02, diff --git a/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php b/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php index 1bbac2aa19..b38b287a24 100644 --- a/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php +++ b/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php @@ -17,10 +17,7 @@ class ConditionalHelper */ protected $condition; - /** - * @var string - */ - protected $cellRange; + protected string $cellRange; protected ?string $tokens = null; diff --git a/src/PhpSpreadsheet/Writer/Xls/ErrorCode.php b/src/PhpSpreadsheet/Writer/Xls/ErrorCode.php index 7a864f50f3..e74f4f405a 100644 --- a/src/PhpSpreadsheet/Writer/Xls/ErrorCode.php +++ b/src/PhpSpreadsheet/Writer/Xls/ErrorCode.php @@ -7,7 +7,7 @@ class ErrorCode /** * @var array */ - protected static $errorCodeMap = [ + protected static array $errorCodeMap = [ '#NULL!' => 0x00, '#DIV/0!' => 0x07, '#VALUE!' => 0x0F, diff --git a/src/PhpSpreadsheet/Writer/Xls/Escher.php b/src/PhpSpreadsheet/Writer/Xls/Escher.php index ec07a71aa7..118fd80d71 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Escher.php +++ b/src/PhpSpreadsheet/Writer/Xls/Escher.php @@ -23,24 +23,18 @@ class Escher /** * The written binary data. - * - * @var string */ - private $data; + private string $data; /** * Shape offsets. Positions in binary stream where a new shape record begins. - * - * @var array */ - private $spOffsets; + private array $spOffsets; /** * Shape types. - * - * @var array */ - private $spTypes; + private array $spTypes; /** * Constructor. diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index e3b7923a48..5cd68debb6 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -35,8 +35,7 @@ public function setColorIndex($colorIndex): void $this->colorIndex = $colorIndex; } - /** @var int */ - private static $notImplemented = 0; + private static int $notImplemented = 0; /** * Get font record data. @@ -114,7 +113,7 @@ private static function mapBold(?bool $bold): int * * @var int[] */ - private static $mapUnderline = [ + private static array $mapUnderline = [ \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_NONE => 0x00, \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_SINGLE => 0x01, \PhpOffice\PhpSpreadsheet\Style\Font::UNDERLINE_DOUBLE => 0x02, diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index b30834050e..93d94630a0 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -49,17 +49,13 @@ class Parser /** * The index of the character we are currently looking at. - * - * @var int */ - public $currentCharacter; + public int $currentCharacter; /** * The token we are working on. - * - * @var string */ - public $currentToken; + public string $currentToken; /** * The formula to parse. @@ -68,10 +64,8 @@ class Parser /** * The character ahead of the current char. - * - * @var string */ - public $lookAhead; + public string $lookAhead; /** * The parse tree to be generated. @@ -87,17 +81,13 @@ class Parser /** * Array of sheet references in the form of REF structures. - * - * @var array */ - public $references; + public array $references; /** * The Excel ptg indices. - * - * @var array */ - private $ptg = [ + private array $ptg = [ 'ptgExp' => 0x01, 'ptgTbl' => 0x02, 'ptgAdd' => 0x03, @@ -208,10 +198,8 @@ class Parser * -1 is a variable number of arguments. * class: The reference, value or array class of the function args. * vol: The function is volatile. - * - * @var array */ - private $functions = [ + private array $functions = [ // function ptg args class vol 'COUNT' => [0, -1, 0, 0], 'IF' => [1, -1, 1, 0], @@ -751,8 +739,7 @@ private function convertError($errorCode): string }; } - /** @var bool */ - private $tryDefinedName = false; + private bool $tryDefinedName = false; private function convertDefinedName(string $name): string { diff --git a/src/PhpSpreadsheet/Writer/Xls/Style/CellAlignment.php b/src/PhpSpreadsheet/Writer/Xls/Style/CellAlignment.php index 711d88d209..81da6353a9 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Style/CellAlignment.php +++ b/src/PhpSpreadsheet/Writer/Xls/Style/CellAlignment.php @@ -9,7 +9,7 @@ class CellAlignment /** * @var array */ - private static $horizontalMap = [ + private static array $horizontalMap = [ Alignment::HORIZONTAL_GENERAL => 0, Alignment::HORIZONTAL_LEFT => 1, Alignment::HORIZONTAL_RIGHT => 3, @@ -21,7 +21,7 @@ class CellAlignment /** * @var array */ - private static $verticalMap = [ + private static array $verticalMap = [ Alignment::VERTICAL_BOTTOM => 2, Alignment::VERTICAL_TOP => 0, Alignment::VERTICAL_CENTER => 1, diff --git a/src/PhpSpreadsheet/Writer/Xls/Style/CellBorder.php b/src/PhpSpreadsheet/Writer/Xls/Style/CellBorder.php index bc14920654..e97a1f7914 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Style/CellBorder.php +++ b/src/PhpSpreadsheet/Writer/Xls/Style/CellBorder.php @@ -9,7 +9,7 @@ class CellBorder /** * @var array */ - protected static $styleMap = [ + protected static array $styleMap = [ Border::BORDER_NONE => 0x00, Border::BORDER_THIN => 0x01, Border::BORDER_MEDIUM => 0x02, diff --git a/src/PhpSpreadsheet/Writer/Xls/Style/CellFill.php b/src/PhpSpreadsheet/Writer/Xls/Style/CellFill.php index f5a8c4700e..a0a932a967 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Style/CellFill.php +++ b/src/PhpSpreadsheet/Writer/Xls/Style/CellFill.php @@ -9,7 +9,7 @@ class CellFill /** * @var array */ - protected static $fillStyleMap = [ + protected static array $fillStyleMap = [ Fill::FILL_NONE => 0x00, Fill::FILL_SOLID => 0x01, Fill::FILL_PATTERN_MEDIUMGRAY => 0x02, diff --git a/src/PhpSpreadsheet/Writer/Xls/Style/ColorMap.php b/src/PhpSpreadsheet/Writer/Xls/Style/ColorMap.php index caf85c0499..46f7bd5b48 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Style/ColorMap.php +++ b/src/PhpSpreadsheet/Writer/Xls/Style/ColorMap.php @@ -9,7 +9,7 @@ class ColorMap /** * @var array */ - private static $colorMap = [ + private static array $colorMap = [ '#000000' => 0x08, '#FFFFFF' => 0x09, '#FF0000' => 0x0A, diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index 1f7b28f2a5..030f68654b 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -64,14 +64,12 @@ class Workbook extends BIFFwriter * * @var Xf[] */ - private $xfWriters = []; + private array $xfWriters = []; /** * Array containing the colour palette. - * - * @var array */ - private $palette; + private array $palette; /** * The codepage indicates the text encoding used for strings. @@ -93,70 +91,52 @@ class Workbook extends BIFFwriter * * @var Font[] */ - private $fontWriters = []; + private array $fontWriters = []; /** * Added fonts. Maps from font's hash => index in workbook. - * - * @var array */ - private $addedFonts = []; + private array $addedFonts = []; /** * Shared number formats. - * - * @var array */ - private $numberFormats = []; + private array $numberFormats = []; /** * Added number formats. Maps from numberFormat's hash => index in workbook. - * - * @var array */ - private $addedNumberFormats = []; + private array $addedNumberFormats = []; /** * Sizes of the binary worksheet streams. - * - * @var array */ - private $worksheetSizes = []; + private array $worksheetSizes = []; /** * Offsets of the binary worksheet streams relative to the start of the global workbook stream. - * - * @var array */ - private $worksheetOffsets = []; + private array $worksheetOffsets = []; /** * Total number of shared strings in workbook. - * - * @var int */ - private $stringTotal; + private int $stringTotal; /** * Number of unique shared strings in workbook. - * - * @var int */ - private $stringUnique; + private int $stringUnique; /** * Array of unique shared strings in workbook. - * - * @var array */ - private $stringTable; + private array $stringTable; /** * Color cache. - * - * @var array */ - private $colors; + private array $colors; /** * Escher object corresponding to MSODRAWINGGROUP. diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 288c1222fe..d925d21b7d 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -54,11 +54,9 @@ // */ class Worksheet extends BIFFwriter { - /** @var int */ - private static $always0 = 0; + private static int $always0 = 0; - /** @var int */ - private static $always1 = 1; + private static int $always1 = 1; /** * Formula parser. @@ -67,10 +65,8 @@ class Worksheet extends BIFFwriter /** * Array containing format information for columns. - * - * @var array */ - private $columnInfo; + private array $columnInfo; /** * The active pane for the worksheet. @@ -101,31 +97,23 @@ class Worksheet extends BIFFwriter /** * Reference to the total number of strings in the workbook. - * - * @var int */ - private $stringTotal; + private int $stringTotal; /** * Reference to the number of unique strings in the workbook. - * - * @var int */ - private $stringUnique; + private int $stringUnique; /** * Reference to the array containing all the unique strings in the workbook. - * - * @var array */ - private $stringTable; + private array $stringTable; /** * Color cache. - * - * @var array */ - private $colors; + private array $colors; /** * Index of first used row (at least 0). @@ -149,10 +137,8 @@ class Worksheet extends BIFFwriter /** * Sheet object. - * - * @var \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet */ - public $phpSheet; + public \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet; /** * Escher object corresponding to MSODRAWING. @@ -161,15 +147,10 @@ class Worksheet extends BIFFwriter /** * Array of font hashes associated to FONT records index. - * - * @var array */ - public $fontHashIndex; + public array $fontHashIndex; - /** - * @var bool - */ - private $preCalculateFormulas; + private bool $preCalculateFormulas; private int $printHeaders; @@ -765,8 +746,7 @@ private function writeBoolErr(int $row, int $col, $value, int $isError, int $xfI const WRITE_FORMULA_RANGE = -2; const WRITE_FORMULA_EXCEPTION = -3; - /** @var bool */ - private static $allowThrow = false; + private static bool $allowThrow = false; public static function setAllowThrow(bool $allowThrow): void { diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index c18bc85862..b276cddfab 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -37,24 +37,20 @@ class Xlsx extends BaseWriter { /** * Office2003 compatibility. - * - * @var bool */ - private $office2003compatibility = false; + private bool $office2003compatibility = false; /** * Private Spreadsheet. - * - * @var Spreadsheet */ - private $spreadSheet; + private Spreadsheet $spreadSheet; /** * Private string table. * * @var string[] */ - private $stringTable = []; + private array $stringTable = []; /** * Private unique Conditional HashTable. @@ -107,10 +103,8 @@ class Xlsx extends BaseWriter /** * Private handle for zip stream. - * - * @var ZipStream */ - private $zip; + private ZipStream $zip; private Chart $writerPartChart; @@ -648,8 +642,7 @@ public function setOffice2003Compatibility($office2003compatibility): static return $this; } - /** @var array */ - private $pathNames = []; + private array $pathNames = []; private function addZipFile(string $path, string $content): void { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index f27156507a..d25ec4bcb2 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -19,10 +19,7 @@ class Chart extends WriterPart { - /** - * @var int - */ - private $seriesIndex; + private int $seriesIndex; /** * Write charts to XML format. diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 7efaaf9396..0c1561de98 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -20,17 +20,13 @@ class Worksheet extends WriterPart { - /** @var string */ - private $numberStoredAsText = ''; + private string $numberStoredAsText = ''; - /** @var string */ - private $formula = ''; + private string $formula = ''; - /** @var string */ - private $twoDigitTextYear = ''; + private string $twoDigitTextYear = ''; - /** @var string */ - private $evalError = ''; + private string $evalError = ''; /** * Write worksheet to XML format. diff --git a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php index 3d7967c0e6..74f46d4bfd 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Engine/RangeTest.php @@ -11,8 +11,7 @@ class RangeTest extends TestCase { - /** @var string */ - private $incompleteMessage = 'Must be revisited'; + private string $incompleteMessage = 'Must be revisited'; private \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadSheet; diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/SetupTeardownDatabases.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/SetupTeardownDatabases.php index c280b6725b..5094d8ea4b 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Database/SetupTeardownDatabases.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Database/SetupTeardownDatabases.php @@ -17,12 +17,12 @@ class SetupTeardownDatabases extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AllSetupTeardown.php index 6fd236934b..b51a8509a7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/AllSetupTeardown.php @@ -18,12 +18,12 @@ class AllSetupTeardown extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AllSetupTeardown.php index 709535dc9c..9d41cedc3e 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/AllSetupTeardown.php @@ -18,12 +18,12 @@ class AllSetupTeardown extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AllSetupTeardown.php index 46947d7d1f..93240fa008 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/AllSetupTeardown.php @@ -13,20 +13,17 @@ class AllSetupTeardown extends TestCase { - /** - * @var string - */ - protected $compatibilityMode; + protected string $compatibilityMode; /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php index ed91c19360..7514023e23 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/IndirectTest.php @@ -174,8 +174,7 @@ public static function providerRelative(): array ]; } - /** @var bool */ - private static $definedFormulaWorking = false; + private static bool $definedFormulaWorking = false; public function testAboveCell(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AllSetupTeardown.php index a73de31c0f..d4594cc67d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/AllSetupTeardown.php @@ -18,12 +18,12 @@ class AllSetupTeardown extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php index 37266eec5e..5b728fefa7 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/AllSetupTeardown.php @@ -18,12 +18,12 @@ class AllSetupTeardown extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/AllSetupTeardown.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/AllSetupTeardown.php index 63f2e01c82..a24822476d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/AllSetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/AllSetupTeardown.php @@ -21,12 +21,12 @@ class AllSetupTeardown extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php index a5ef6e6cd4..6c05513a90 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Web/WebServiceTest.php @@ -16,7 +16,7 @@ class WebServiceTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Calculation/RowColumnReferenceTest.php b/tests/PhpSpreadsheetTests/Calculation/RowColumnReferenceTest.php index 1219583643..e34f8c87ed 100644 --- a/tests/PhpSpreadsheetTests/Calculation/RowColumnReferenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/RowColumnReferenceTest.php @@ -10,10 +10,7 @@ class RowColumnReferenceTest extends TestCase { - /** - * @var Spreadsheet - */ - protected $spreadSheet; + protected Spreadsheet $spreadSheet; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Cell/CellDetachTest.php b/tests/PhpSpreadsheetTests/Cell/CellDetachTest.php index 388d3ad713..efd2dca04d 100644 --- a/tests/PhpSpreadsheetTests/Cell/CellDetachTest.php +++ b/tests/PhpSpreadsheetTests/Cell/CellDetachTest.php @@ -12,7 +12,7 @@ class CellDetachTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Chart/Charts32CatAxValAxTest.php b/tests/PhpSpreadsheetTests/Chart/Charts32CatAxValAxTest.php index 083e9a6c3d..0937345cd0 100644 --- a/tests/PhpSpreadsheetTests/Chart/Charts32CatAxValAxTest.php +++ b/tests/PhpSpreadsheetTests/Chart/Charts32CatAxValAxTest.php @@ -22,8 +22,7 @@ class Charts32CatAxValAxTest extends TestCase // These tests can only be performed by examining xml. // They are based on sample 33_Chart_Create_Scatter2. - /** @var string */ - private $outputFileName = ''; + private string $outputFileName = ''; private const FORMAT_CODE_DATE_ISO8601_SLASH = 'yyyy/mm/dd'; // not automatically treated as numeric diff --git a/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php b/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php index 73c98afe2d..7efef03023 100644 --- a/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php +++ b/tests/PhpSpreadsheetTests/Custom/ComplexAssert.php @@ -11,8 +11,7 @@ class ComplexAssert extends TestCase { private string $errorMessage = ''; - /** @var float */ - private $delta = 0.0; + private float $delta = 0.0; public function __construct() { diff --git a/tests/PhpSpreadsheetTests/Document/PropertiesTest.php b/tests/PhpSpreadsheetTests/Document/PropertiesTest.php index 12de9c1220..0ada722002 100644 --- a/tests/PhpSpreadsheetTests/Document/PropertiesTest.php +++ b/tests/PhpSpreadsheetTests/Document/PropertiesTest.php @@ -12,13 +12,9 @@ class PropertiesTest extends TestCase { - /** - * @var Properties - */ - private $properties; + private Properties $properties; - /** @var float */ - private $startTime; + private float $startTime; protected function setup(): void { diff --git a/tests/PhpSpreadsheetTests/NamedRange2Test.php b/tests/PhpSpreadsheetTests/NamedRange2Test.php index 6c20e145dd..dcf038c52f 100644 --- a/tests/PhpSpreadsheetTests/NamedRange2Test.php +++ b/tests/PhpSpreadsheetTests/NamedRange2Test.php @@ -13,7 +13,7 @@ class NamedRange2Test extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php index 7ee93665e4..c6bb2ccaba 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php @@ -9,20 +9,11 @@ /** Define a Read Filter class implementing IReadFilter */ class CsvContiguousFilter implements IReadFilter { - /** - * @var int - */ - private $startRow = 0; + private int $startRow = 0; - /** - * @var int - */ - private $endRow = 0; + private int $endRow = 0; - /** - * @var int - */ - private $filterType = 0; + private int $filterType = 0; /** * Set the list of rows that we want to read. diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php index abb85d73e8..148a30cf51 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousTest.php @@ -10,10 +10,7 @@ class CsvContiguousTest extends TestCase { - /** - * @var string - */ - private $inputFileName = 'samples/Reader/sampleData/example2.csv'; + private string $inputFileName = 'samples/Reader/sampleData/example2.csv'; public function testContiguous(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php index 64dd48cb58..f58e1809a8 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvLineEndingTest.php @@ -10,8 +10,7 @@ class CsvLineEndingTest extends TestCase { - /** @var string */ - private $tempFile = ''; + private string $tempFile = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatLocaleTest.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatLocaleTest.php index 9550636b3c..9fc15f1e48 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatLocaleTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatLocaleTest.php @@ -17,15 +17,9 @@ class CsvNumberFormatLocaleTest extends TestCase */ private $currentLocale; - /** - * @var string - */ - protected $filename; + protected string $filename; - /** - * @var Csv - */ - protected $csvReader; + protected Csv $csvReader; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatTest.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatTest.php index 3cf4047092..5b3e7a0626 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvNumberFormatTest.php @@ -10,15 +10,9 @@ class CsvNumberFormatTest extends TestCase { - /** - * @var string - */ - protected $filename; + protected string $filename; - /** - * @var Csv - */ - protected $csvReader; + protected Csv $csvReader; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/EmptyFileTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/EmptyFileTest.php index 9e7c15515d..7506ea0160 100644 --- a/tests/PhpSpreadsheetTests/Reader/Ods/EmptyFileTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Ods/EmptyFileTest.php @@ -11,8 +11,7 @@ class EmptyFileTest extends TestCase { - /** @var string */ - private $tempfile = ''; + private string $tempfile = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/OdsTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/OdsTest.php index ade0093e70..840646d7f1 100644 --- a/tests/PhpSpreadsheetTests/Reader/Ods/OdsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Ods/OdsTest.php @@ -21,8 +21,7 @@ class OdsTest extends TestCase private const ODS_DATA_FILE = 'tests/data/Reader/Ods/data.ods'; - /** @var string */ - private $incompleteMessage = 'Features not implemented yet'; + private string $incompleteMessage = 'Features not implemented yet'; private string $timeZone; diff --git a/tests/PhpSpreadsheetTests/Reader/Slk/SlkTest.php b/tests/PhpSpreadsheetTests/Reader/Slk/SlkTest.php index ac8b381df4..371bfb457e 100644 --- a/tests/PhpSpreadsheetTests/Reader/Slk/SlkTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Slk/SlkTest.php @@ -13,15 +13,9 @@ class SlkTest extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = __DIR__ . '/../../../../samples/templates/SylkTest.slk'; - - /** - * @var string - */ - private $filename = ''; + private static string $testbook = __DIR__ . '/../../../../samples/templates/SylkTest.slk'; + + private string $filename = ''; protected function teardown(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xls/LoadSheetsOnlyTest.php b/tests/PhpSpreadsheetTests/Reader/Xls/LoadSheetsOnlyTest.php index e723dbda24..5edcbe6d39 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xls/LoadSheetsOnlyTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xls/LoadSheetsOnlyTest.php @@ -12,12 +12,9 @@ class LoadSheetsOnlyTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLS/HiddenSheet.xls'; + private static string $testbook = 'tests/data/Reader/XLS/HiddenSheet.xls'; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/EmptyFileTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/EmptyFileTest.php index 2136b3a7a7..9da7f79d60 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/EmptyFileTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/EmptyFileTest.php @@ -11,8 +11,7 @@ class EmptyFileTest extends TestCase { - /** @var string */ - private $tempfile = ''; + private string $tempfile = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/ExplicitDateTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/ExplicitDateTest.php index 919e617aa7..adad99aff9 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/ExplicitDateTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/ExplicitDateTest.php @@ -8,10 +8,7 @@ class ExplicitDateTest extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/explicitdate.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/explicitdate.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue1482Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue1482Test.php index e1d0875504..bfaa580843 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue1482Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue1482Test.php @@ -8,10 +8,7 @@ class Issue1482Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.1482.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.1482.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2301Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2301Test.php index 1d876a0ff8..95dc2228d0 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2301Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2301Test.php @@ -9,10 +9,7 @@ class Issue2301Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.2301.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.2301.xlsx'; public static function testReadRichText(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2488Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2488Test.php index 6595cb5b42..c4f4e1def9 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2488Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2488Test.php @@ -9,10 +9,7 @@ class Issue2488Test extends TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.2488.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.2488.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2490Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2490Test.php index 8307ce1db6..4cd14973d8 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2490Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2490Test.php @@ -9,15 +9,9 @@ class Issue2490Test extends TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.2490.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.2490.xlsx'; - /** - * @var string - */ - private static $testbook3093 = 'tests/data/Reader/XLSX/issue.3093.xlsx'; + private static string $testbook3093 = 'tests/data/Reader/XLSX/issue.3093.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2501Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2501Test.php index 011d00b8fb..fb8e7bec34 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2501Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2501Test.php @@ -9,10 +9,7 @@ class Issue2501Test extends TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.2501.b.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.2501.b.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2516Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2516Test.php index e091d2a79d..c4333d6f37 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2516Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2516Test.php @@ -9,10 +9,7 @@ class Issue2516Test extends TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.2516b.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.2516b.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2542Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2542Test.php index 34027522fe..1bf7993d68 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2542Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2542Test.php @@ -10,10 +10,7 @@ class Issue2542Test extends TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.2542.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.2542.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2778Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2778Test.php index b672f9c1c7..cdfcacf3d5 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2778Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2778Test.php @@ -9,10 +9,7 @@ class Issue2778Test extends TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.2778.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.2778.xlsx'; public function testIssue2778(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2885Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2885Test.php index 9f2783ce82..ec332e0414 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2885Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue2885Test.php @@ -9,10 +9,7 @@ class Issue2885Test extends TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.2885.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.2885.xlsx'; public function testIssue2885(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3435Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3435Test.php index 0962724019..333016e66c 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3435Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3435Test.php @@ -8,10 +8,7 @@ class Issue3435Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.3435.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.3435.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3464Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3464Test.php index f466dc725d..2dc1d8d44d 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3464Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3464Test.php @@ -9,10 +9,7 @@ class Issue3464Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.3464.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.3464.xlsx'; public function testReadFontColor(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3495Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3495Test.php index 5c0b71facf..8148d95e70 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3495Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3495Test.php @@ -8,10 +8,7 @@ class Issue3495Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.3495d.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.3495d.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3534Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3534Test.php index 3a0146e74f..833a30ed2e 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3534Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3534Test.php @@ -9,10 +9,7 @@ class Issue3534Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.3534.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.3534.xlsx'; public function testReadColumnStyles(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3552Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3552Test.php index de3e738cc0..197a7bbc6b 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3552Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3552Test.php @@ -11,10 +11,7 @@ class Issue3552Test extends AbstractFunctional { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.3552.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.3552.xlsx'; public function testRowBreaks(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3553Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3553Test.php index 73c19f7e7e..be1042dffe 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3553Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3553Test.php @@ -8,10 +8,7 @@ class Issue3553Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.3553.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.3553.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3665Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3665Test.php index f4990bc676..d3e68adf37 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3665Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3665Test.php @@ -8,10 +8,7 @@ class Issue3665Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue.3665.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue.3665.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/LoadSheetsOnlyTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/LoadSheetsOnlyTest.php index 3513fd981a..93739b6352 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/LoadSheetsOnlyTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/LoadSheetsOnlyTest.php @@ -12,12 +12,9 @@ class LoadSheetsOnlyTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/HiddenSheet.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/HiddenSheet.xlsx'; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceIssue2109bTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceIssue2109bTest.php index 6c0e6b1e31..40c6b01446 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceIssue2109bTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceIssue2109bTest.php @@ -9,10 +9,7 @@ class NamespaceIssue2109bTest extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/issue2109b.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/issue2109b.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceNonStdTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceNonStdTest.php index c1b6bbb478..15576dae7d 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceNonStdTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceNonStdTest.php @@ -11,10 +11,7 @@ class NamespaceNonStdTest extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/namespacenonstd.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/namespacenonstd.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceOpenpyxl35Test.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceOpenpyxl35Test.php index d582530c62..c9ae6535d6 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceOpenpyxl35Test.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceOpenpyxl35Test.php @@ -9,10 +9,7 @@ class NamespaceOpenpyxl35Test extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/namespaces.openpyxl35.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/namespaces.openpyxl35.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespacePurlTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespacePurlTest.php index 7d7ff3fe35..5e1e6a5671 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespacePurlTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespacePurlTest.php @@ -8,10 +8,7 @@ class NamespacePurlTest extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/namespacepurl.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/namespacepurl.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceStdTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceStdTest.php index 62e95b4102..ff9ef8864c 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceStdTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/NamespaceStdTest.php @@ -11,10 +11,7 @@ class NamespaceStdTest extends \PHPUnit\Framework\TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/namespacestd.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/namespacestd.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/SharedFormulaTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/SharedFormulaTest.php index b7e4532162..dfa6f34000 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/SharedFormulaTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/SharedFormulaTest.php @@ -10,10 +10,7 @@ class SharedFormulaTest extends TestCase { - /** - * @var string - */ - private static $testbook = 'samples/templates/32readwriteAreaChart1.xlsx'; + private static string $testbook = 'samples/templates/32readwriteAreaChart1.xlsx'; public function testPreliminaries(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/SplitsTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/SplitsTest.php index ddea4ae0cc..e852b0e7bb 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/SplitsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/SplitsTest.php @@ -9,10 +9,7 @@ class SplitsTest extends AbstractFunctional { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/splits.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/splits.xlsx'; public function testSplits(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxRootZipFilesTest.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxRootZipFilesTest.php index 1142c0c80e..f83e7989d4 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxRootZipFilesTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/XlsxRootZipFilesTest.php @@ -9,10 +9,7 @@ class XlsxRootZipFilesTest extends TestCase { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/XLSX/rootZipFiles.xlsx'; + private static string $testbook = 'tests/data/Reader/XLSX/rootZipFiles.xlsx'; public function testXlsxRootZipFiles(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/DataValidationsTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/DataValidationsTest.php index 151fc4235b..63810408c5 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/DataValidationsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/DataValidationsTest.php @@ -11,8 +11,7 @@ class DataValidationsTest extends AbstractFunctional { - /** @var string */ - private $filename = 'tests/data/Reader/Xml/datavalidations.xml'; + private string $filename = 'tests/data/Reader/Xml/datavalidations.xml'; public function testValidation(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php index b5d8a33d54..47d831241d 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/PageSetupTest.php @@ -18,10 +18,9 @@ class PageSetupTest extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; - /** @var string */ - private $filename = 'tests/data/Reader/Xml/PageSetup.xml'; + private string $filename = 'tests/data/Reader/Xml/PageSetup.xml'; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/SplitsTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/SplitsTest.php index 7f6b7f6fa6..3ef4238de5 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/SplitsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/SplitsTest.php @@ -9,10 +9,7 @@ class SplitsTest extends AbstractFunctional { - /** - * @var string - */ - private static $testbook = 'tests/data/Reader/Xml/splits.xml'; + private static string $testbook = 'tests/data/Reader/Xml/splits.xml'; public function testSplits(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php index befac3b9ec..cf815e5ab1 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/XmlLoadTest.php @@ -15,7 +15,7 @@ class XmlLoadTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; private string $locale; diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/XmlOddTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/XmlOddTest.php index d479449cf7..bda6fc5723 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/XmlOddTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/XmlOddTest.php @@ -10,10 +10,7 @@ class XmlOddTest extends TestCase { - /** - * @var string - */ - private $filename = ''; + private string $filename = ''; protected function teardown(): void { diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/XmlPropertiesTest.php b/tests/PhpSpreadsheetTests/Reader/Xml/XmlPropertiesTest.php index bcc23813e1..481f038a22 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/XmlPropertiesTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/XmlPropertiesTest.php @@ -10,8 +10,7 @@ class XmlPropertiesTest extends AbstractFunctional { - /** @var string */ - private $filename = 'tests/data/Reader/Xml/hyperlinkbase.xml'; + private string $filename = 'tests/data/Reader/Xml/hyperlinkbase.xml'; public function testProperties(): void { diff --git a/tests/PhpSpreadsheetTests/ReferenceHelper3Test.php b/tests/PhpSpreadsheetTests/ReferenceHelper3Test.php index 4a437a0104..a50ee92289 100644 --- a/tests/PhpSpreadsheetTests/ReferenceHelper3Test.php +++ b/tests/PhpSpreadsheetTests/ReferenceHelper3Test.php @@ -81,8 +81,7 @@ public function testCompletelyRelative(): void $spreadsheet->disconnectWorksheets(); } - /** @var bool */ - private static $sumFormulaWorking = false; + private static bool $sumFormulaWorking = false; public function testSumAboveCell(): void { diff --git a/tests/PhpSpreadsheetTests/Shared/Date2Test.php b/tests/PhpSpreadsheetTests/Shared/Date2Test.php index 7d66fe8717..687a34e230 100644 --- a/tests/PhpSpreadsheetTests/Shared/Date2Test.php +++ b/tests/PhpSpreadsheetTests/Shared/Date2Test.php @@ -13,7 +13,7 @@ class Date2Test extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; private int $calculateDateTimeType; diff --git a/tests/PhpSpreadsheetTests/Shared/FileTest.php b/tests/PhpSpreadsheetTests/Shared/FileTest.php index c4baf51ce2..e8d370e22d 100644 --- a/tests/PhpSpreadsheetTests/Shared/FileTest.php +++ b/tests/PhpSpreadsheetTests/Shared/FileTest.php @@ -12,8 +12,7 @@ class FileTest extends TestCase { private bool $uploadFlag = false; - /** @var string */ - private $tempfile = ''; + private string $tempfile = ''; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/SpreadsheetCoverageTest.php b/tests/PhpSpreadsheetTests/SpreadsheetCoverageTest.php index 196dabd336..f9a6d126c6 100644 --- a/tests/PhpSpreadsheetTests/SpreadsheetCoverageTest.php +++ b/tests/PhpSpreadsheetTests/SpreadsheetCoverageTest.php @@ -11,10 +11,10 @@ class SpreadsheetCoverageTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** @var ?Spreadsheet */ - private $spreadsheet2; + private ?Spreadsheet $spreadsheet2 = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/SpreadsheetTest.php b/tests/PhpSpreadsheetTests/SpreadsheetTest.php index fe4e986439..f7d9d86f81 100644 --- a/tests/PhpSpreadsheetTests/SpreadsheetTest.php +++ b/tests/PhpSpreadsheetTests/SpreadsheetTest.php @@ -12,7 +12,7 @@ class SpreadsheetTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Style/AlignmentMiddleTest.php b/tests/PhpSpreadsheetTests/Style/AlignmentMiddleTest.php index 2fcb719185..7e61f83a5d 100644 --- a/tests/PhpSpreadsheetTests/Style/AlignmentMiddleTest.php +++ b/tests/PhpSpreadsheetTests/Style/AlignmentMiddleTest.php @@ -15,10 +15,9 @@ class AlignmentMiddleTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; - /** @var string */ - private $outputFileName = ''; + private string $outputFileName = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Style/AlignmentTest.php b/tests/PhpSpreadsheetTests/Style/AlignmentTest.php index 0f0ba5e15d..1b93800047 100644 --- a/tests/PhpSpreadsheetTests/Style/AlignmentTest.php +++ b/tests/PhpSpreadsheetTests/Style/AlignmentTest.php @@ -12,7 +12,7 @@ class AlignmentTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalBoolTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalBoolTest.php index e4b0c7fcf8..f0d16058db 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalBoolTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalBoolTest.php @@ -14,8 +14,7 @@ class ConditionalBoolTest extends TestCase { - /** @var string */ - private $outfile = ''; + private string $outfile = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/CellMatcherTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/CellMatcherTest.php index 505991d4e4..ac0ba30d88 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/CellMatcherTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/CellMatcherTest.php @@ -17,7 +17,7 @@ class CellMatcherTest extends TestCase /** * @var ?Spreadsheet */ - protected $spreadsheet; + protected ?Spreadsheet $spreadsheet = null; protected function loadSpreadsheet(): Spreadsheet { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/BlankWizardTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/BlankWizardTest.php index 027c0674eb..d9a64fd5c0 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/BlankWizardTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/BlankWizardTest.php @@ -12,20 +12,11 @@ class BlankWizardTest extends TestCase { - /** - * @var Style - */ - protected $style; - - /** - * @var string - */ - protected $range = '$C$3:$E$5'; - - /** - * @var Wizard - */ - protected $wizardFactory; + protected Style $style; + + protected string $range = '$C$3:$E$5'; + + protected Wizard $wizardFactory; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/CellValueWizardTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/CellValueWizardTest.php index 7ccc860fc0..d16ca99ea5 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/CellValueWizardTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/CellValueWizardTest.php @@ -12,20 +12,11 @@ class CellValueWizardTest extends TestCase { - /** - * @var Style - */ - protected $style; + protected Style $style; - /** - * @var string - */ - protected $range = '$C$3:$E$5'; + protected string $range = '$C$3:$E$5'; - /** - * @var Wizard - */ - protected $wizardFactory; + protected Wizard $wizardFactory; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/DateValueWizardTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/DateValueWizardTest.php index 824066cb98..57778fc8d3 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/DateValueWizardTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/DateValueWizardTest.php @@ -12,20 +12,11 @@ class DateValueWizardTest extends TestCase { - /** - * @var Style - */ - protected $style; + protected Style $style; - /** - * @var string - */ - protected $range = '$C$3:$E$5'; + protected string $range = '$C$3:$E$5'; - /** - * @var Wizard - */ - protected $wizardFactory; + protected Wizard $wizardFactory; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/DuplicatesWizardTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/DuplicatesWizardTest.php index 2b280a7aad..8c5082a30a 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/DuplicatesWizardTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/DuplicatesWizardTest.php @@ -12,20 +12,11 @@ class DuplicatesWizardTest extends TestCase { - /** - * @var Style - */ - protected $style; - - /** - * @var string - */ - protected $range = '$C$3:$E$5'; - - /** - * @var Wizard - */ - protected $wizardFactory; + protected Style $style; + + protected string $range = '$C$3:$E$5'; + + protected Wizard $wizardFactory; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/ErrorWizardTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/ErrorWizardTest.php index b845318fe3..8026135aa7 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/ErrorWizardTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/ErrorWizardTest.php @@ -12,20 +12,11 @@ class ErrorWizardTest extends TestCase { - /** - * @var Style - */ - protected $style; - - /** - * @var string - */ - protected $range = '$C$3:$E$5'; - - /** - * @var Wizard - */ - protected $wizardFactory; + protected Style $style; + + protected string $range = '$C$3:$E$5'; + + protected Wizard $wizardFactory; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/ExpressionWizardTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/ExpressionWizardTest.php index 7ce0c2be01..770af66af1 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/ExpressionWizardTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/ExpressionWizardTest.php @@ -12,20 +12,11 @@ class ExpressionWizardTest extends TestCase { - /** - * @var Style - */ - protected $style; + protected Style $style; - /** - * @var string - */ - protected $range = '$C$3:$E$5'; + protected string $range = '$C$3:$E$5'; - /** - * @var Wizard - */ - protected $wizardFactory; + protected Wizard $wizardFactory; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/TextValueWizardTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/TextValueWizardTest.php index de6d22aafa..cd89dd347d 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/TextValueWizardTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/TextValueWizardTest.php @@ -12,20 +12,11 @@ class TextValueWizardTest extends TestCase { - /** - * @var Style - */ - protected $style; - - /** - * @var string - */ - protected $range = '$C$3:$E$5'; - - /** - * @var Wizard - */ - protected $wizardFactory; + protected Style $style; + + protected string $range = '$C$3:$E$5'; + + protected Wizard $wizardFactory; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/WizardFactoryTest.php b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/WizardFactoryTest.php index e3c71387e3..04681b39a0 100644 --- a/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/WizardFactoryTest.php +++ b/tests/PhpSpreadsheetTests/Style/ConditionalFormatting/Wizard/WizardFactoryTest.php @@ -12,10 +12,7 @@ class WizardFactoryTest extends TestCase { - /** - * @var Wizard - */ - protected $wizardFactory; + protected Wizard $wizardFactory; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/SetupTeardown.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/SetupTeardown.php index 925c97c462..ef3cfb4b3a 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/SetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/SetupTeardown.php @@ -13,17 +13,14 @@ class SetupTeardown extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; - /** - * @var int - */ - protected $maxRow = 4; + protected int $maxRow = 4; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowUndeprecatedTest.php b/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowUndeprecatedTest.php index 40f1d03e2d..66862e98de 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowUndeprecatedTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowUndeprecatedTest.php @@ -15,7 +15,7 @@ class ByColumnAndRowUndeprecatedTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Worksheet/ConditionalStyleTest.php b/tests/PhpSpreadsheetTests/Worksheet/ConditionalStyleTest.php index e884740391..44ce5bcb86 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ConditionalStyleTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ConditionalStyleTest.php @@ -11,10 +11,7 @@ class ConditionalStyleTest extends TestCase { - /** - * @var Spreadsheet - */ - protected $spreadsheet; + protected Spreadsheet $spreadsheet; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Worksheet/MergeBehaviourTest.php b/tests/PhpSpreadsheetTests/Worksheet/MergeBehaviourTest.php index 7f0b04df64..4147f86353 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/MergeBehaviourTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/MergeBehaviourTest.php @@ -10,19 +10,13 @@ class MergeBehaviourTest extends AbstractFunctional { - /** - * @var array - */ - private static $testDataRaw = [ + private static array $testDataRaw = [ [1.1, 2.2, '=ROUND(A1+B1, 1)'], [4.4, 5.5, '=ROUND(A2+B2, 1)'], ['=ROUND(A1+A2, 1)', '=ROUND(B1+B2, 1)', '=ROUND(A3+B3, 1)'], ]; - /** - * @var array - */ - private $testDataFormatted = [ + private array $testDataFormatted = [ ['=DATE(1960, 12, 19)', '=DATE(2022, 09, 15)'], ]; diff --git a/tests/PhpSpreadsheetTests/Worksheet/RemoveTest.php b/tests/PhpSpreadsheetTests/Worksheet/RemoveTest.php index 0dcab2d10d..9778aa9b0e 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/RemoveTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/RemoveTest.php @@ -21,7 +21,7 @@ public function testRemoveRow(): void 'FF00FF00', 'FF0000FF', ]; - $rowHeights = [-1, -1, 1.2, 1.3, 1.4, 1.5, -1, -1, -1]; + $rowHeights = [-1.0, -1.0, 1.2, 1.3, 1.4, 1.5, -1.0, -1.0, -1.0]; for ($row = 1; $row < 10; ++$row) { $sheet->getCell("B$row") ->getStyle() diff --git a/tests/PhpSpreadsheetTests/Worksheet/Table/SetupTeardown.php b/tests/PhpSpreadsheetTests/Worksheet/Table/SetupTeardown.php index 41bf86ed23..192e76e4c8 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/Table/SetupTeardown.php +++ b/tests/PhpSpreadsheetTests/Worksheet/Table/SetupTeardown.php @@ -13,17 +13,14 @@ class SetupTeardown extends TestCase /** * @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** * @var ?Worksheet */ - private $sheet; + private ?Worksheet $sheet = null; - /** - * @var int - */ - protected $maxRow = 4; + protected int $maxRow = 4; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php b/tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php index adf2aa19a1..4c0b86b637 100644 --- a/tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Dompdf/PaperSizeArrayTest.php @@ -12,8 +12,7 @@ class PaperSizeArrayTest extends TestCase { - /** @var string */ - private $outfile = ''; + private string $outfile = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php b/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php index 53c62ece0f..15378e12b1 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/HtmlCommentsTest.php @@ -10,10 +10,7 @@ class HtmlCommentsTest extends Functional\AbstractFunctional { - /** - * @var Spreadsheet - */ - private $spreadsheet; + private Spreadsheet $spreadsheet; public static function providerCommentRichText(): array { diff --git a/tests/PhpSpreadsheetTests/Writer/Html/ImageCopyTest.php b/tests/PhpSpreadsheetTests/Writer/Html/ImageCopyTest.php index 83e8bdf041..ddd3200919 100644 --- a/tests/PhpSpreadsheetTests/Writer/Html/ImageCopyTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Html/ImageCopyTest.php @@ -13,8 +13,7 @@ class ImageCopyTest extends Functional\AbstractFunctional { - /** @var string */ - private $xlsxFile = ''; + private string $xlsxFile = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Mpdf/ImageCopyPdfTest.php b/tests/PhpSpreadsheetTests/Writer/Mpdf/ImageCopyPdfTest.php index c9aae25b71..5fec6b5adf 100644 --- a/tests/PhpSpreadsheetTests/Writer/Mpdf/ImageCopyPdfTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Mpdf/ImageCopyPdfTest.php @@ -13,8 +13,7 @@ class ImageCopyPdfTest extends Functional\AbstractFunctional { - /** @var string */ - private $xlsxFile = ''; + private string $xlsxFile = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php index e18857e3ec..50e7bc7d58 100644 --- a/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Ods/ContentTest.php @@ -22,10 +22,7 @@ class ContentTest extends TestCase { - /** - * @var string - */ - private $samplesPath = 'tests/data/Writer/Ods'; + private string $samplesPath = 'tests/data/Writer/Ods'; private string $compatibilityMode; diff --git a/tests/PhpSpreadsheetTests/Writer/PreCalcTest.php b/tests/PhpSpreadsheetTests/Writer/PreCalcTest.php index 8dd6ee4a3f..98fc58f9cf 100644 --- a/tests/PhpSpreadsheetTests/Writer/PreCalcTest.php +++ b/tests/PhpSpreadsheetTests/Writer/PreCalcTest.php @@ -13,8 +13,7 @@ class PreCalcTest extends AbstractFunctional { - /** @var string */ - private $outfile = ''; + private string $outfile = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php index 9dc7281b69..23398bf060 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/FormulaErrTest.php @@ -13,10 +13,10 @@ class FormulaErrTest extends AbstractFunctional { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** @var ?Spreadsheet */ - private $reloadedSpreadsheet; + private ?Spreadsheet $reloadedSpreadsheet = null; private bool $allowThrow; diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/ParserTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/ParserTest.php index 9a283ddbee..73e7239ce0 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/ParserTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/ParserTest.php @@ -12,7 +12,7 @@ class ParserTest extends TestCase { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php index 532f22b0be..01a68974e7 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php @@ -12,13 +12,10 @@ class WorkbookTest extends TestCase { - /** - * @var Workbook - */ - private $workbook; + private Workbook $workbook; /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php b/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php index 5f9c5d91d6..74901dd40c 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xls/XlsGifBmpTest.php @@ -13,10 +13,7 @@ class XlsGifBmpTest extends AbstractFunctional { - /** - * @var string - */ - private $filename = ''; + private string $filename = ''; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/CalculationErrorTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/CalculationErrorTest.php index 9b61bf6360..85d246fb00 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/CalculationErrorTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/CalculationErrorTest.php @@ -12,10 +12,10 @@ class CalculationErrorTest extends AbstractFunctional { /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** @var ?Spreadsheet */ - private $reloadedSpreadsheet; + private ?Spreadsheet $reloadedSpreadsheet = null; protected function tearDown(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/ConditionalTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/ConditionalTest.php index bceed1050f..a8616aada9 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/ConditionalTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/ConditionalTest.php @@ -14,15 +14,9 @@ class ConditionalTest extends AbstractFunctional { - /** - * @var string - */ - protected $cellRange; + protected string $cellRange; - /** - * @var Style - */ - protected $style; + protected Style $style; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php index 185154e1bd..e4fe3690ae 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/LocaleFloatsTest.php @@ -17,10 +17,10 @@ class LocaleFloatsTest extends AbstractFunctional private $currentLocale; /** @var ?Spreadsheet */ - private $spreadsheet; + private ?Spreadsheet $spreadsheet = null; /** @var ?Spreadsheet */ - private $reloadedSpreadsheet; + private ?Spreadsheet $reloadedSpreadsheet = null; protected function setUp(): void { diff --git a/tests/PhpSpreadsheetTests/Writer/Xlsx/Unparsed2396Test.php b/tests/PhpSpreadsheetTests/Writer/Xlsx/Unparsed2396Test.php index a27758b38c..549b5a164f 100644 --- a/tests/PhpSpreadsheetTests/Writer/Xlsx/Unparsed2396Test.php +++ b/tests/PhpSpreadsheetTests/Writer/Xlsx/Unparsed2396Test.php @@ -13,8 +13,7 @@ class Unparsed2396Test extends TestCase { - /** @var string */ - private $filename = ''; + private string $filename = ''; protected function tearDown(): void { From 5d716b7908f6d9d113a8d3e342fc9b83c7be4cdd Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 10 Dec 2023 10:01:04 +0100 Subject: [PATCH 06/25] Apply PhpCsFixer `phpdoc_to_return_type` --- phpstan-baseline.neon | 25 +++- samples/Pdf/mpdf2.inc | 4 +- .../Calculation/Calculation.php | 61 +++------ src/PhpSpreadsheet/Calculation/Database.php | 4 +- src/PhpSpreadsheet/Calculation/DateTime.php | 14 +- .../Calculation/DateTimeExcel/Current.php | 4 +- .../Calculation/DateTimeExcel/Date.php | 2 +- .../Calculation/DateTimeExcel/DateValue.php | 4 +- .../Calculation/DateTimeExcel/Helpers.php | 2 +- .../Engine/CyclicReferenceStack.php | 2 +- .../Calculation/Engine/Logger.php | 2 +- .../Calculation/Engineering.php | 4 +- .../Calculation/Engineering/BitWise.php | 8 +- .../Calculation/Engineering/ConvertUOM.php | 4 +- src/PhpSpreadsheet/Calculation/Financial.php | 4 +- .../Calculation/FormulaParser.php | 6 +- .../Calculation/FormulaToken.php | 12 +- src/PhpSpreadsheet/Calculation/Functions.php | 17 +-- src/PhpSpreadsheet/Calculation/Logical.php | 8 +- .../Calculation/Logical/Conditional.php | 8 +- src/PhpSpreadsheet/Calculation/LookupRef.php | 16 +-- .../Calculation/LookupRef/HLookup.php | 2 +- .../Calculation/LookupRef/Hyperlink.php | 2 +- .../Calculation/LookupRef/Lookup.php | 2 +- .../Calculation/LookupRef/Matrix.php | 5 +- .../Calculation/LookupRef/Selection.php | 2 +- .../Calculation/LookupRef/Sort.php | 4 +- .../Calculation/LookupRef/Unique.php | 2 +- .../Calculation/LookupRef/VLookup.php | 2 +- .../Calculation/Statistical.php | 20 +-- .../Calculation/Statistical/MaxMinBase.php | 5 +- .../Calculation/Statistical/Maximum.php | 8 +- .../Calculation/Statistical/Minimum.php | 8 +- .../Calculation/Statistical/Trends.php | 4 +- .../Calculation/Statistical/VarianceBase.php | 10 +- .../Calculation/TextData/Format.php | 4 +- src/PhpSpreadsheet/Calculation/Web.php | 2 +- .../Calculation/Web/Service.php | 2 +- src/PhpSpreadsheet/Cell/Cell.php | 18 +-- src/PhpSpreadsheet/Cell/Coordinate.php | 18 +-- src/PhpSpreadsheet/Cell/DataType.php | 2 +- src/PhpSpreadsheet/Cell/DataValidation.php | 44 ++----- .../Cell/DefaultValueBinder.php | 4 +- src/PhpSpreadsheet/Cell/Hyperlink.php | 8 +- src/PhpSpreadsheet/Chart/Chart.php | 18 +-- src/PhpSpreadsheet/Chart/DataSeries.php | 20 +-- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 24 +--- src/PhpSpreadsheet/Chart/Layout.php | 16 +-- src/PhpSpreadsheet/Chart/Legend.php | 10 +- src/PhpSpreadsheet/Chart/PlotArea.php | 10 +- src/PhpSpreadsheet/Chart/Properties.php | 34 ++--- src/PhpSpreadsheet/Chart/Title.php | 4 +- src/PhpSpreadsheet/Collection/Cells.php | 14 +- .../Collection/Memory/SimpleCache1.php | 33 ++--- src/PhpSpreadsheet/Document/Properties.php | 16 +-- src/PhpSpreadsheet/HashTable.php | 6 +- src/PhpSpreadsheet/Helper/Html.php | 4 +- src/PhpSpreadsheet/Reader/Html.php | 8 +- src/PhpSpreadsheet/Reader/Slk.php | 12 +- src/PhpSpreadsheet/Reader/Xls.php | 14 +- src/PhpSpreadsheet/Reader/Xls/Color.php | 2 +- src/PhpSpreadsheet/Reader/Xls/RC4.php | 4 +- .../Reader/Xls/Style/FillPattern.php | 4 +- src/PhpSpreadsheet/Reader/Xlsx.php | 8 +- src/PhpSpreadsheet/Reader/Xlsx/Styles.php | 4 +- src/PhpSpreadsheet/Reader/Xlsx/Theme.php | 12 +- src/PhpSpreadsheet/ReferenceHelper.php | 6 +- src/PhpSpreadsheet/RichText/RichText.php | 2 +- src/PhpSpreadsheet/Shared/Date.php | 2 +- src/PhpSpreadsheet/Shared/Escher.php | 12 +- .../DgContainer/SpgrContainer/SpContainer.php | 36 ++--- .../Shared/Escher/DggContainer.php | 22 +--- .../Escher/DggContainer/BstoreContainer.php | 2 +- .../DggContainer/BstoreContainer/BSE.php | 6 +- .../DggContainer/BstoreContainer/BSE/Blip.php | 4 +- src/PhpSpreadsheet/Shared/Font.php | 10 +- src/PhpSpreadsheet/Shared/OLE.php | 14 +- .../Shared/OLE/ChainedBlockStream.php | 4 +- src/PhpSpreadsheet/Shared/OLE/PPS.php | 6 +- src/PhpSpreadsheet/Shared/StringHelper.php | 6 +- src/PhpSpreadsheet/Shared/Trend/BestFit.php | 70 +++------- .../Shared/Trend/LinearBestFit.php | 4 +- .../Shared/Trend/PolynomialBestFit.php | 12 +- src/PhpSpreadsheet/Shared/Trend/Trend.php | 4 +- src/PhpSpreadsheet/Shared/XMLWriter.php | 4 +- src/PhpSpreadsheet/Shared/Xls.php | 2 +- src/PhpSpreadsheet/Spreadsheet.php | 108 +++++---------- src/PhpSpreadsheet/Style/Border.php | 12 +- src/PhpSpreadsheet/Style/Borders.php | 48 ++----- src/PhpSpreadsheet/Style/Color.php | 4 +- src/PhpSpreadsheet/Style/Conditional.php | 22 +--- .../ConditionalDataBarExtension.php | 35 +---- .../ConditionalFormattingRuleExtension.php | 5 +- src/PhpSpreadsheet/Style/Fill.php | 20 +-- src/PhpSpreadsheet/Style/Font.php | 40 ++---- src/PhpSpreadsheet/Style/NumberFormat.php | 14 +- .../Style/NumberFormat/Formatter.php | 2 +- src/PhpSpreadsheet/Style/Protection.php | 4 +- src/PhpSpreadsheet/Style/Style.php | 28 +--- src/PhpSpreadsheet/Style/Supervisor.php | 20 +-- .../Worksheet/AutoFilter/Column.php | 24 +--- .../Worksheet/AutoFilter/Column/Rule.php | 14 +- src/PhpSpreadsheet/Worksheet/Drawing.php | 4 +- .../Worksheet/Drawing/Shadow.php | 28 +--- src/PhpSpreadsheet/Worksheet/HeaderFooter.php | 40 ++---- .../Worksheet/MemoryDrawing.php | 8 +- src/PhpSpreadsheet/Worksheet/PageMargins.php | 24 +--- src/PhpSpreadsheet/Worksheet/PageSetup.php | 42 ++---- src/PhpSpreadsheet/Worksheet/Protection.php | 4 +- src/PhpSpreadsheet/Worksheet/RowDimension.php | 4 +- src/PhpSpreadsheet/Worksheet/SheetView.php | 13 +- src/PhpSpreadsheet/Worksheet/Worksheet.php | 124 ++++++------------ src/PhpSpreadsheet/Writer/Html.php | 40 ++---- src/PhpSpreadsheet/Writer/Ods.php | 4 +- src/PhpSpreadsheet/Writer/Ods/WriterPart.php | 4 +- src/PhpSpreadsheet/Writer/Pdf.php | 22 +--- src/PhpSpreadsheet/Writer/Pdf/Dompdf.php | 2 +- src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 2 +- src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 2 +- src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php | 10 +- src/PhpSpreadsheet/Writer/Xls/Escher.php | 12 +- src/PhpSpreadsheet/Writer/Xls/Font.php | 4 +- src/PhpSpreadsheet/Writer/Xls/Parser.php | 12 +- src/PhpSpreadsheet/Writer/Xls/Workbook.php | 12 +- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 6 +- src/PhpSpreadsheet/Writer/Xls/Xf.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx.php | 24 ++-- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Comments.php | 4 +- .../Writer/Xlsx/ContentTypes.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/DocProps.php | 6 +- src/PhpSpreadsheet/Writer/Xlsx/Drawing.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 10 +- src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php | 2 +- .../Writer/Xlsx/StringTable.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Style.php | 6 +- src/PhpSpreadsheet/Writer/Xlsx/Theme.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Workbook.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php | 4 +- ...ueBinderWithOverriddenDataTypeForValue.php | 2 +- .../Functional/AbstractFunctional.php | 4 +- 143 files changed, 563 insertions(+), 1238 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 02b3e86709..a5573ea05d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1165,11 +1165,6 @@ parameters: count: 1 path: src/PhpSpreadsheet/Chart/DataSeriesValues.php - - - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\DataSeriesValues\\:\\:getDataValues\\(\\) should return array but returns array\\|null\\.$#" - count: 1 - path: src/PhpSpreadsheet/Chart/DataSeriesValues.php - - message: "#^Offset 0 does not exist on array\\|null\\.$#" count: 1 @@ -1180,6 +1175,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Chart/DataSeriesValues.php + - + message: "#^Cannot access property \\$color on SimpleXMLElement\\|null\\.$#" + count: 2 + path: src/PhpSpreadsheet/Reader/Xlsx/Styles.php + - message: "#^Cannot call method beforeCellAddress\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\CellReferenceHelper\\|null\\.$#" count: 1 @@ -1205,11 +1205,26 @@ parameters: count: 1 path: src/PhpSpreadsheet/Worksheet/Validations.php + - + message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#" + count: 3 + path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php + - message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Xlsx\\\\Chart\\:\\:getChartType\\(\\) should return array\\ but returns array\\, string\\|null\\>\\.$#" count: 1 path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php + - + message: "#^Parameter \\#2 \\$array of function array_key_exists expects array, array\\|null given\\.$#" + count: 1 + path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php + + - + message: "#^Offset 0 does not exist on array\\|null\\.$#" + count: 1 + path: tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3767Test.php + - message: "#^Parameter \\#2 \\$value of function ini_set expects string, int given\\.$#" count: 1 diff --git a/samples/Pdf/mpdf2.inc b/samples/Pdf/mpdf2.inc index 749bcd01e1..3ebb22bc64 100644 --- a/samples/Pdf/mpdf2.inc +++ b/samples/Pdf/mpdf2.inc @@ -17,10 +17,8 @@ class Mpdf2 extends Mpdf * Other configuration options may be specified here. * * @param array $config Configuration array - * - * @return \Mpdf\Mpdf implementation */ - protected function createExternalWriterInstance($config) + protected function createExternalWriterInstance($config): \Mpdf\Mpdf { $defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults(); $fontDirs = $defaultConfig['fontDir']; diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 4156051a52..d7b1a56afd 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -216,8 +216,7 @@ public static function keyInExcelConstants(string $key): bool return array_key_exists($key, self::$excelConstants); } - /** @return mixed */ - public static function getExcelConstants(string $key) + public static function getExcelConstants(string $key): mixed { return self::$excelConstants[$key]; } @@ -2938,10 +2937,8 @@ public function flushInstance(): void /** * Get the Logger for this calculation engine instance. - * - * @return Logger */ - public function getDebugLog() + public function getDebugLog(): Logger { return $this->debugLog; } @@ -3001,17 +2998,15 @@ public static function setArrayReturnType($returnType): bool * * @return string $returnType Array return type */ - public static function getArrayReturnType() + public static function getArrayReturnType(): string { return self::$returnArrayAsType; } /** * Is calculation caching enabled? - * - * @return bool */ - public function getCalculationCacheEnabled() + public function getCalculationCacheEnabled(): bool { return $this->calculationCacheEnabled; } @@ -3098,10 +3093,8 @@ public function disableBranchPruning(): void /** * Get the currently defined locale code. - * - * @return string */ - public function getLocale() + public function getLocale(): string { return self::$localeLanguage; } @@ -3365,10 +3358,8 @@ public function _translateFormulaToEnglish(string $formula): string /** * @param string $function - * - * @return string */ - public static function localeFunc($function) + public static function localeFunc($function): string { if (self::$localeLanguage !== 'en_us') { $functionName = trim($function, '('); @@ -3386,10 +3377,8 @@ public static function localeFunc($function) /** * Wrap string values in quotes. - * - * @return mixed */ - public static function wrapResult(mixed $value) + public static function wrapResult(mixed $value): mixed { if (is_string($value)) { // Error values cannot be "wrapped" @@ -3410,10 +3399,8 @@ public static function wrapResult(mixed $value) /** * Remove quotes used as a wrapper to identify string values. - * - * @return mixed */ - public static function unwrapResult(mixed $value) + public static function unwrapResult(mixed $value): mixed { if (is_string($value)) { if ((isset($value[0])) && ($value[0] == self::FORMULA_STRING_QUOTE) && (substr($value, -1) == self::FORMULA_STRING_QUOTE)) { @@ -3432,10 +3419,8 @@ public static function unwrapResult(mixed $value) * Retained for backward compatibility. * * @param Cell $cell Cell to calculate - * - * @return mixed */ - public function calculate(?Cell $cell = null) + public function calculate(?Cell $cell = null): mixed { try { return $this->calculateCellValue($cell); @@ -3449,10 +3434,8 @@ public function calculate(?Cell $cell = null) * * @param Cell $cell Cell to calculate * @param bool $resetLog Flag indicating whether the debug log should be reset or not - * - * @return mixed */ - public function calculateCellValue(?Cell $cell = null, $resetLog = true) + public function calculateCellValue(?Cell $cell = null, $resetLog = true): mixed { if ($cell === null) { return null; @@ -3572,10 +3555,8 @@ public function parseFormula($formula) * @param string $formula Formula to parse * @param string $cellID Address of the cell to calculate * @param Cell $cell Cell to calculate - * - * @return mixed */ - public function calculateFormula($formula, $cellID = null, ?Cell $cell = null) + public function calculateFormula($formula, $cellID = null, ?Cell $cell = null): mixed { // Initialise the logging settings $this->formulaError = null; @@ -3641,10 +3622,8 @@ public function saveValueToCache($cellReference, mixed $cellValue): void * @param string $cellID The ID (e.g. A3) of the cell that we are calculating * @param Cell $cell Cell to calculate * @param bool $ignoreQuotePrefix If set to true, evaluate the formyla even if the referenced cell is quote prefixed - * - * @return mixed */ - public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false) + public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false): mixed { $cellValue = null; @@ -3875,10 +3854,8 @@ private static function resizeMatricesExtend(array &$matrix1, array &$matrix2, $ * Format details of an operand for display in the log (based on operand type). * * @param mixed $value First matrix operand - * - * @return mixed */ - private function showValue(mixed $value) + private function showValue(mixed $value): mixed { if ($this->debugLog->getWriteDebugLog()) { $testArray = Functions::flattenArray($value); @@ -4536,10 +4513,7 @@ private function internalParseFormula($formula, ?Cell $cell = null): bool|array return $output; } - /** - * @return mixed - */ - private static function dataTestReference(array &$operandData) + private static function dataTestReference(array &$operandData): mixed { $operand = $operandData['value']; if (($operandData['reference'] === null) && (is_array($operand))) { @@ -5565,7 +5539,7 @@ private function addDefaultArgumentValues(array $functionCall, array $args, arra /** * @return null|mixed */ - private function getArgumentDefaultValue(ReflectionParameter $methodArgument) + private function getArgumentDefaultValue(ReflectionParameter $methodArgument): mixed { $defaultValue = null; @@ -5678,10 +5652,7 @@ public function getSuppressFormulaErrors(): bool return $this->suppressFormulaErrorsNew; } - /** - * @return mixed - */ - private static function boolToString(mixed $operand1) + private static function boolToString(mixed $operand1): mixed { if (is_bool($operand1)) { $operand1 = ($operand1) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE']; diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php index 547d6062c3..40a2926f07 100644 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ b/src/PhpSpreadsheet/Calculation/Database.php @@ -138,10 +138,8 @@ public static function DCOUNTA($database, $field, $criteria): string|int * 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 mixed */ - public static function DGET($database, $field, $criteria) + public static function DGET($database, $field, $criteria): mixed { return Database\DGet::evaluate($database, $field, $criteria); } diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 81169f4d59..589f75d9a8 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -64,7 +64,7 @@ public static function getDateValue(mixed $dateValue): float|string * @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 */ - public static function DATETIMENOW() + public static function DATETIMENOW(): mixed { return DateTimeExcel\Current::now(); } @@ -90,7 +90,7 @@ public static function DATETIMENOW() * @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 */ - public static function DATENOW() + public static function DATENOW(): mixed { return DateTimeExcel\Current::today(); } @@ -149,7 +149,7 @@ public static function DATENOW() * @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 */ - public static function DATE($year = 0, $month = 1, $day = 1) + public static function DATE($year = 0, $month = 1, $day = 1): mixed { return DateTimeExcel\Date::fromYMD($year, $month, $day); } @@ -218,7 +218,7 @@ public static function TIME($hour = 0, $minute = 0, $second = 0): string|float|i * @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 */ - public static function DATEVALUE($dateValue) + public static function DATEVALUE($dateValue): mixed { return DateTimeExcel\DateValue::fromString($dateValue); } @@ -424,7 +424,7 @@ public static function NETWORKDAYS(mixed $startDate, mixed $endDate, mixed ...$d * @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 */ - public static function WORKDAY(mixed $startDate, $endDays, mixed ...$dateArgs) + public static function WORKDAY(mixed $startDate, $endDays, mixed ...$dateArgs): mixed { return DateTimeExcel\WorkDay::date($startDate, $endDays, ...$dateArgs); } @@ -851,7 +851,7 @@ public static function SECOND(mixed $timeValue = 0): string|int|array * @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 */ - public static function EDATE(mixed $dateValue = 1, $adjustmentMonths = 0) + public static function EDATE(mixed $dateValue = 1, $adjustmentMonths = 0): mixed { return DateTimeExcel\Month::adjust($dateValue, $adjustmentMonths); } @@ -879,7 +879,7 @@ public static function EDATE(mixed $dateValue = 1, $adjustmentMonths = 0) * @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 */ - public static function EOMONTH(mixed $dateValue = 1, $adjustmentMonths = 0) + public static function EOMONTH(mixed $dateValue = 1, $adjustmentMonths = 0): mixed { return DateTimeExcel\Month::lastDay($dateValue, $adjustmentMonths); } diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Current.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Current.php index 5de671d3cb..20b48969be 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Current.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Current.php @@ -24,7 +24,7 @@ class Current * @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 */ - public static function today() + public static function today(): mixed { $dti = new DateTimeImmutable(); $dateArray = Helpers::dateParse($dti->format('c')); @@ -49,7 +49,7 @@ public static function today() * @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 */ - public static function now() + public static function now(): mixed { $dti = new DateTimeImmutable(); $dateArray = Helpers::dateParse($dti->format('c')); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php index 040cca954d..b3d7f47383 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php @@ -63,7 +63,7 @@ class Date * If an array of numbers is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function fromYMD($year, $month, $day) + public static function fromYMD($year, $month, $day): mixed { if (is_array($year) || is_array($month) || is_array($day)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $year, $month, $day); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php index 0cb2277843..1093d732be 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php @@ -39,7 +39,7 @@ class DateValue * If an array of numbers is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function fromString($dateValue) + public static function fromString($dateValue): mixed { if (is_array($dateValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $dateValue); @@ -134,7 +134,7 @@ private static function setUpArray(string $dateValue, DateTimeImmutable $dti): a * @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 */ - private static function finalResults(array $PHPDateArray, DateTimeImmutable $dti, int $baseYear) + private static function finalResults(array $PHPDateArray, DateTimeImmutable $dti, int $baseYear): mixed { $retValue = ExcelError::Value(); if (Helpers::dateParseSucceeded($PHPDateArray)) { diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index 9082b48449..58dc9fd030 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -62,7 +62,7 @@ public static function getDateValue(mixed $dateValue, bool $allowBool = true): f * * @return mixed Excel date/time serial value, or string if error */ - public static function getTimeValue($timeValue) + public static function getTimeValue($timeValue): mixed { $saveReturnDateType = Functions::getReturnDateType(); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); diff --git a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php index b13865761f..f4806b477b 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php +++ b/src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php @@ -58,7 +58,7 @@ public function clear(): void * * @return mixed[] */ - public function showStack() + public function showStack(): array { return $this->stack; } diff --git a/src/PhpSpreadsheet/Calculation/Engine/Logger.php b/src/PhpSpreadsheet/Calculation/Engine/Logger.php index 20f8e92c0a..35242aaf90 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/Logger.php +++ b/src/PhpSpreadsheet/Calculation/Engine/Logger.php @@ -123,7 +123,7 @@ public function clearLog(): void * * @return string[] */ - public function getLog() + public function getLog(): array { return $this->debugLog; } diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 1479fab2a7..0725512ba7 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -1351,7 +1351,7 @@ public static function getConversionGroupUnitDetails($category = null): array * * @return mixed[] */ - public static function getConversionMultipliers() + public static function getConversionMultipliers(): array { return Engineering\ConvertUOM::getConversionMultipliers(); } @@ -1368,7 +1368,7 @@ public static function getConversionMultipliers() * * @return mixed[] */ - public static function getBinaryConversionMultipliers() + public static function getBinaryConversionMultipliers(): array { return Engineering\ConvertUOM::getBinaryConversionMultipliers(); } diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php index f3e6ed2545..2cbc8ffc03 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php @@ -232,10 +232,8 @@ private static function validateBitwiseArgument(mixed $value): float /** * Validate arguments passed to the bitwise functions. - * - * @return int */ - private static function validateShiftAmount(mixed $value) + private static function validateShiftAmount(mixed $value): int { $value = self::nullFalseTrueToNumber($value); @@ -252,10 +250,8 @@ private static function validateShiftAmount(mixed $value) /** * Many functions accept null/false/true argument treated as 0/0/1. - * - * @return mixed */ - private static function nullFalseTrueToNumber(mixed &$number) + private static function nullFalseTrueToNumber(mixed &$number): mixed { if ($number === null) { $number = 0; diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php index ac4787fda4..ada0aaa804 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php @@ -490,7 +490,7 @@ public static function getConversionCategoryUnitDetails($category = null): array * * @return mixed[] */ - public static function getConversionMultipliers() + public static function getConversionMultipliers(): array { return self::$conversionMultipliers; } @@ -501,7 +501,7 @@ public static function getConversionMultipliers() * * @return mixed[] */ - public static function getBinaryConversionMultipliers() + public static function getBinaryConversionMultipliers(): array { return self::$binaryConversionMultipliers; } diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index c17fcbf697..9e299a57d2 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -867,10 +867,8 @@ public static function NPER($rate = 0, $pmt = 0, $pv = 0, $fv = 0, $type = 0) * @see Financial\CashFlow\Variable\Periodic::presentValue() * * @param array $args - * - * @return float */ - public static function NPV(...$args) + public static function NPV(...$args): float { return Financial\CashFlow\Variable\Periodic::presentValue(...$args); } diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index 40dfe52391..12938a5abc 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -76,10 +76,8 @@ public function __construct($formula = '') /** * Get Formula. - * - * @return string */ - public function getFormula() + public function getFormula(): string { return $this->formula; } @@ -111,7 +109,7 @@ public function getTokenCount(): int * * @return FormulaToken[] */ - public function getTokens() + public function getTokens(): array { return $this->tokens; } diff --git a/src/PhpSpreadsheet/Calculation/FormulaToken.php b/src/PhpSpreadsheet/Calculation/FormulaToken.php index 8186a06703..ab6c09c7e6 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaToken.php +++ b/src/PhpSpreadsheet/Calculation/FormulaToken.php @@ -84,10 +84,8 @@ public function __construct($value, $tokenType = self::TOKEN_TYPE_UNKNOWN, $toke /** * Get Value. - * - * @return string */ - public function getValue() + public function getValue(): string { return $this->value; } @@ -104,10 +102,8 @@ public function setValue($value): void /** * Get Token Type (represented by TOKEN_TYPE_*). - * - * @return string */ - public function getTokenType() + public function getTokenType(): string { return $this->tokenType; } @@ -124,10 +120,8 @@ public function setTokenType($value): void /** * Get Token SubType (represented by TOKEN_SUBTYPE_*). - * - * @return string */ - public function getTokenSubType() + public function getTokenSubType(): string { return $this->tokenSubType; } diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 33a79ed606..14de737093 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -71,7 +71,7 @@ public static function setCompatibilityMode($compatibilityMode): bool * Functions::COMPATIBILITY_GNUMERIC 'Gnumeric' * Functions::COMPATIBILITY_OPENOFFICE 'OpenOfficeCalc' */ - public static function getCompatibilityMode() + public static function getCompatibilityMode(): string { return self::$compatibilityMode; } @@ -111,7 +111,7 @@ public static function setReturnDateType($returnDateType): bool * Functions::RETURNDATE_PHP_DATETIME_OBJECT 'O' * Functions::RETURNDATE_EXCEL ' 'E' */ - public static function getReturnDateType() + public static function getReturnDateType(): string { return self::$returnDateType; } @@ -176,10 +176,7 @@ public static function ifCondition(mixed $condition): string return str_replace('""""', '""', $operator . $operand); } - /** - * @return mixed - */ - private static function operandSpecialHandling(mixed $operand) + private static function operandSpecialHandling(mixed $operand): mixed { if (is_numeric($operand) || is_bool($operand)) { return $operand; @@ -549,7 +546,7 @@ public static function flattenArray($array): array /** * @return null|mixed */ - public static function scalar(mixed $value) + public static function scalar(mixed $value): mixed { if (!is_array($value)) { return $value; @@ -569,7 +566,7 @@ public static function scalar(mixed $value) * * @return array Flattened array */ - public static function flattenArrayIndexed($array) + public static function flattenArrayIndexed($array): array { if (!is_array($array)) { return (array) $array; @@ -599,10 +596,8 @@ public static function flattenArrayIndexed($array) * Convert an array to a single scalar value by extracting the first element. * * @param mixed $value Array or scalar value - * - * @return mixed */ - public static function flattenSingleValue(mixed $value = '') + public static function flattenSingleValue(mixed $value = ''): mixed { while (is_array($value)) { $value = array_shift($value); diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php index 5f2996360a..3532cb1403 100644 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ b/src/PhpSpreadsheet/Calculation/Logical.php @@ -199,7 +199,7 @@ public static function NOT(mixed $logical = false): bool|string|array * * @return mixed The value of returnIfTrue or returnIfFalse determined by condition */ - public static function statementIf(mixed $condition = true, mixed $returnIfTrue = 0, mixed $returnIfFalse = false) + public static function statementIf(mixed $condition = true, mixed $returnIfTrue = 0, mixed $returnIfFalse = false): mixed { return Logical\Conditional::statementIf($condition, $returnIfTrue, $returnIfFalse); } @@ -232,7 +232,7 @@ public static function statementIf(mixed $condition = true, mixed $returnIfTrue * * @return mixed The value of matched expression */ - public static function statementSwitch(mixed ...$arguments) + public static function statementSwitch(mixed ...$arguments): mixed { return Logical\Conditional::statementSwitch(...$arguments); } @@ -252,7 +252,7 @@ public static function statementSwitch(mixed ...$arguments) * * @return mixed The value of errorpart or testValue determined by error condition */ - public static function IFERROR(mixed $testValue = '', mixed $errorpart = '') + public static function IFERROR(mixed $testValue = '', mixed $errorpart = ''): mixed { return Logical\Conditional::IFERROR($testValue, $errorpart); } @@ -272,7 +272,7 @@ public static function IFERROR(mixed $testValue = '', mixed $errorpart = '') * * @return mixed The value of errorpart or testValue determined by error condition */ - public static function IFNA(mixed $testValue = '', mixed $napart = '') + public static function IFNA(mixed $testValue = '', mixed $napart = ''): mixed { return Logical\Conditional::IFNA($testValue, $napart); } diff --git a/src/PhpSpreadsheet/Calculation/Logical/Conditional.php b/src/PhpSpreadsheet/Calculation/Logical/Conditional.php index 2fdd6498d1..9ac36c5b21 100644 --- a/src/PhpSpreadsheet/Calculation/Logical/Conditional.php +++ b/src/PhpSpreadsheet/Calculation/Logical/Conditional.php @@ -46,7 +46,7 @@ class Conditional * * @return mixed The value of returnIfTrue or returnIfFalse determined by condition */ - public static function statementIf(mixed $condition = true, mixed $returnIfTrue = 0, mixed $returnIfFalse = false) + public static function statementIf(mixed $condition = true, mixed $returnIfTrue = 0, mixed $returnIfFalse = false): mixed { $condition = ($condition === null) ? true : Functions::flattenSingleValue($condition); @@ -86,7 +86,7 @@ public static function statementIf(mixed $condition = true, mixed $returnIfTrue * * @return mixed The value of matched expression */ - public static function statementSwitch(mixed ...$arguments) + public static function statementSwitch(mixed ...$arguments): mixed { $result = ExcelError::VALUE(); @@ -132,7 +132,7 @@ public static function statementSwitch(mixed ...$arguments) * 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 IFERROR(mixed $testValue = '', mixed $errorpart = '') + public static function IFERROR(mixed $testValue = '', mixed $errorpart = ''): mixed { if (is_array($testValue)) { return self::evaluateArrayArgumentsSubset([self::class, __FUNCTION__], 1, $testValue, $errorpart); @@ -159,7 +159,7 @@ public static function IFERROR(mixed $testValue = '', mixed $errorpart = '') * 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 IFNA(mixed $testValue = '', mixed $napart = '') + public static function IFNA(mixed $testValue = '', mixed $napart = ''): mixed { if (is_array($testValue)) { return self::evaluateArrayArgumentsSubset([self::class, __FUNCTION__], 1, $testValue, $napart); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 9b71cfb38e..0a3a372db9 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -158,7 +158,7 @@ public static function ROWS($cellAddress = null) * * @return string The value of $displayName (or $linkURL if $displayName was blank) */ - public static function HYPERLINK(mixed $linkURL = '', mixed $displayName = null, ?Cell $cell = null) + public static function HYPERLINK(mixed $linkURL = '', mixed $displayName = null, ?Cell $cell = null): string { return LookupRef\Hyperlink::set($linkURL, $displayName, $cell); } @@ -244,7 +244,7 @@ public static function OFFSET($cellAddress = null, mixed $rows = 0, mixed $colum * * @return mixed The selected value */ - public static function CHOOSE(...$chooseArgs) + public static function CHOOSE(...$chooseArgs): mixed { return LookupRef\Selection::choose(...$chooseArgs); } @@ -292,7 +292,7 @@ public static function MATCH(mixed $lookupValue, mixed $lookupArray, mixed $matc * * @return mixed the value of a specified cell or array of cells */ - public static function INDEX(mixed $matrix, mixed $rowNum = 0, mixed $columnNum = 0) + public static function INDEX(mixed $matrix, mixed $rowNum = 0, mixed $columnNum = 0): mixed { return Matrix::index($matrix, $rowNum, $columnNum); } @@ -333,7 +333,7 @@ public static function TRANSPOSE($matrixData): array * * @return mixed The value of the found cell */ - public static function VLOOKUP(mixed $lookup_value, mixed $lookup_array, mixed $index_number, mixed $not_exact_match = true) + public static function VLOOKUP(mixed $lookup_value, mixed $lookup_array, mixed $index_number, mixed $not_exact_match = true): mixed { return VLookup::lookup($lookup_value, $lookup_array, $index_number, $not_exact_match); } @@ -355,7 +355,7 @@ public static function VLOOKUP(mixed $lookup_value, mixed $lookup_array, mixed $ * * @return mixed The value of the found cell */ - public static function HLOOKUP(mixed $lookup_value, mixed $lookup_array, mixed $index_number, mixed $not_exact_match = true) + public static function HLOOKUP(mixed $lookup_value, mixed $lookup_array, mixed $index_number, mixed $not_exact_match = true): mixed { return HLookup::lookup($lookup_value, $lookup_array, $index_number, $not_exact_match); } @@ -374,7 +374,7 @@ public static function HLOOKUP(mixed $lookup_value, mixed $lookup_array, mixed $ * * @return mixed The value of the found cell */ - public static function LOOKUP(mixed $lookup_value, mixed $lookup_vector, $result_vector = null) + public static function LOOKUP(mixed $lookup_value, mixed $lookup_vector, $result_vector = null): mixed { return Lookup::lookup($lookup_value, $lookup_vector, $result_vector); } @@ -388,10 +388,8 @@ public static function LOOKUP(mixed $lookup_value, mixed $lookup_vector, $result * * @param mixed $cellReference The cell to check * @param Cell $cell The current cell (containing this formula) - * - * @return string */ - public static function FORMULATEXT(mixed $cellReference = '', ?Cell $cell = null) + public static function FORMULATEXT(mixed $cellReference = '', ?Cell $cell = null): string { return LookupRef\Formula::text($cellReference, $cell); } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/HLookup.php b/src/PhpSpreadsheet/Calculation/LookupRef/HLookup.php index 9e09e3d434..fd83700b4b 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/HLookup.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/HLookup.php @@ -25,7 +25,7 @@ class HLookup extends LookupBase * * @return mixed The value of the found cell */ - public static function lookup(mixed $lookupValue, mixed $lookupArray, mixed $indexNumber, mixed $notExactMatch = true) + public static function lookup(mixed $lookupValue, mixed $lookupArray, mixed $indexNumber, mixed $notExactMatch = true): mixed { if (is_array($lookupValue) || is_array($indexNumber)) { return self::evaluateArrayArgumentsIgnore([self::class, __FUNCTION__], 1, $lookupValue, $lookupArray, $indexNumber, $notExactMatch); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php b/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php index a199d5b0f5..63e7549d2f 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php @@ -20,7 +20,7 @@ class Hyperlink * * @return mixed The value of $displayName (or $linkURL if $displayName was blank) */ - public static function set(mixed $linkURL = '', mixed $displayName = null, ?Cell $cell = null) + public static function set(mixed $linkURL = '', mixed $displayName = null, ?Cell $cell = null): mixed { $linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL); $displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php b/src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php index 147c982f9f..5be8417843 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php @@ -20,7 +20,7 @@ class Lookup * * @return mixed The value of the found cell */ - public static function lookup(mixed $lookupValue, mixed $lookupVector, $resultVector = null) + public static function lookup(mixed $lookupValue, mixed $lookupVector, $resultVector = null): mixed { if (is_array($lookupValue)) { return self::evaluateArrayArgumentsSubset([self::class, __FUNCTION__], 1, $lookupValue, $lookupVector, $resultVector); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php b/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php index e42193d4c3..d578854de0 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php @@ -74,7 +74,7 @@ public static function transpose($matrixData): array * If an array of values is passed as the $rowNum and/or $columnNum arguments, then the returned result * will also be an array with the same dimensions */ - public static function index(mixed $matrix, mixed $rowNum = 0, mixed $columnNum = null) + public static function index(mixed $matrix, mixed $rowNum = 0, mixed $columnNum = null): mixed { if (is_array($rowNum) || is_array($columnNum)) { return self::evaluateArrayArgumentsSubsetFrom([self::class, __FUNCTION__], 1, $matrix, $rowNum, $columnNum); @@ -121,8 +121,7 @@ public static function index(mixed $matrix, mixed $rowNum = 0, mixed $columnNum return $matrix[$rowNum][$columnNum]; } - /** @return mixed */ - private static function extractRowValue(array $matrix, array $rowKeys, int $rowNum) + private static function extractRowValue(array $matrix, array $rowKeys, int $rowNum): mixed { if ($rowNum === 0) { return $matrix; diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Selection.php b/src/PhpSpreadsheet/Calculation/LookupRef/Selection.php index ae742677d1..53396c9c9d 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Selection.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Selection.php @@ -24,7 +24,7 @@ class Selection * * @return mixed The selected value */ - public static function choose(mixed $chosenEntry, mixed ...$chooseArgs) + public static function choose(mixed $chosenEntry, mixed ...$chooseArgs): mixed { if (is_array($chosenEntry)) { return self::evaluateArrayArgumentsSubset([self::class, __FUNCTION__], 1, $chosenEntry, ...$chooseArgs); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php b/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php index a428174c1a..97986715cf 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php @@ -29,7 +29,7 @@ class Sort extends LookupRefValidations * * @return mixed The sorted values from the sort range */ - public static function sort(mixed $sortArray, mixed $sortIndex = 1, mixed $sortOrder = self::ORDER_ASCENDING, mixed $byColumn = false) + public static function sort(mixed $sortArray, mixed $sortIndex = 1, mixed $sortOrder = self::ORDER_ASCENDING, mixed $byColumn = false): mixed { if (!is_array($sortArray)) { // Scalars are always returned "as is" @@ -79,7 +79,7 @@ public static function sort(mixed $sortArray, mixed $sortIndex = 1, mixed $sortO * * @return mixed The sorted values from the sort range */ - public static function sortBy(mixed $sortArray, mixed ...$args) + public static function sortBy(mixed $sortArray, mixed ...$args): mixed { if (!is_array($sortArray)) { // Scalars are always returned "as is" diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php b/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php index 720f28d9b7..220be2d131 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Unique.php @@ -18,7 +18,7 @@ class Unique * * @return mixed The unique values from the search range */ - public static function unique(mixed $lookupVector, mixed $byColumn = false, mixed $exactlyOnce = false) + public static function unique(mixed $lookupVector, mixed $byColumn = false, mixed $exactlyOnce = false): mixed { if (!is_array($lookupVector)) { // Scalars are always returned "as is" diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php b/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php index a0e375d4c0..92e37b16ad 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php @@ -24,7 +24,7 @@ class VLookup extends LookupBase * * @return mixed The value of the found cell */ - public static function lookup(mixed $lookupValue, mixed $lookupArray, mixed $indexNumber, mixed $notExactMatch = true) + public static function lookup(mixed $lookupValue, mixed $lookupArray, mixed $indexNumber, mixed $notExactMatch = true): mixed { if (is_array($lookupValue) || is_array($indexNumber)) { return self::evaluateArrayArgumentsIgnore([self::class, __FUNCTION__], 1, $lookupValue, $lookupArray, $indexNumber, $notExactMatch); diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 5d85db2c51..1cb08a54ed 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -654,7 +654,7 @@ public static function GEOMEAN(mixed ...$args) * * @return float[] */ - public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true) + public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true): array { return Trends::GROWTH($yValues, $xValues, $newValues, $const); } @@ -895,10 +895,8 @@ public static function LOGNORMDIST2($value, $mean, $stdDev, $cumulative = false) * @see Statistical\Maximum::max() * * @param mixed ...$args Data values - * - * @return float */ - public static function MAX(mixed ...$args) + public static function MAX(mixed ...$args): float|int|string { return Maximum::max(...$args); } @@ -916,10 +914,8 @@ public static function MAX(mixed ...$args) * @see Statistical\Maximum::maxA() * * @param mixed ...$args Data values - * - * @return float */ - public static function MAXA(mixed ...$args) + public static function MAXA(mixed ...$args): float|int|string { return Maximum::maxA(...$args); } @@ -980,10 +976,8 @@ public static function MEDIAN(mixed ...$args) * @see Statistical\Minimum::min() * * @param mixed ...$args Data values - * - * @return float */ - public static function MIN(mixed ...$args) + public static function MIN(mixed ...$args): float|int|string { return Minimum::min(...$args); } @@ -1001,10 +995,8 @@ public static function MIN(mixed ...$args) * @see Statistical\Minimum::minA() * * @param mixed ...$args Data values - * - * @return float */ - public static function MINA(mixed ...$args) + public static function MINA(mixed ...$args): float|int|string { return Minimum::minA(...$args); } @@ -1555,7 +1547,7 @@ public static function TINV($probability, $degrees) * * @return float[] */ - public static function TREND($yValues, $xValues = [], $newValues = [], $const = true) + public static function TREND($yValues, $xValues = [], $newValues = [], $const = true): array { return Trends::TREND($yValues, $xValues, $newValues, $const); } diff --git a/src/PhpSpreadsheet/Calculation/Statistical/MaxMinBase.php b/src/PhpSpreadsheet/Calculation/Statistical/MaxMinBase.php index ba5482fa69..c575721872 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/MaxMinBase.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/MaxMinBase.php @@ -4,10 +4,7 @@ abstract class MaxMinBase { - /** - * @return mixed - */ - protected static function datatypeAdjustmentAllowStrings(mixed $value) + protected static function datatypeAdjustmentAllowStrings(mixed $value): mixed { if (is_bool($value)) { return (int) $value; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Maximum.php b/src/PhpSpreadsheet/Calculation/Statistical/Maximum.php index a92bef4d93..47a98e6c6f 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Maximum.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Maximum.php @@ -17,10 +17,8 @@ class Maximum extends MaxMinBase * MAX(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float */ - public static function max(mixed ...$args) + public static function max(mixed ...$args): float|int|string { $returnValue = null; @@ -56,10 +54,8 @@ public static function max(mixed ...$args) * MAXA(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float */ - public static function maxA(mixed ...$args) + public static function maxA(mixed ...$args): float|int|string { $returnValue = null; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Minimum.php b/src/PhpSpreadsheet/Calculation/Statistical/Minimum.php index 7ec013fc51..fcb77c6337 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Minimum.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Minimum.php @@ -17,10 +17,8 @@ class Minimum extends MaxMinBase * MIN(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float */ - public static function min(mixed ...$args) + public static function min(mixed ...$args): float|int|string { $returnValue = null; @@ -56,10 +54,8 @@ public static function min(mixed ...$args) * MINA(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float */ - public static function minA(mixed ...$args) + public static function minA(mixed ...$args): float|int|string { $returnValue = null; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php index 02af7f9007..3db6c0606a 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php @@ -155,7 +155,7 @@ public static function FORECAST(mixed $xValue, array $yValues, array $xValues) * * @return float[] */ - public static function GROWTH($yValues, $xValues = [], $newValues = [], mixed $const = true) + public static function GROWTH($yValues, $xValues = [], $newValues = [], mixed $const = true): array { $yValues = Functions::flattenArray($yValues); $xValues = Functions::flattenArray($xValues); @@ -412,7 +412,7 @@ public static function STEYX(array $yValues, array $xValues) * * @return float[] */ - public static function TREND($yValues, $xValues = [], $newValues = [], mixed $const = true) + public static function TREND($yValues, $xValues = [], $newValues = [], mixed $const = true): array { $yValues = Functions::flattenArray($yValues); $xValues = Functions::flattenArray($xValues); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/VarianceBase.php b/src/PhpSpreadsheet/Calculation/Statistical/VarianceBase.php index 883f6c94a2..db6e691726 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/VarianceBase.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/VarianceBase.php @@ -6,10 +6,7 @@ abstract class VarianceBase { - /** - * @return mixed - */ - protected static function datatypeAdjustmentAllowStrings(mixed $value) + protected static function datatypeAdjustmentAllowStrings(mixed $value): mixed { if (is_bool($value)) { return (int) $value; @@ -20,10 +17,7 @@ protected static function datatypeAdjustmentAllowStrings(mixed $value) return $value; } - /** - * @return mixed - */ - protected static function datatypeAdjustmentBooleans(mixed $value) + protected static function datatypeAdjustmentBooleans(mixed $value): mixed { if (is_bool($value) && (Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE)) { return (int) $value; diff --git a/src/PhpSpreadsheet/Calculation/TextData/Format.php b/src/PhpSpreadsheet/Calculation/TextData/Format.php index 88434f85e6..38679379fb 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Format.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Format.php @@ -134,10 +134,8 @@ public static function TEXTFORMAT(mixed $value, mixed $format): array|string /** * @param mixed $value Value to check - * - * @return mixed */ - private static function convertValue(mixed $value, bool $spacesMeanZero = false) + private static function convertValue(mixed $value, bool $spacesMeanZero = false): mixed { $value = $value ?? 0; if (is_bool($value)) { diff --git a/src/PhpSpreadsheet/Calculation/Web.php b/src/PhpSpreadsheet/Calculation/Web.php index f4dd40e57d..ce2789e6bb 100644 --- a/src/PhpSpreadsheet/Calculation/Web.php +++ b/src/PhpSpreadsheet/Calculation/Web.php @@ -23,7 +23,7 @@ class Web * * @return string the output resulting from a call to the webservice */ - public static function WEBSERVICE(string $url) + public static function WEBSERVICE(string $url): string { return Web\Service::webService($url); } diff --git a/src/PhpSpreadsheet/Calculation/Web/Service.php b/src/PhpSpreadsheet/Calculation/Web/Service.php index 3775180221..7d843fcdc9 100644 --- a/src/PhpSpreadsheet/Calculation/Web/Service.php +++ b/src/PhpSpreadsheet/Calculation/Web/Service.php @@ -18,7 +18,7 @@ class Service * * @return string the output resulting from a call to the webservice */ - public static function webService(string $url) + public static function webService(string $url): string { $url = trim($url); if (strlen($url) > 2048) { diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index edff0aebf0..79c02f0f06 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -173,10 +173,8 @@ public function getCoordinate(): string /** * Get cell value. - * - * @return mixed */ - public function getValue() + public function getValue(): mixed { return $this->value; } @@ -324,10 +322,8 @@ public static function setCalculateDateTimeType(int $calculateDateTimeType): voi /** * Convert date, time, or datetime from int to float if desired. - * - * @return mixed */ - private function convertDateTimeInt(mixed $result) + private function convertDateTimeInt(mixed $result): mixed { if (is_int($result)) { if (self::$calculateDateTimeType === self::CALCULATE_TIME_FLOAT) { @@ -416,10 +412,8 @@ public function setCalculatedValue(mixed $originalValue, bool $tryNumeric = true * Note that this value is not guaranteed to reflect the actual calculated value because it is * possible that auto-calculation was disabled in the original spreadsheet, and underlying data * values used by the formula have changed since it was last calculated. - * - * @return mixed */ - public function getOldCalculatedValue() + public function getOldCalculatedValue(): mixed { return $this->calculatedValue; } @@ -555,7 +549,7 @@ public function setHyperlink(?Hyperlink $hyperlink = null): self * * @return ?Cells */ - public function getParent() + public function getParent(): ?Cells { return $this->parent; } @@ -774,10 +768,8 @@ public function setFormulaAttributes(mixed $attributes): self /** * Get the formula attributes. - * - * @return mixed */ - public function getFormulaAttributes() + public function getFormulaAttributes(): mixed { return $this->formulaAttributes; } diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index 564d280a2e..e371941afc 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -81,7 +81,7 @@ public static function coordinateIsRange($cellAddress): bool * * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1' */ - public static function absoluteReference($cellAddress) + public static function absoluteReference($cellAddress): string { if (self::coordinateIsRange($cellAddress)) { throw new Exception('Cell coordinate string can not be a range of cells'); @@ -111,7 +111,7 @@ public static function absoluteReference($cellAddress) * * @return string Absolute coordinate e.g. '$A$1' */ - public static function absoluteCoordinate(string $cellAddress) + public static function absoluteCoordinate(string $cellAddress): string { if (self::coordinateIsRange($cellAddress)) { throw new Exception('Cell coordinate string can not be a range of cells'); @@ -140,7 +140,7 @@ public static function absoluteCoordinate(string $cellAddress) * e.g. ['B4','D9'] or [['B4','D9'], ['H2','O11']] * or ['B4'] */ - public static function splitRange($range) + public static function splitRange($range): array { // Ensure $pRange is a valid range if (empty($range)) { @@ -163,7 +163,7 @@ public static function splitRange($range) * * @return string String representation of $pRange */ - public static function buildRange(array $range) + public static function buildRange(array $range): string { // Verify range if (empty($range) || !is_array($range[0])) { @@ -232,7 +232,7 @@ public static function rangeBoundaries(string $range): array * * @return array Range dimension (width, height) */ - public static function rangeDimension(string $range) + public static function rangeDimension(string $range): array { // Calculate range outer borders [$rangeStart, $rangeEnd] = self::rangeBoundaries($range); @@ -248,7 +248,7 @@ public static function rangeDimension(string $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(string $range) + public static function getRangeBoundaries(string $range): array { [$rangeA, $rangeB] = self::rangeBoundaries($range); @@ -424,7 +424,7 @@ private static function sortCellReferenceArray(array $cellList): array * * @return array All individual cells in that range */ - private static function getReferencesForCellBlock($cellBlock) + private static function getReferencesForCellBlock($cellBlock): array { $returnValue = []; @@ -488,7 +488,7 @@ private static function getReferencesForCellBlock($cellBlock) * * @return array associative array mapping coordinate ranges to valuea */ - public static function mergeRangesInCollection(array $coordinateCollection) + public static function mergeRangesInCollection(array $coordinateCollection): array { $hashedValues = []; $mergedCoordCollection = []; @@ -565,7 +565,7 @@ public static function mergeRangesInCollection(array $coordinateCollection) * * @return array[] */ - private static function getCellBlocksFromRangeString($rangeString) + private static function getCellBlocksFromRangeString($rangeString): array { $rangeString = str_replace('$', '', strtoupper($rangeString)); diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php index e24e694e2e..f702a1a53f 100644 --- a/src/PhpSpreadsheet/Cell/DataType.php +++ b/src/PhpSpreadsheet/Cell/DataType.php @@ -41,7 +41,7 @@ class DataType * * @return array */ - public static function getErrorCodes() + public static function getErrorCodes(): array { return self::$errorCodes; } diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php index 1cea89d557..0ba116349c 100644 --- a/src/PhpSpreadsheet/Cell/DataValidation.php +++ b/src/PhpSpreadsheet/Cell/DataValidation.php @@ -143,10 +143,8 @@ public function setFormula2(string $formula): static /** * Get Type. - * - * @return string */ - public function getType() + public function getType(): string { return $this->type; } @@ -167,10 +165,8 @@ public function setType($type): static /** * Get Error style. - * - * @return string */ - public function getErrorStyle() + public function getErrorStyle(): string { return $this->errorStyle; } @@ -191,10 +187,8 @@ public function setErrorStyle($errorStyle): static /** * Get Operator. - * - * @return string */ - public function getOperator() + public function getOperator(): string { return $this->operator; } @@ -215,10 +209,8 @@ public function setOperator($operator): static /** * Get Allow Blank. - * - * @return bool */ - public function getAllowBlank() + public function getAllowBlank(): bool { return $this->allowBlank; } @@ -239,10 +231,8 @@ public function setAllowBlank($allowBlank): static /** * Get Show DropDown. - * - * @return bool */ - public function getShowDropDown() + public function getShowDropDown(): bool { return $this->showDropDown; } @@ -263,10 +253,8 @@ public function setShowDropDown($showDropDown): static /** * Get Show InputMessage. - * - * @return bool */ - public function getShowInputMessage() + public function getShowInputMessage(): bool { return $this->showInputMessage; } @@ -287,10 +275,8 @@ public function setShowInputMessage($showInputMessage): static /** * Get Show ErrorMessage. - * - * @return bool */ - public function getShowErrorMessage() + public function getShowErrorMessage(): bool { return $this->showErrorMessage; } @@ -311,10 +297,8 @@ public function setShowErrorMessage($showErrorMessage): static /** * Get Error title. - * - * @return string */ - public function getErrorTitle() + public function getErrorTitle(): string { return $this->errorTitle; } @@ -335,10 +319,8 @@ public function setErrorTitle($errorTitle): static /** * Get Error. - * - * @return string */ - public function getError() + public function getError(): string { return $this->error; } @@ -359,10 +341,8 @@ public function setError($error): static /** * Get Prompt title. - * - * @return string */ - public function getPromptTitle() + public function getPromptTitle(): string { return $this->promptTitle; } @@ -383,10 +363,8 @@ public function setPromptTitle($promptTitle): static /** * Get Prompt. - * - * @return string */ - public function getPrompt() + public function getPrompt(): string { return $this->prompt; } diff --git a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php index dfe025b4b7..1335de5761 100644 --- a/src/PhpSpreadsheet/Cell/DefaultValueBinder.php +++ b/src/PhpSpreadsheet/Cell/DefaultValueBinder.php @@ -40,10 +40,8 @@ public function bindValue(Cell $cell, $value): bool /** * DataType for value. - * - * @return string */ - public static function dataTypeForValue(mixed $value) + public static function dataTypeForValue(mixed $value): string { // Match the value against a few data types if ($value === null) { diff --git a/src/PhpSpreadsheet/Cell/Hyperlink.php b/src/PhpSpreadsheet/Cell/Hyperlink.php index e8e550603b..667f4153b8 100644 --- a/src/PhpSpreadsheet/Cell/Hyperlink.php +++ b/src/PhpSpreadsheet/Cell/Hyperlink.php @@ -29,10 +29,8 @@ public function __construct($url = '', $tooltip = '') /** * Get URL. - * - * @return string */ - public function getUrl() + public function getUrl(): string { return $this->url; } @@ -53,10 +51,8 @@ public function setUrl($url): static /** * Get tooltip. - * - * @return string */ - public function getTooltip() + public function getTooltip(): string { return $this->tooltip; } diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index 22feb14434..a9ac2410dd 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -157,10 +157,8 @@ public function __destruct() /** * Get Name. - * - * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -277,10 +275,8 @@ public function setPlotArea(PlotArea $plotArea): self /** * Get Plot Visible Only. - * - * @return bool */ - public function getPlotVisibleOnly() + public function getPlotVisibleOnly(): bool { return $this->plotVisibleOnly; } @@ -301,10 +297,8 @@ public function setPlotVisibleOnly($plotVisibleOnly): static /** * Get Display Blanks as. - * - * @return string */ - public function getDisplayBlanksAs() + public function getDisplayBlanksAs(): string { return $this->displayBlanksAs; } @@ -419,10 +413,8 @@ public function getTopLeftPosition(): array /** * Get the cell address where the top left of the chart is fixed. - * - * @return string */ - public function getTopLeftCell() + public function getTopLeftCell(): string { return $this->topLeftCellRef; } @@ -647,7 +639,7 @@ public function refresh(): void * * @return bool true on success */ - public function render($outputDestination = null) + public function render($outputDestination = null): bool { if ($outputDestination == 'php://output') { $outputDestination = null; diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index baadcf56a3..adcab17bc8 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -193,10 +193,8 @@ public function setPlotGrouping(string $groupingType): static /** * Get Plot Direction. - * - * @return string */ - public function getPlotDirection() + public function getPlotDirection(): string { return $this->plotDirection; } @@ -220,7 +218,7 @@ public function setPlotDirection($plotDirection): static * * @return int[] */ - public function getPlotOrder() + public function getPlotOrder(): array { return $this->plotOrder; } @@ -230,7 +228,7 @@ public function getPlotOrder() * * @return DataSeriesValues[] */ - public function getPlotLabels() + public function getPlotLabels(): array { return $this->plotLabel; } @@ -255,7 +253,7 @@ public function getPlotLabelByIndex(mixed $index) * * @return DataSeriesValues[] */ - public function getPlotCategories() + public function getPlotCategories(): array { return $this->plotCategory; } @@ -279,10 +277,8 @@ public function getPlotCategoryByIndex(mixed $index) /** * Get Plot Style. - * - * @return null|string */ - public function getPlotStyle() + public function getPlotStyle(): ?string { return $this->plotStyle; } @@ -306,7 +302,7 @@ public function setPlotStyle($plotStyle): static * * @return DataSeriesValues[] */ - public function getPlotValues() + public function getPlotValues(): array { return $this->plotValues; } @@ -358,10 +354,8 @@ public function getPlotSeriesCount(): int /** * Get Smooth Line. - * - * @return bool */ - public function getSmoothLine() + public function getSmoothLine(): bool { return $this->smoothLine; } diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index fbdc3adfbc..e5130224f6 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -108,10 +108,8 @@ public function __construct( /** * Get Series Data Type. - * - * @return string */ - public function getDataType() + public function getDataType(): string { return $this->dataType; } @@ -143,7 +141,7 @@ public function setDataType($dataType): static * * @return ?string */ - public function getDataSource() + public function getDataSource(): ?string { return $this->dataSource; } @@ -234,10 +232,8 @@ public function setFormatCode(string $formatCode): static /** * Get Series Point Count. - * - * @return int */ - public function getPointCount() + public function getPointCount(): int { return $this->pointCount; } @@ -390,10 +386,8 @@ public function isMultiLevelSeries(): ?bool /** * Return the level count of a multi-level Data Series. - * - * @return int */ - public function multiLevelCount() + public function multiLevelCount(): int { $levelCount = 0; foreach ($this->dataValues as $dataValueSet) { @@ -408,17 +402,15 @@ public function multiLevelCount() * * @return mixed[] */ - public function getDataValues() + public function getDataValues(): ?array { return $this->dataValues; } /** * Get the first Series Data value. - * - * @return mixed */ - public function getDataValue() + public function getDataValue(): mixed { $count = count($this->dataValues); if ($count == 0) { @@ -519,10 +511,8 @@ public function setBubble3D(bool $bubble3D): self /** * Get Smooth Line. - * - * @return bool */ - public function getSmoothLine() + public function getSmoothLine(): bool { return $this->smoothLine; } diff --git a/src/PhpSpreadsheet/Chart/Layout.php b/src/PhpSpreadsheet/Chart/Layout.php index f64f53319b..aeb8e08dba 100644 --- a/src/PhpSpreadsheet/Chart/Layout.php +++ b/src/PhpSpreadsheet/Chart/Layout.php @@ -174,7 +174,7 @@ private function initColor(array $layout, string $name): void * * @return ?string */ - public function getLayoutTarget() + public function getLayoutTarget(): ?string { return $this->layoutTarget; } @@ -196,7 +196,7 @@ public function setLayoutTarget(?string $target): static * * @return ?string */ - public function getXMode() + public function getXMode(): ?string { return $this->xMode; } @@ -220,7 +220,7 @@ public function setXMode($mode): static * * @return ?string */ - public function getYMode() + public function getYMode(): ?string { return $this->yMode; } @@ -263,10 +263,8 @@ public function setXPosition(float $position): static /** * Get Y-Position. - * - * @return null|float */ - public function getYPosition() + public function getYPosition(): ?float { return $this->yPos; } @@ -288,7 +286,7 @@ public function setYPosition(float $position): static * * @return ?float */ - public function getWidth() + public function getWidth(): ?float { return $this->width; } @@ -307,10 +305,8 @@ public function setWidth(?float $width): static /** * Get Height. - * - * @return null|float */ - public function getHeight() + public function getHeight(): ?float { return $this->height; } diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index f6cbfccb4b..a6fd72b450 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -70,10 +70,8 @@ public function getFillColor(): ChartColor /** * Get legend position as an excel string value. - * - * @return string */ - public function getPosition() + public function getPosition(): string { return $this->position; } @@ -120,10 +118,8 @@ public function setPositionXL($positionXL): bool /** * Get allow overlay of other elements? - * - * @return bool */ - public function getOverlay() + public function getOverlay(): bool { return $this->overlay; } @@ -143,7 +139,7 @@ public function setOverlay($overlay): void * * @return ?Layout */ - public function getLayout() + public function getLayout(): ?Layout { return $this->layout; } diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php index 91fc669cd6..a703e533eb 100644 --- a/src/PhpSpreadsheet/Chart/PlotArea.php +++ b/src/PhpSpreadsheet/Chart/PlotArea.php @@ -82,17 +82,15 @@ public function getPlotSeriesCount(): int|float * * @return DataSeries[] */ - public function getPlotGroup() + public function getPlotGroup(): array { return $this->plotSeries; } /** * Get Plot Series by Index. - * - * @return DataSeries */ - public function getPlotGroupByIndex(mixed $index) + public function getPlotGroupByIndex(mixed $index): DataSeries { return $this->plotSeries[$index]; } @@ -148,10 +146,8 @@ public function getGradientFillAngle(): ?float /** * Get gradientFillStops. - * - * @return array */ - public function getGradientFillStops() + public function getGradientFillStops(): array { return $this->gradientFillStops; } diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index 4245b114d5..2e34b2721b 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -139,10 +139,8 @@ public function __construct() /** * Get Object State. - * - * @return bool */ - public function getObjectState() + public function getObjectState(): bool { return $this->objectState; } @@ -416,10 +414,8 @@ protected function getShadowPresetsMap(int $presetsOption): array /** * Get value of array element. - * - * @return mixed */ - protected function getArrayElementsValue(mixed $properties, mixed $elements) + protected function getArrayElementsValue(mixed $properties, mixed $elements): mixed { $reference = &$properties; if (!is_array($elements)) { @@ -502,7 +498,7 @@ public function getGlowColorObject(): ChartColor * * @return ?float */ - public function getGlowSize() + public function getGlowSize(): ?float { return $this->glowSize; } @@ -536,10 +532,8 @@ public function setSoftEdges($size): void /** * Get Soft Edges Size. - * - * @return string */ - public function getSoftEdgesSize() + public function getSoftEdgesSize(): ?float { return $this->softEdges['size']; } @@ -895,10 +889,8 @@ public function setLineStyleProperty(string $propertyName, mixed $value): self * Get Line Style Property. * * @param array|string $elements - * - * @return string */ - public function getLineStyleProperty($elements) + public function getLineStyleProperty($elements): ?string { return $this->getArrayElementsValue($this->lineStyleProperties, $elements); } @@ -920,10 +912,8 @@ public function getLineStyleProperty($elements) * * @param int $arraySelector * @param string $arrayKaySelector - * - * @return string */ - protected function getLineStyleArrowSize($arraySelector, $arrayKaySelector) + protected function getLineStyleArrowSize($arraySelector, $arrayKaySelector): string { return self::ARROW_SIZES[$arraySelector][$arrayKaySelector] ?? ''; } @@ -933,10 +923,8 @@ protected function getLineStyleArrowSize($arraySelector, $arrayKaySelector) * * @param string $arrowSelector * @param string $propertySelector - * - * @return string */ - public function getLineStyleArrowParameters($arrowSelector, $propertySelector) + public function getLineStyleArrowParameters($arrowSelector, $propertySelector): string { return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrowSelector]['size'], $propertySelector); } @@ -945,10 +933,8 @@ public function getLineStyleArrowParameters($arrowSelector, $propertySelector) * Get Line Style Arrow Width. * * @param string $arrow - * - * @return string */ - public function getLineStyleArrowWidth($arrow) + public function getLineStyleArrowWidth($arrow): ?string { return $this->getLineStyleProperty(['arrow', $arrow, 'w']); } @@ -957,10 +943,8 @@ public function getLineStyleArrowWidth($arrow) * Get Line Style Arrow Excel Length. * * @param string $arrow - * - * @return string */ - public function getLineStyleArrowLength($arrow) + public function getLineStyleArrowLength($arrow): ?string { return $this->getLineStyleProperty(['arrow', $arrow, 'len']); } diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index 4d7c303cdf..89df6bb716 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -85,10 +85,8 @@ public function setCaption($caption): static /** * Get allow overlay of other elements? - * - * @return bool */ - public function getOverlay() + public function getOverlay(): bool { return $this->overlay; } diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index a55bd6736d..b9b8e77338 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -66,10 +66,8 @@ public function __construct(Worksheet $parent, CacheInterface $cache) /** * Return the parent worksheet for this cell collection. - * - * @return null|Worksheet */ - public function getParent() + public function getParent(): ?Worksheet { return $this->parent; } @@ -138,10 +136,8 @@ public function getSortedCoordinates(): array /** * Return the cell coordinate of the currently active cell object. - * - * @return null|string */ - public function getCurrentCoordinate() + public function getCurrentCoordinate(): ?string { return $this->currentCoordinate; } @@ -200,7 +196,7 @@ public function getHighestRowAndColumn(): array * * @return string Highest column name */ - public function getHighestColumn($row = null) + public function getHighestColumn($row = null): string { if ($row === null) { return $this->getHighestRowAndColumn()['column']; @@ -233,7 +229,7 @@ public function getHighestColumn($row = null) * * @return int Highest row number */ - public function getHighestRow($column = null) + public function getHighestRow($column = null): int { if ($column === null) { return $this->getHighestRowAndColumn()['row']; @@ -391,7 +387,7 @@ public function add($cellCoordinate, Cell $cell): Cell * * @return null|Cell Cell that was found, or null if not found */ - public function get(string $cellCoordinate) + public function get(string $cellCoordinate): ?Cell { if ($cellCoordinate === $this->currentCoordinate) { return $this->currentCell; diff --git a/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php b/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php index 2dae6de81b..70129c947b 100644 --- a/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php +++ b/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php @@ -18,10 +18,7 @@ class SimpleCache1 implements CacheInterface */ private array $cache = []; - /** - * @return bool - */ - public function clear() + public function clear(): bool { $this->cache = []; @@ -30,10 +27,8 @@ public function clear() /** * @param string $key - * - * @return bool */ - public function delete($key) + public function delete($key): bool { unset($this->cache[$key]); @@ -42,10 +37,8 @@ public function delete($key) /** * @param iterable $keys - * - * @return bool */ - public function deleteMultiple($keys) + public function deleteMultiple($keys): bool { foreach ($keys as $key) { $this->delete($key); @@ -57,10 +50,8 @@ public function deleteMultiple($keys) /** * @param string $key * @param mixed $default - * - * @return mixed */ - public function get($key, $default = null) + public function get($key, $default = null): mixed { if ($this->has($key)) { return $this->cache[$key]; @@ -72,10 +63,8 @@ public function get($key, $default = null) /** * @param iterable $keys * @param mixed $default - * - * @return iterable */ - public function getMultiple($keys, $default = null) + public function getMultiple($keys, $default = null): iterable { $results = []; foreach ($keys as $key) { @@ -87,10 +76,8 @@ public function getMultiple($keys, $default = null) /** * @param string $key - * - * @return bool */ - public function has($key) + public function has($key): bool { return array_key_exists($key, $this->cache); } @@ -99,10 +86,8 @@ public function has($key) * @param string $key * @param mixed $value * @param null|DateInterval|int $ttl - * - * @return bool */ - public function set($key, $value, $ttl = null) + public function set($key, $value, $ttl = null): bool { $this->cache[$key] = $value; @@ -112,10 +97,8 @@ public function set($key, $value, $ttl = null) /** * @param iterable $values * @param null|DateInterval|int $ttl - * - * @return bool */ - public function setMultiple($values, $ttl = null) + public function setMultiple($values, $ttl = null): bool { foreach ($values as $key => $value) { $this->set($key, $value); diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index 1ebf0bedea..6e5a99da29 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -371,10 +371,8 @@ public function isCustomPropertySet(string $propertyName): bool /** * Get a Custom Property Value. - * - * @return mixed */ - public function getCustomPropertyValue(string $propertyName) + public function getCustomPropertyValue(string $propertyName): mixed { if (isset($this->customProperties[$propertyName])) { return $this->customProperties[$propertyName]['value']; @@ -385,10 +383,8 @@ public function getCustomPropertyValue(string $propertyName) /** * Get a Custom Property Type. - * - * @return null|string */ - public function getCustomPropertyType(string $propertyName) + public function getCustomPropertyType(string $propertyName): ?string { return $this->customProperties[$propertyName]['type'] ?? null; } @@ -472,20 +468,16 @@ public function setCustomProperty(string $propertyName, mixed $propertyValue = ' /** * Convert property to form desired by Excel. - * - * @return mixed */ - public static function convertProperty(mixed $propertyValue, string $propertyType) + public static function convertProperty(mixed $propertyValue, string $propertyType): mixed { return self::SPECIAL_TYPES[$propertyType] ?? self::convertProperty2($propertyValue, $propertyType); } /** * Convert property to form desired by Excel. - * - * @return mixed */ - private static function convertProperty2(mixed $propertyValue, string $type) + private static function convertProperty2(mixed $propertyValue, string $type): mixed { $propertyType = self::convertPropertyType($type); switch ($propertyType) { diff --git a/src/PhpSpreadsheet/HashTable.php b/src/PhpSpreadsheet/HashTable.php index c9762ab478..87c49ee7e6 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -120,7 +120,7 @@ public function getIndexForHashCode(string $hashCode): false|int * * @return null|T */ - public function getByIndex(int $index) + public function getByIndex(int $index): ?IComparable { if (isset($this->keyMap[$index])) { return $this->getByHashCode($this->keyMap[$index]); @@ -134,7 +134,7 @@ public function getByIndex(int $index) * * @return null|T */ - public function getByHashCode(string $hashCode) + public function getByHashCode(string $hashCode): ?IComparable { if (isset($this->items[$hashCode])) { return $this->items[$hashCode]; @@ -148,7 +148,7 @@ public function getByHashCode(string $hashCode) * * @return T[] */ - public function toArray() + public function toArray(): array { return $this->items; } diff --git a/src/PhpSpreadsheet/Helper/Html.php b/src/PhpSpreadsheet/Helper/Html.php index 05b47176e8..2a9d627bc4 100644 --- a/src/PhpSpreadsheet/Helper/Html.php +++ b/src/PhpSpreadsheet/Helper/Html.php @@ -607,10 +607,8 @@ private function initialise(): void /** * Parse HTML formatting and return the resulting RichText. - * - * @return RichText */ - public function toRichTextObject(string $html) + public function toRichTextObject(string $html): RichText { $this->initialise(); diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index ad249cb1ce..149cf04530 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -226,13 +226,11 @@ public function setInputEncoding($inputEncoding): static /** * Get input encoding. * - * @return string - * * @codeCoverageIgnore * * @deprecated no use is made of this property */ - public function getInputEncoding() + public function getInputEncoding(): string { return $this->inputEncoding; } @@ -820,10 +818,8 @@ private function loadDocument(DOMDocument $document, Spreadsheet $spreadsheet): /** * Get sheet index. - * - * @return int */ - public function getSheetIndex() + public function getSheetIndex(): int { return $this->sheetIndex; } diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 466e6068c0..480c29eb13 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -110,11 +110,9 @@ public function setInputEncoding($inputEncoding): static * * @deprecated no use is made of this property * - * @return string - * * @codeCoverageIgnore */ - public function getInputEncoding() + public function getInputEncoding(): string { return $this->inputEncoding; } @@ -516,10 +514,8 @@ private function processPFinal(Spreadsheet &$spreadsheet, array $formatArray): v /** * Loads PhpSpreadsheet from file into PhpSpreadsheet instance. - * - * @return Spreadsheet */ - public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet) + public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Spreadsheet { // Open file $this->canReadOrBust($filename); @@ -581,10 +577,8 @@ private function columnRowFromRowData(array $rowData, string &$column, string &$ /** * Get sheet index. - * - * @return int */ - public function getSheetIndex() + public function getSheetIndex(): int { return $this->sheetIndex; } diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index b9cd6de0dd..15a074a30a 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -3924,7 +3924,7 @@ private function readSharedFmla(): void * * @return string The string contents as UTF-8 */ - private function readString() + private function readString(): string { $length = self::getUInt2d($this->data, $this->pos + 2); $recordData = $this->readRecordData($this->data, $this->pos + 4, $length); @@ -7117,10 +7117,8 @@ private function readByteStringLong(string $subData): array * function will automatically find out where the Unicode string ends. * * @param string $subData - * - * @return array */ - private static function readUnicodeStringShort($subData) + private static function readUnicodeStringShort($subData): array { $value = ''; @@ -7141,10 +7139,8 @@ private static function readUnicodeStringShort($subData) * this function is under construction, needs to support rich text, and Asian phonetic settings. * * @param string $subData - * - * @return array */ - private static function readUnicodeStringLong($subData) + private static function readUnicodeStringLong($subData): array { $value = ''; @@ -7319,10 +7315,8 @@ public static function getUInt2d($data, $pos): int * * @param string $data * @param int $pos - * - * @return int */ - public static function getInt2d($data, $pos) + public static function getInt2d($data, $pos): int { return unpack('s', $data[$pos] . $data[$pos + 1])[1]; // @phpstan-ignore-line } diff --git a/src/PhpSpreadsheet/Reader/Xls/Color.php b/src/PhpSpreadsheet/Reader/Xls/Color.php index fd5d723a0f..56e9e660dc 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, array $palette, $version) + public static function map($color, array $palette, $version): array { if ($color <= 0x07 || $color >= 0x40) { // special built-in color diff --git a/src/PhpSpreadsheet/Reader/Xls/RC4.php b/src/PhpSpreadsheet/Reader/Xls/RC4.php index b5458f68b9..f00f905813 100644 --- a/src/PhpSpreadsheet/Reader/Xls/RC4.php +++ b/src/PhpSpreadsheet/Reader/Xls/RC4.php @@ -38,10 +38,8 @@ public function __construct($key) * Symmetric decryption/encryption function. * * @param string $data Data to encrypt/decrypt - * - * @return string */ - public function RC4($data) + public function RC4($data): string { $len = strlen($data); for ($c = 0; $c < $len; ++$c) { diff --git a/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php b/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php index a688386889..a9f0d7dfe8 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php +++ b/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php @@ -36,10 +36,8 @@ class FillPattern * OpenOffice documentation: 2.5.12. * * @param int $index - * - * @return string */ - public static function lookup($index) + public static function lookup($index): string { if (isset(self::$fillPatternMap[$index])) { return self::$fillPatternMap[$index]; diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 32b09bc19d..fda8abcc89 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -355,10 +355,8 @@ private function fileExistsInArchive(ZipArchive $archive, string $fileName = '') /** * @param string $fileName - * - * @return string */ - private function getFromZipArchive(ZipArchive $archive, $fileName = '') + private function getFromZipArchive(ZipArchive $archive, $fileName = ''): string { // Root-relative paths if (str_contains($fileName, '//')) { @@ -1958,10 +1956,8 @@ private function readRibbon(Spreadsheet $excel, string $customUITarget, ZipArchi /** * @param null|array|bool|SimpleXMLElement $array * @param int|string $key - * - * @return mixed */ - private static function getArrayItem($array, $key = 0) + private static function getArrayItem($array, $key = 0): mixed { return ($array === null || is_bool($array)) ? null : ($array[$key] ?? null); } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php index 8158937fed..ee51190d41 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php @@ -430,10 +430,8 @@ public function styles(): array * Get array item. * * @param mixed $array (usually array, in theory can be false) - * - * @return stdClass */ - private static function getArrayItem(mixed $array, int $key = 0) + private static function getArrayItem(mixed $array, int $key = 0): ?SimpleXMLElement { return is_array($array) ? ($array[$key] ?? null) : null; } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Theme.php b/src/PhpSpreadsheet/Reader/Xlsx/Theme.php index bfd322126e..af4a559852 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Theme.php @@ -39,11 +39,9 @@ public function __construct($themeName, $colourSchemeName, $colourMap) /** * Not called by Reader, never accessible any other time. * - * @return string - * * @codeCoverageIgnore */ - public function getThemeName() + public function getThemeName(): string { return $this->themeName; } @@ -51,11 +49,9 @@ public function getThemeName() /** * Not called by Reader, never accessible any other time. * - * @return string - * * @codeCoverageIgnore */ - public function getColourSchemeName() + public function getColourSchemeName(): string { return $this->colourSchemeName; } @@ -64,10 +60,8 @@ public function getColourSchemeName() * Get colour Map Value by Position. * * @param int $index - * - * @return null|string */ - public function getColourByIndex($index) + public function getColourByIndex($index): ?string { return $this->colourMap[$index] ?? null; } diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index 827da85309..c6a9f7dd3c 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -31,10 +31,8 @@ class ReferenceHelper /** * Get an instance of this class. - * - * @return ReferenceHelper */ - public static function getInstance() + public static function getInstance(): self { if (self::$instance === null) { self::$instance = new self(); @@ -839,7 +837,7 @@ private function updateRowRangesAllWorksheets(string $formula, int $numberOfRows * * @return string Updated cell range */ - private function updateCellReference($cellReference = 'A1', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false) + private function updateCellReference($cellReference = 'A1', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false): string { // Is it in another worksheet? Will not have to update anything. if (str_contains($cellReference, '!')) { diff --git a/src/PhpSpreadsheet/RichText/RichText.php b/src/PhpSpreadsheet/RichText/RichText.php index d77747cbae..37c69f0ffb 100644 --- a/src/PhpSpreadsheet/RichText/RichText.php +++ b/src/PhpSpreadsheet/RichText/RichText.php @@ -107,7 +107,7 @@ public function __toString(): string * * @return ITextElement[] */ - public function getRichTextElements() + public function getRichTextElements(): array { return $this->richTextElements; } diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 66bbb801eb..1b4af061af 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -87,7 +87,7 @@ public static function setExcelCalendar($baseYear): bool * * @return int Excel base date (1900 or 1904) */ - public static function getExcelCalendar() + public static function getExcelCalendar(): int { return self::$excelCalendar; } diff --git a/src/PhpSpreadsheet/Shared/Escher.php b/src/PhpSpreadsheet/Shared/Escher.php index 49c1baabe9..33a9fad0a3 100644 --- a/src/PhpSpreadsheet/Shared/Escher.php +++ b/src/PhpSpreadsheet/Shared/Escher.php @@ -23,7 +23,7 @@ class Escher * * @return ?Escher\DggContainer */ - public function getDggContainer() + public function getDggContainer(): ?Escher\DggContainer { return $this->dggContainer; } @@ -32,10 +32,8 @@ public function getDggContainer() * Set Drawing Group Container. * * @param Escher\DggContainer $dggContainer - * - * @return Escher\DggContainer */ - public function setDggContainer($dggContainer) + public function setDggContainer($dggContainer): Escher\DggContainer { return $this->dggContainer = $dggContainer; } @@ -45,7 +43,7 @@ public function setDggContainer($dggContainer) * * @return ?Escher\DgContainer */ - public function getDgContainer() + public function getDgContainer(): ?Escher\DgContainer { return $this->dgContainer; } @@ -54,10 +52,8 @@ public function getDgContainer() * Set Drawing Container. * * @param Escher\DgContainer $dgContainer - * - * @return Escher\DgContainer */ - public function setDgContainer($dgContainer) + public function setDgContainer($dgContainer): Escher\DgContainer { return $this->dgContainer = $dgContainer; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index 10b62ad073..9faa02ebbb 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -78,10 +78,8 @@ public function setParent($parent): void /** * Get the parent Shape Group Container. - * - * @return SpgrContainer */ - public function getParent() + public function getParent(): SpgrContainer { return $this->parent; } @@ -98,10 +96,8 @@ public function setSpgr($value): void /** * Get whether this is a group shape. - * - * @return bool */ - public function getSpgr() + public function getSpgr(): bool { return $this->spgr; } @@ -118,10 +114,8 @@ public function setSpType($value): void /** * Get the shape type. - * - * @return int */ - public function getSpType() + public function getSpType(): int { return $this->spType; } @@ -138,10 +132,8 @@ public function setSpFlag($value): void /** * Get the shape flag. - * - * @return int */ - public function getSpFlag() + public function getSpFlag(): int { return $this->spFlag; } @@ -158,10 +150,8 @@ public function setSpId($value): void /** * Get the shape index. - * - * @return int */ - public function getSpId() + public function getSpId(): int { return $this->spId; } @@ -180,10 +170,8 @@ public function setOPT($property, mixed $value): void * Get an option for the Shape Group Container. * * @param int $property The number specifies the option - * - * @return mixed */ - public function getOPT($property) + public function getOPT($property): mixed { if (isset($this->OPT[$property])) { return $this->OPT[$property]; @@ -194,10 +182,8 @@ public function getOPT($property) /** * Get the collection of options. - * - * @return array */ - public function getOPTCollection() + public function getOPTCollection(): array { return $this->OPT; } @@ -214,10 +200,8 @@ public function setStartCoordinates($value): void /** * Get cell coordinates of upper-left corner of shape. - * - * @return string */ - public function getStartCoordinates() + public function getStartCoordinates(): string { return $this->startCoordinates; } @@ -266,10 +250,8 @@ public function setEndCoordinates($value): void /** * Get cell coordinates of bottom-right corner of shape. - * - * @return string */ - public function getEndCoordinates() + public function getEndCoordinates(): string { return $this->endCoordinates; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php index 36d9e30c0d..7857b78393 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php @@ -38,10 +38,8 @@ class DggContainer /** * Get maximum shape index of all shapes in all drawings (plus one). - * - * @return int */ - public function getSpIdMax() + public function getSpIdMax(): int { return $this->spIdMax; } @@ -58,10 +56,8 @@ public function setSpIdMax($value): void /** * Get total number of drawings saved. - * - * @return int */ - public function getCDgSaved() + public function getCDgSaved(): int { return $this->cDgSaved; } @@ -78,10 +74,8 @@ public function setCDgSaved($value): void /** * Get total number of shapes saved (including group shapes). - * - * @return int */ - public function getCSpSaved() + public function getCSpSaved(): int { return $this->cSpSaved; } @@ -101,7 +95,7 @@ public function setCSpSaved($value): void * * @return ?DggContainer\BstoreContainer */ - public function getBstoreContainer() + public function getBstoreContainer(): ?DggContainer\BstoreContainer { return $this->bstoreContainer; } @@ -130,10 +124,8 @@ public function setOPT($property, mixed $value): void * Get an option for the drawing group. * * @param int $property The number specifies the option - * - * @return mixed */ - public function getOPT($property) + public function getOPT($property): mixed { if (isset($this->OPT[$property])) { return $this->OPT[$property]; @@ -144,10 +136,8 @@ public function getOPT($property) /** * Get identifier clusters. - * - * @return array */ - public function getIDCLs() + public function getIDCLs(): array { return $this->IDCLs; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php index a7ed4bae8b..2d13b42d07 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer.php @@ -25,7 +25,7 @@ public function addBSE(BstoreContainer\BSE $BSE): void * * @return BstoreContainer\BSE[] */ - public function getBSECollection() + public function getBSECollection(): array { return $this->BSECollection; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php index 9b175a0e7a..cfe13eaf85 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php @@ -48,7 +48,7 @@ public function setParent(BstoreContainer $parent): void * * @return ?BSE\Blip */ - public function getBlip() + public function getBlip(): ?BSE\Blip { return $this->blip; } @@ -64,10 +64,8 @@ public function setBlip(BSE\Blip $blip): void /** * Get the BLIP type. - * - * @return int */ - public function getBlipType() + public function getBlipType(): int { return $this->blipType; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php index 849c6c2238..767224c69e 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php @@ -18,10 +18,8 @@ class Blip /** * Get the raw image data. - * - * @return string */ - public function getData() + public function getData(): string { return $this->data; } diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index dde5193d52..95556df9d5 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -300,10 +300,8 @@ public static function setAutoSizeMethod($method): bool /** * Get autoSize method. - * - * @return string */ - public static function getAutoSizeMethod() + public static function getAutoSizeMethod(): string { return self::$autoSizeMethod; } @@ -326,10 +324,8 @@ public static function setTrueTypeFontPath($folderPath): void /** * Get the path to the folder containing .ttf files. - * - * @return string */ - public static function getTrueTypeFontPath() + public static function getTrueTypeFontPath(): string { return self::$trueTypeFontPath; } @@ -553,7 +549,7 @@ public static function centimeterSizeToPixels($sizeInCm): float * * @return string Path to TrueType font file */ - public static function getTrueTypeFontFileFromFont(FontStyle $font, bool $checkPath = true) + public static function getTrueTypeFontFileFromFont(FontStyle $font, bool $checkPath = true): string { if ($checkPath && (!file_exists(self::$trueTypeFontPath) || !is_dir(self::$trueTypeFontPath))) { throw new PhpSpreadsheetException('Valid directory to TrueType Font files not specified'); diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index 4c29018cea..345a6f861a 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -243,10 +243,8 @@ public function getStream($blockIdOrPps) * Reads a signed char. * * @param resource $fileHandle file handle - * - * @return int */ - private static function readInt1($fileHandle) + private static function readInt1($fileHandle): int { [, $tmp] = unpack('c', fread($fileHandle, 1) ?: '') ?: [0, 0]; @@ -257,10 +255,8 @@ private static function readInt1($fileHandle) * Reads an unsigned short (2 octets). * * @param resource $fileHandle file handle - * - * @return int */ - private static function readInt2($fileHandle) + private static function readInt2($fileHandle): int { [, $tmp] = unpack('v', fread($fileHandle, 2) ?: '') ?: [0, 0]; @@ -275,10 +271,8 @@ private static function readInt2($fileHandle) * Reads long (4 octets), interpreted as if signed on 32-bit system. * * @param resource $fileHandle file handle - * - * @return int */ - private static function readInt4($fileHandle) + private static function readInt4($fileHandle): int { [, $tmp] = unpack('V', fread($fileHandle, 4) ?: '') ?: [0, 0]; if ($tmp >= self::SIGNED_4OCTET_LIMIT) { @@ -463,7 +457,7 @@ public function getData($index, $position, $length): string * * @return int The amount of bytes in data the PPS has */ - public function getDataLength($index) + public function getDataLength($index): int { if (isset($this->_list[$index])) { return $this->_list[$index]->Size; diff --git a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php index 4d13e68f18..142cdd4b37 100644 --- a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php +++ b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php @@ -135,10 +135,8 @@ public function stream_eof(): bool // @codingStandardsIgnoreLine /** * Returns the position of the file pointer, i.e. its offset into the file * stream. Implements support for ftell(). - * - * @return int */ - public function stream_tell() // @codingStandardsIgnoreLine + public function stream_tell(): int // @codingStandardsIgnoreLine { return $this->pos; } diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index c033ebd79a..9e6e0c4782 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -134,7 +134,7 @@ public function __construct($No, $name, $type, $prev, $next, $dir, $time_1st, $t * * @return int The amount of data (in bytes) */ - public function getDataLen() + public function getDataLen(): int { //if (!isset($this->_data)) { // return 0; @@ -148,7 +148,7 @@ public function getDataLen() * * @return string The binary string */ - public function getPpsWk() + public function getPpsWk(): string { $ret = str_pad($this->Name, 64, "\x00"); @@ -181,7 +181,7 @@ public function getPpsWk() * * @return int The index for this PPS */ - public static function savePpsSetPnt(array &$raList, mixed $to_save, mixed $depth = 0) + public static function savePpsSetPnt(array &$raList, mixed $to_save, mixed $depth = 0): int { if (!is_array($to_save) || (empty($to_save))) { return 0xFFFFFFFF; diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index 3e9de1eea3..3089215325 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -228,10 +228,8 @@ private static function buildSYLKCharacters(): void /** * Get whether iconv extension is available. - * - * @return bool */ - public static function getIsIconvEnabled() + public static function getIsIconvEnabled(): bool { if (isset(self::$isIconvEnabled)) { return self::$isIconvEnabled; @@ -650,7 +648,7 @@ public static function SYLKtoUTF8(string $textValue): string * * @return mixed string or only the leading numeric part of the string */ - public static function testStringAsNumeric($textValue) + public static function testStringAsNumeric($textValue): mixed { if (is_numeric($textValue)) { return $textValue; diff --git a/src/PhpSpreadsheet/Shared/Trend/BestFit.php b/src/PhpSpreadsheet/Shared/Trend/BestFit.php index 731a677933..94f97bfde5 100644 --- a/src/PhpSpreadsheet/Shared/Trend/BestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/BestFit.php @@ -73,14 +73,12 @@ abstract class BestFit protected float $yOffset = 0; - /** @return bool */ - public function getError() + public function getError(): bool { return $this->error; } - /** @return string */ - public function getBestFitType() + public function getBestFitType(): string { return $this->bestFitType; } @@ -92,7 +90,7 @@ public function getBestFitType() * * @return float Y-Value */ - abstract public function getValueOfYForX($xValue); + abstract public function getValueOfYForX($xValue): float; /** * Return the X-Value for a specified value of Y. @@ -101,14 +99,14 @@ abstract public function getValueOfYForX($xValue); * * @return float X-Value */ - abstract public function getValueOfXForY($yValue); + abstract public function getValueOfXForY($yValue): float; /** * Return the original set of X-Values. * * @return float[] X-Values */ - public function getXValues() + public function getXValues(): array { return $this->xValues; } @@ -117,19 +115,15 @@ public function getXValues() * Return the Equation of the best-fit line. * * @param int $dp Number of places of decimal precision to display - * - * @return string */ - abstract public function getEquation($dp = 0); + abstract public function getEquation($dp = 0): string; /** * 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($this->slope, $dp); @@ -142,10 +136,8 @@ public function getSlope($dp = 0) * Return the standard error of the Slope. * * @param int $dp Number of places of decimal precision to display - * - * @return float */ - public function getSlopeSE($dp = 0) + public function getSlopeSE($dp = 0): float { if ($dp != 0) { return round($this->slopeSE, $dp); @@ -158,10 +150,8 @@ public function getSlopeSE($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($this->intersect, $dp); @@ -174,10 +164,8 @@ public function getIntersect($dp = 0) * Return the standard error of the Intersect. * * @param int $dp Number of places of decimal precision to display - * - * @return float */ - public function getIntersectSE($dp = 0) + public function getIntersectSE($dp = 0): float { if ($dp != 0) { return round($this->intersectSE, $dp); @@ -190,10 +178,8 @@ public function getIntersectSE($dp = 0) * Return the goodness of fit for this regression. * * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getGoodnessOfFit($dp = 0) + public function getGoodnessOfFit($dp = 0): float { if ($dp != 0) { return round($this->goodnessOfFit, $dp); @@ -206,10 +192,8 @@ public function getGoodnessOfFit($dp = 0) * Return the goodness of fit for this regression. * * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getGoodnessOfFitPercent($dp = 0) + public function getGoodnessOfFitPercent($dp = 0): float { if ($dp != 0) { return round($this->goodnessOfFit * 100, $dp); @@ -222,10 +206,8 @@ public function getGoodnessOfFitPercent($dp = 0) * Return the standard deviation of the residuals for this regression. * * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getStdevOfResiduals($dp = 0) + public function getStdevOfResiduals($dp = 0): float { if ($dp != 0) { return round($this->stdevOfResiduals, $dp); @@ -236,10 +218,8 @@ public function getStdevOfResiduals($dp = 0) /** * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getSSRegression($dp = 0) + public function getSSRegression($dp = 0): float { if ($dp != 0) { return round($this->SSRegression, $dp); @@ -250,10 +230,8 @@ public function getSSRegression($dp = 0) /** * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getSSResiduals($dp = 0) + public function getSSResiduals($dp = 0): float { if ($dp != 0) { return round($this->SSResiduals, $dp); @@ -264,10 +242,8 @@ public function getSSResiduals($dp = 0) /** * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getDFResiduals($dp = 0) + public function getDFResiduals($dp = 0): float { if ($dp != 0) { return round($this->DFResiduals, $dp); @@ -278,10 +254,8 @@ public function getDFResiduals($dp = 0) /** * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getF($dp = 0) + public function getF($dp = 0): float { if ($dp != 0) { return round($this->f, $dp); @@ -292,10 +266,8 @@ public function getF($dp = 0) /** * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getCovariance($dp = 0) + public function getCovariance($dp = 0): float { if ($dp != 0) { return round($this->covariance, $dp); @@ -306,10 +278,8 @@ public function getCovariance($dp = 0) /** * @param int $dp Number of places of decimal precision to return - * - * @return float */ - public function getCorrelation($dp = 0) + public function getCorrelation($dp = 0): float { if ($dp != 0) { return round($this->correlation, $dp); @@ -321,7 +291,7 @@ public function getCorrelation($dp = 0) /** * @return float[] */ - public function getYBestFitValues() + public function getYBestFitValues(): array { return $this->yBestFitValues; } diff --git a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php index 54ba089fff..12009b6f0c 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -17,7 +17,7 @@ class LinearBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue): int|float + public function getValueOfYForX($xValue): float { return $this->getIntersect() + $this->getSlope() * $xValue; } @@ -29,7 +29,7 @@ public function getValueOfYForX($xValue): int|float * * @return float X-Value */ - public function getValueOfXForY($yValue): int|float + public function getValueOfXForY($yValue): float { return ($yValue - $this->getIntersect()) / $this->getSlope(); } diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index 205dbcf2a3..2afaae7c43 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -23,10 +23,8 @@ class PolynomialBestFit extends BestFit /** * Return the order of this polynomial. - * - * @return int */ - public function getOrder() + public function getOrder(): int { return $this->order; } @@ -38,7 +36,7 @@ public function getOrder() * * @return float Y-Value */ - public function getValueOfYForX($xValue) + public function getValueOfYForX($xValue): float { $retVal = $this->getIntersect(); $slope = $this->getSlope(); @@ -60,7 +58,7 @@ public function getValueOfYForX($xValue) * * @return float X-Value */ - public function getValueOfXForY($yValue): int|float + public function getValueOfXForY($yValue): float { return ($yValue - $this->getIntersect()) / $this->getSlope(); } @@ -94,10 +92,8 @@ public function getEquation($dp = 0): string * 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) { $coefficients = []; diff --git a/src/PhpSpreadsheet/Shared/Trend/Trend.php b/src/PhpSpreadsheet/Shared/Trend/Trend.php index abb80a57ea..a12f7f60b9 100644 --- a/src/PhpSpreadsheet/Shared/Trend/Trend.php +++ b/src/PhpSpreadsheet/Shared/Trend/Trend.php @@ -52,10 +52,8 @@ class Trend * @param array $yValues * @param array $xValues * @param bool $const - * - * @return mixed */ - public static function calculate(string $trendType = self::TREND_BEST_FIT, $yValues = [], $xValues = [], $const = true) + public static function calculate(string $trendType = self::TREND_BEST_FIT, $yValues = [], $xValues = [], $const = true): mixed { // 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 44ca8f477e..978bd8b062 100644 --- a/src/PhpSpreadsheet/Shared/XMLWriter.php +++ b/src/PhpSpreadsheet/Shared/XMLWriter.php @@ -69,10 +69,8 @@ public function __wakeup(): void /** * Get written data. - * - * @return string */ - public function getData() + public function getData(): string { if ($this->tempFileName == '') { return $this->outputMemory(true); diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php index c5b43fe173..26626d0f39 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -18,7 +18,7 @@ class Xls * * @return int The width in pixels */ - public static function sizeCol(Worksheet $worksheet, $col = 'A') + public static function sizeCol(Worksheet $worksheet, $col = 'A'): int { // default font of the workbook $font = $worksheet->getParentOrThrow()->getDefaultStyle()->getFont(); diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 2618321d16..d2f8c72c53 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -177,10 +177,8 @@ public function getTheme(): Theme /** * The workbook has macros ? - * - * @return bool */ - public function hasMacros() + public function hasMacros(): bool { return $this->hasMacros; } @@ -208,10 +206,8 @@ public function setMacrosCode($macroCode): void /** * Return the macros code. - * - * @return null|string */ - public function getMacrosCode() + public function getMacrosCode(): ?string { return $this->macrosCode; } @@ -238,10 +234,8 @@ public function hasMacrosCertificate(): bool /** * Return the macros certificate. - * - * @return null|string */ - public function getMacrosCertificate() + public function getMacrosCertificate(): ?string { return $this->macrosCertificate; } @@ -319,10 +313,8 @@ public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData): void * It has to be minimized when the library start to support currently unparsed data. * * @internal - * - * @return array */ - public function getUnparsedLoadedData() + public function getUnparsedLoadedData(): array { return $this->unparsedLoadedData; } @@ -352,10 +344,8 @@ private function getExtensionOnly(mixed $path): string * retrieve Binaries Ribbon Objects. * * @param string $what - * - * @return null|array */ - public function getRibbonBinObjects($what = 'all') + public function getRibbonBinObjects($what = 'all'): ?array { $ReturnData = null; $what = strtolower($what); @@ -416,10 +406,8 @@ public function sheetCodeNameExists($codeName): bool * Get sheet by code name. Warning : sheet don't have always a code name ! * * @param string $codeName Sheet name - * - * @return null|Worksheet */ - public function getSheetByCodeName($codeName) + public function getSheetByCodeName($codeName): ?Worksheet { $worksheetCount = count($this->workSheetCollection); for ($i = 0; $i < $worksheetCount; ++$i) { @@ -490,20 +478,16 @@ public function disconnectWorksheets(): void /** * Return the calculation engine for this worksheet. - * - * @return null|Calculation */ - public function getCalculationEngine() + public function getCalculationEngine(): ?Calculation { return $this->calculationEngine; } /** * Get properties. - * - * @return Document\Properties */ - public function getProperties() + public function getProperties(): Document\Properties { return $this->properties; } @@ -518,10 +502,8 @@ public function setProperties(Document\Properties $documentProperties): void /** * Get security. - * - * @return Document\Security */ - public function getSecurity() + public function getSecurity(): Document\Security { return $this->security; } @@ -536,10 +518,8 @@ public function setSecurity(Document\Security $documentSecurity): void /** * Get active sheet. - * - * @return Worksheet */ - public function getActiveSheet() + public function getActiveSheet(): Worksheet { return $this->getSheet($this->activeSheetIndex); } @@ -636,10 +616,8 @@ public function removeSheetByIndex($sheetIndex): void * Get sheet by index. * * @param int $sheetIndex Sheet index - * - * @return Worksheet */ - public function getSheet($sheetIndex) + public function getSheet($sheetIndex): Worksheet { if (!isset($this->workSheetCollection[$sheetIndex])) { $numSheets = $this->getSheetCount(); @@ -657,7 +635,7 @@ public function getSheet($sheetIndex) * * @return Worksheet[] */ - public function getAllSheets() + public function getAllSheets(): array { return $this->workSheetCollection; } @@ -666,10 +644,8 @@ public function getAllSheets() * Get sheet by name. * * @param string $worksheetName Sheet name - * - * @return null|Worksheet */ - public function getSheetByName($worksheetName) + public function getSheetByName($worksheetName): ?Worksheet { $worksheetCount = count($this->workSheetCollection); for ($i = 0; $i < $worksheetCount; ++$i) { @@ -699,7 +675,7 @@ public function getSheetByNameOrThrow(string $worksheetName): Worksheet * * @return int index */ - public function getIndex(Worksheet $worksheet) + public function getIndex(Worksheet $worksheet): int { foreach ($this->workSheetCollection as $key => $value) { if ($value->getHashCode() === $worksheet->getHashCode()) { @@ -718,7 +694,7 @@ public function getIndex(Worksheet $worksheet) * * @return int New sheet index */ - public function setIndexByName(string $worksheetName, $newIndexPosition) + public function setIndexByName(string $worksheetName, $newIndexPosition): int { $oldIndex = $this->getIndex($this->getSheetByNameOrThrow($worksheetName)); $worksheet = array_splice( @@ -749,7 +725,7 @@ public function getSheetCount(): int * * @return int Active sheet index */ - public function getActiveSheetIndex() + public function getActiveSheetIndex(): int { return $this->activeSheetIndex; } @@ -758,10 +734,8 @@ public function getActiveSheetIndex() * Set active sheet index. * * @param int $worksheetIndex Active sheet index - * - * @return Worksheet */ - public function setActiveSheetIndex($worksheetIndex) + public function setActiveSheetIndex($worksheetIndex): Worksheet { $numSheets = count($this->workSheetCollection); @@ -779,10 +753,8 @@ public function setActiveSheetIndex($worksheetIndex) * Set active sheet index by name. * * @param string $worksheetName Sheet title - * - * @return Worksheet */ - public function setActiveSheetIndexByName(string $worksheetName) + public function setActiveSheetIndexByName(string $worksheetName): Worksheet { if (($worksheet = $this->getSheetByName($worksheetName)) instanceof Worksheet) { $this->setActiveSheetIndex($this->getIndex($worksheet)); @@ -1106,7 +1078,7 @@ public function __clone() * * @return Style[] */ - public function getCellXfCollection() + public function getCellXfCollection(): array { return $this->cellXfCollection; } @@ -1115,10 +1087,8 @@ public function getCellXfCollection() * Get cellXf by index. * * @param int $cellStyleIndex - * - * @return Style */ - public function getCellXfByIndex($cellStyleIndex) + public function getCellXfByIndex($cellStyleIndex): Style { return $this->cellXfCollection[$cellStyleIndex]; } @@ -1151,10 +1121,8 @@ public function cellXfExists(Style $cellStyleIndex): bool /** * Get default style. - * - * @return Style */ - public function getDefaultStyle() + public function getDefaultStyle(): Style { if (isset($this->cellXfCollection[0])) { return $this->cellXfCollection[0]; @@ -1204,10 +1172,8 @@ public function removeCellXfByIndex($cellStyleIndex): void /** * Get the cellXf supervisor. - * - * @return Style */ - public function getCellXfSupervisor() + public function getCellXfSupervisor(): Style { return $this->cellXfSupervisor; } @@ -1217,7 +1183,7 @@ public function getCellXfSupervisor() * * @return Style[] */ - public function getCellStyleXfCollection() + public function getCellStyleXfCollection(): array { return $this->cellStyleXfCollection; } @@ -1226,10 +1192,8 @@ public function getCellStyleXfCollection() * Get cellStyleXf by index. * * @param int $cellStyleIndex Index to cellXf - * - * @return Style */ - public function getCellStyleXfByIndex($cellStyleIndex) + public function getCellStyleXfByIndex($cellStyleIndex): Style { return $this->cellStyleXfCollection[$cellStyleIndex]; } @@ -1357,10 +1321,8 @@ public function garbageCollect(): void /** * Return the unique ID value assigned to this spreadsheet workbook. - * - * @return string */ - public function getID() + public function getID(): string { return $this->uniqueID; } @@ -1370,7 +1332,7 @@ public function getID() * * @return bool True if horizonal scroll bar is visible */ - public function getShowHorizontalScroll() + public function getShowHorizontalScroll(): bool { return $this->showHorizontalScroll; } @@ -1390,7 +1352,7 @@ public function setShowHorizontalScroll($showHorizontalScroll): void * * @return bool True if vertical scroll bar is visible */ - public function getShowVerticalScroll() + public function getShowVerticalScroll(): bool { return $this->showVerticalScroll; } @@ -1410,7 +1372,7 @@ public function setShowVerticalScroll($showVerticalScroll): void * * @return bool True if the sheet tabs are visible */ - public function getShowSheetTabs() + public function getShowSheetTabs(): bool { return $this->showSheetTabs; } @@ -1430,7 +1392,7 @@ public function setShowSheetTabs($showSheetTabs): void * * @return bool true if workbook window is minimized */ - public function getMinimized() + public function getMinimized(): bool { return $this->minimized; } @@ -1451,7 +1413,7 @@ public function setMinimized($minimized): void * * @return bool true if workbook window is minimized */ - public function getAutoFilterDateGrouping() + public function getAutoFilterDateGrouping(): bool { return $this->autoFilterDateGrouping; } @@ -1472,7 +1434,7 @@ public function setAutoFilterDateGrouping($autoFilterDateGrouping): void * * @return int First sheet in book view */ - public function getFirstSheetIndex() + public function getFirstSheetIndex(): int { return $this->firstSheetIndex; } @@ -1499,7 +1461,7 @@ public function setFirstSheetIndex($firstSheetIndex): void * * @return string Visible status */ - public function getVisibility() + public function getVisibility(): string { return $this->visibility; } @@ -1538,7 +1500,7 @@ public function setVisibility($visibility): void * * @return int Ratio between the workbook tabs bar and the horizontal scroll bar */ - public function getTabRatio() + public function getTabRatio(): int { return $this->tabRatio; } @@ -1573,10 +1535,8 @@ public function reevaluateAutoFilters(bool $resetToMax): void /** * @throws Exception - * - * @return mixed */ - public function __serialize() + public function __serialize(): array { throw new Exception('Spreadsheet objects cannot be serialized'); } diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index db14285ec8..e665e86fb0 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -62,10 +62,8 @@ public function __construct($isSupervisor = false, bool $isConditional = false) /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return Border */ - public function getSharedComponent() + public function getSharedComponent(): self { /** @var Style */ $parent = $this->parent; @@ -132,10 +130,8 @@ public function applyFromArray(array $styleArray): static /** * Get Border style. - * - * @return string */ - public function getBorderStyle() + public function getBorderStyle(): string { if ($this->isSupervisor) { return $this->getSharedComponent()->getBorderStyle(); @@ -173,10 +169,8 @@ public function setBorderStyle($style): static /** * Get Border Color. - * - * @return Color */ - public function getColor() + public function getColor(): Color { return $this->color; } diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index 7f5fef02a3..344b218307 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -113,10 +113,8 @@ public function __construct($isSupervisor = false, bool $isConditional = false) /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return Borders */ - public function getSharedComponent() + public function getSharedComponent(): self { /** @var Style */ $parent = $this->parent; @@ -209,60 +207,48 @@ public function applyFromArray(array $styleArray): static /** * Get Left. - * - * @return Border */ - public function getLeft() + public function getLeft(): Border { return $this->left; } /** * Get Right. - * - * @return Border */ - public function getRight() + public function getRight(): Border { return $this->right; } /** * Get Top. - * - * @return Border */ - public function getTop() + public function getTop(): Border { return $this->top; } /** * Get Bottom. - * - * @return Border */ - public function getBottom() + public function getBottom(): Border { return $this->bottom; } /** * Get Diagonal. - * - * @return Border */ - public function getDiagonal() + public function getDiagonal(): Border { return $this->diagonal; } /** * Get AllBorders (pseudo-border). Only applies to supervisor. - * - * @return Border */ - public function getAllBorders() + public function getAllBorders(): Border { if (!$this->isSupervisor) { throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); @@ -273,10 +259,8 @@ public function getAllBorders() /** * Get Outline (pseudo-border). Only applies to supervisor. - * - * @return Border */ - public function getOutline() + public function getOutline(): Border { if (!$this->isSupervisor) { throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); @@ -287,10 +271,8 @@ public function getOutline() /** * Get Inside (pseudo-border). Only applies to supervisor. - * - * @return Border */ - public function getInside() + public function getInside(): Border { if (!$this->isSupervisor) { throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); @@ -301,10 +283,8 @@ public function getInside() /** * Get Vertical (pseudo-border). Only applies to supervisor. - * - * @return Border */ - public function getVertical() + public function getVertical(): Border { if (!$this->isSupervisor) { throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); @@ -315,10 +295,8 @@ public function getVertical() /** * Get Horizontal (pseudo-border). Only applies to supervisor. - * - * @return Border */ - public function getHorizontal() + public function getHorizontal(): Border { if (!$this->isSupervisor) { throw new PhpSpreadsheetException('Can only get pseudo-border for supervisor.'); @@ -329,10 +307,8 @@ public function getHorizontal() /** * Get DiagonalDirection. - * - * @return int */ - public function getDiagonalDirection() + public function getDiagonalDirection(): int { if ($this->isSupervisor) { return $this->getSharedComponent()->getDiagonalDirection(); diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index 7b5acc8879..6af05465c8 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -136,10 +136,8 @@ public function __construct($colorValue = self::COLOR_BLACK, $isSupervisor = fal /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return Color */ - public function getSharedComponent() + public function getSharedComponent(): self { /** @var Style */ $parent = $this->parent; diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index e3804e5dab..c16474dadb 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -129,10 +129,8 @@ public function setNoFormatSet(bool $noFormatSet): self /** * Get Condition type. - * - * @return string */ - public function getConditionType() + public function getConditionType(): string { return $this->conditionType; } @@ -153,10 +151,8 @@ public function setConditionType($type): static /** * Get Operator type. - * - * @return string */ - public function getOperatorType() + public function getOperatorType(): string { return $this->operatorType; } @@ -177,10 +173,8 @@ public function setOperatorType($type): static /** * Get text. - * - * @return string */ - public function getText() + public function getText(): string { return $this->text; } @@ -201,10 +195,8 @@ public function setText($text): static /** * Get StopIfTrue. - * - * @return bool */ - public function getStopIfTrue() + public function getStopIfTrue(): bool { return $this->stopIfTrue; } @@ -228,7 +220,7 @@ public function setStopIfTrue($stopIfTrue): static * * @return (bool|float|int|string)[] */ - public function getConditions() + public function getConditions(): array { return $this->condition; } @@ -266,10 +258,8 @@ public function addCondition($condition): static /** * Get Style. - * - * @return Style */ - public function getStyle() + public function getStyle(): Style { return $this->style; } diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php index dc71222f75..8a4257e990 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php @@ -73,10 +73,7 @@ public function getXmlElements(): array return $ret; } - /** - * @return int - */ - public function getMinLength() + public function getMinLength(): int { return $this->minLength; } @@ -88,10 +85,7 @@ public function setMinLength(int $minLength): self return $this; } - /** - * @return int - */ - public function getMaxLength() + public function getMaxLength(): int { return $this->maxLength; } @@ -103,10 +97,7 @@ public function setMaxLength(int $maxLength): self return $this; } - /** - * @return null|bool - */ - public function getBorder() + public function getBorder(): ?bool { return $this->border; } @@ -118,10 +109,7 @@ public function setBorder(bool $border): self return $this; } - /** - * @return null|bool - */ - public function getGradient() + public function getGradient(): ?bool { return $this->gradient; } @@ -145,10 +133,7 @@ public function setDirection(string $direction): self return $this; } - /** - * @return null|bool - */ - public function getNegativeBarBorderColorSameAsPositive() + public function getNegativeBarBorderColorSameAsPositive(): ?bool { return $this->negativeBarBorderColorSameAsPositive; } @@ -172,10 +157,7 @@ public function setAxisPosition(string $axisPosition): self return $this; } - /** - * @return ConditionalFormatValueObject - */ - public function getMaximumConditionalFormatValueObject() + public function getMaximumConditionalFormatValueObject(): ConditionalFormatValueObject { return $this->maximumConditionalFormatValueObject; } @@ -187,10 +169,7 @@ public function setMaximumConditionalFormatValueObject(ConditionalFormatValueObj return $this; } - /** - * @return ConditionalFormatValueObject - */ - public function getMinimumConditionalFormatValueObject() + public function getMinimumConditionalFormatValueObject(): ConditionalFormatValueObject { return $this->minimumConditionalFormatValueObject; } diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php index 3ad69db9e5..c4ef7eb620 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php @@ -162,10 +162,7 @@ private static function parseExtDataBarElementChildrenFromXml(ConditionalDataBar } } - /** - * @return mixed - */ - public function getId() + public function getId(): mixed { return $this->id; } diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index 828e0cbfe2..aaaa26b4d9 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -85,10 +85,8 @@ public function __construct($isSupervisor = false, $isConditional = false) /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return Fill */ - public function getSharedComponent() + public function getSharedComponent(): self { /** @var Style */ $parent = $this->parent; @@ -156,10 +154,8 @@ public function applyFromArray(array $styleArray): static /** * Get Fill Type. - * - * @return null|string */ - public function getFillType() + public function getFillType(): ?string { if ($this->isSupervisor) { return $this->getSharedComponent()->getFillType(); @@ -189,10 +185,8 @@ public function setFillType($fillType): static /** * Get Rotation. - * - * @return float */ - public function getRotation() + public function getRotation(): float { if ($this->isSupervisor) { return $this->getSharedComponent()->getRotation(); @@ -222,10 +216,8 @@ public function setRotation($angleInDegrees): static /** * Get Start Color. - * - * @return Color */ - public function getStartColor() + public function getStartColor(): Color { return $this->startColor; } @@ -253,10 +245,8 @@ public function setStartColor(Color $color): static /** * Get End Color. - * - * @return Color */ - public function getEndColor() + public function getEndColor(): Color { return $this->endColor; } diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index 07a418ae0a..915bede0f7 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -120,10 +120,8 @@ public function __construct($isSupervisor = false, $isConditional = false) /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return Font */ - public function getSharedComponent() + public function getSharedComponent(): self { /** @var Style */ $parent = $this->parent; @@ -217,10 +215,8 @@ public function applyFromArray(array $styleArray): static /** * Get Name. - * - * @return null|string */ - public function getName() + public function getName(): ?string { if ($this->isSupervisor) { return $this->getSharedComponent()->getName(); @@ -332,10 +328,8 @@ public function setComplexScript(string $fontname): self /** * Get Size. - * - * @return null|float */ - public function getSize() + public function getSize(): ?float { if ($this->isSupervisor) { return $this->getSharedComponent()->getSize(); @@ -377,10 +371,8 @@ public function setSize(mixed $sizeInPoints, bool $nullOk = false): static /** * Get Bold. - * - * @return null|bool */ - public function getBold() + public function getBold(): ?bool { if ($this->isSupervisor) { return $this->getSharedComponent()->getBold(); @@ -413,10 +405,8 @@ public function setBold($bold): static /** * Get Italic. - * - * @return null|bool */ - public function getItalic() + public function getItalic(): ?bool { if ($this->isSupervisor) { return $this->getSharedComponent()->getItalic(); @@ -449,10 +439,8 @@ public function setItalic($italic): static /** * Get Superscript. - * - * @return null|bool */ - public function getSuperscript() + public function getSuperscript(): ?bool { if ($this->isSupervisor) { return $this->getSharedComponent()->getSuperscript(); @@ -483,10 +471,8 @@ public function setSuperscript(bool $superscript): static /** * Get Subscript. - * - * @return null|bool */ - public function getSubscript() + public function getSubscript(): ?bool { if ($this->isSupervisor) { return $this->getSharedComponent()->getSubscript(); @@ -620,10 +606,8 @@ public function setChartColorFromObject(?ChartColor $chartColor): self /** * Get Underline. - * - * @return null|string */ - public function getUnderline() + public function getUnderline(): ?string { if ($this->isSupervisor) { return $this->getSharedComponent()->getUnderline(); @@ -660,10 +644,8 @@ public function setUnderline($underlineStyle): static /** * Get Strikethrough. - * - * @return null|bool */ - public function getStrikethrough() + public function getStrikethrough(): ?bool { if ($this->isSupervisor) { return $this->getSharedComponent()->getStrikethrough(); @@ -697,10 +679,8 @@ public function setStrikethrough($strikethru): static /** * Get Color. - * - * @return Color */ - public function getColor() + public function getColor(): Color { return $this->color; } diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 39395797c3..ebb8dbf9eb 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -136,10 +136,8 @@ public function __construct($isSupervisor = false, $isConditional = false) /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return NumberFormat */ - public function getSharedComponent() + public function getSharedComponent(): self { /** @var Style */ $parent = $this->parent; @@ -187,10 +185,8 @@ public function applyFromArray(array $styleArray): static /** * Get Format Code. - * - * @return null|string */ - public function getFormatCode() + public function getFormatCode(): ?string { if ($this->isSupervisor) { return $this->getSharedComponent()->getFormatCode(); @@ -366,10 +362,8 @@ private static function fillBuiltInFormatCodes(): void * Get built-in format code. * * @param int $index - * - * @return string */ - public static function builtInFormatCode($index) + public static function builtInFormatCode($index): string { // Clean parameter $index = (int) $index; @@ -433,7 +427,7 @@ public function getHashCode(): string * * @return string Formatted string */ - public static function toFormattedString(mixed $value, $format, $callBack = null) + public static function toFormattedString(mixed $value, $format, $callBack = null): string { return NumberFormat\Formatter::toFormattedString($value, $format, $callBack); } diff --git a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php index 1115467de4..2d0919d510 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php @@ -114,7 +114,7 @@ private static function splitFormatForSectionSelection(array $sections, mixed $v * * @return string Formatted string */ - public static function toFormattedString($value, $format, $callBack = null) + public static function toFormattedString($value, $format, $callBack = null): string { if (is_bool($value)) { return $value ? Calculation::getTRUE() : Calculation::getFALSE(); diff --git a/src/PhpSpreadsheet/Style/Protection.php b/src/PhpSpreadsheet/Style/Protection.php index 1708098858..9255ba7fe1 100644 --- a/src/PhpSpreadsheet/Style/Protection.php +++ b/src/PhpSpreadsheet/Style/Protection.php @@ -44,10 +44,8 @@ public function __construct($isSupervisor = false, $isConditional = false) /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return Protection */ - public function getSharedComponent() + public function getSharedComponent(): self { /** @var Style */ $parent = $this->parent; diff --git a/src/PhpSpreadsheet/Style/Style.php b/src/PhpSpreadsheet/Style/Style.php index 553b81f90a..23d7e66dfe 100644 --- a/src/PhpSpreadsheet/Style/Style.php +++ b/src/PhpSpreadsheet/Style/Style.php @@ -542,10 +542,8 @@ private function getOldXfIndexes(string $selectionType, array $rangeStart, array /** * Get Fill. - * - * @return Fill */ - public function getFill() + public function getFill(): Fill { return $this->fill; } @@ -572,30 +570,24 @@ public function setFont(Font $font): static /** * Get Borders. - * - * @return Borders */ - public function getBorders() + public function getBorders(): Borders { return $this->borders; } /** * Get Alignment. - * - * @return Alignment */ - public function getAlignment() + public function getAlignment(): Alignment { return $this->alignment; } /** * Get Number Format. - * - * @return NumberFormat */ - public function getNumberFormat() + public function getNumberFormat(): NumberFormat { return $this->numberFormat; } @@ -626,20 +618,16 @@ public function setConditionalStyles(array $conditionalStyleArray): static /** * Get Protection. - * - * @return Protection */ - public function getProtection() + public function getProtection(): Protection { return $this->protection; } /** * Get quote prefix. - * - * @return bool */ - public function getQuotePrefix() + public function getQuotePrefix(): bool { if ($this->isSupervisor) { return $this->getSharedComponent()->getQuotePrefix(); @@ -691,10 +679,8 @@ public function getHashCode(): string /** * Get own index in style collection. - * - * @return int */ - public function getIndex() + public function getIndex(): int { return $this->index; } diff --git a/src/PhpSpreadsheet/Style/Supervisor.php b/src/PhpSpreadsheet/Style/Supervisor.php index 346bee7e1d..bbae57ceee 100644 --- a/src/PhpSpreadsheet/Style/Supervisor.php +++ b/src/PhpSpreadsheet/Style/Supervisor.php @@ -56,20 +56,16 @@ public function bindParent($parent, $parentPropertyName = null) /** * Is this a supervisor or a cell style component? - * - * @return bool */ - public function getIsSupervisor() + public function getIsSupervisor(): bool { return $this->isSupervisor; } /** * Get the currently active sheet. Only used for supervisor. - * - * @return Worksheet */ - public function getActiveSheet() + public function getActiveSheet(): Worksheet { return $this->parent->getActiveSheet(); } @@ -80,7 +76,7 @@ public function getActiveSheet() * * @return string E.g. 'A1' */ - public function getSelectedCells() + public function getSelectedCells(): string { return $this->getActiveSheet()->getSelectedCells(); } @@ -91,7 +87,7 @@ public function getSelectedCells() * * @return string E.g. 'A1' */ - public function getActiveCell() + public function getActiveCell(): string { return $this->getActiveSheet()->getActiveCell(); } @@ -153,17 +149,13 @@ final protected function exportArray2(array &$exportedArray, string $index, mixe /** * Get the shared style component for the currently active cell in currently active sheet. * Only used for style supervisor. - * - * @return mixed */ - abstract public function getSharedComponent(); + abstract public function getSharedComponent(): mixed; /** * Build style array from subcomponents. * * @param array $array - * - * @return array */ - abstract public function getStyleArray($array); + abstract public function getStyleArray($array): array; } diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index 1fe05ac8d4..2e65105315 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -101,10 +101,8 @@ public function setEvaluatedFalse(): void /** * Get AutoFilter column index as string eg: 'A'. - * - * @return string */ - public function getColumnIndex() + public function getColumnIndex(): string { return $this->columnIndex; } @@ -132,10 +130,8 @@ public function setColumnIndex($column): static /** * Get this Column's AutoFilter Parent. - * - * @return null|AutoFilter */ - public function getParent() + public function getParent(): ?AutoFilter { return $this->parent; } @@ -155,10 +151,8 @@ public function setParent(?AutoFilter $parent = null): static /** * Get AutoFilter Type. - * - * @return string */ - public function getFilterType() + public function getFilterType(): string { return $this->filterType; } @@ -187,10 +181,8 @@ public function setFilterType($filterType): static /** * Get AutoFilter Multiple Rules And/Or Join. - * - * @return string */ - public function getJoin() + public function getJoin(): string { return $this->join; } @@ -252,7 +244,7 @@ public function setAttribute($name, $value): static * * @return int[]|string[] */ - public function getAttributes() + public function getAttributes(): array { return $this->attributes; } @@ -283,7 +275,7 @@ public function ruleCount(): int * * @return Column\Rule[] */ - public function getRules() + public function getRules(): array { return $this->ruleset; } @@ -292,10 +284,8 @@ public function getRules() * Get a specified AutoFilter Column Rule. * * @param int $index Rule index in the ruleset array - * - * @return Column\Rule */ - public function getRule($index) + public function getRule($index): Column\Rule { if (!isset($this->ruleset[$index])) { $this->ruleset[$index] = new Column\Rule($this); diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index b70bccd26f..2edbc7874a 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -213,10 +213,8 @@ private function setEvaluatedFalse(): void /** * Get AutoFilter Rule Type. - * - * @return string */ - public function getRuleType() + public function getRuleType(): string { return $this->ruleType; } @@ -285,10 +283,8 @@ public function setValue($value): static /** * Get AutoFilter Rule Operator. - * - * @return string */ - public function getOperator() + public function getOperator(): string { return $this->operator; } @@ -319,10 +315,8 @@ public function setOperator($operator): static /** * Get AutoFilter Rule Grouping. - * - * @return string */ - public function getGrouping() + public function getGrouping(): string { return $this->grouping; } @@ -379,7 +373,7 @@ public function setRule($operator, $value, $grouping = null): static * * @return ?Column */ - public function getParent() + public function getParent(): ?Column { return $this->parent; } diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index 6218482049..f0dcc5e493 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -77,10 +77,8 @@ public function getMediaFilename(): string /** * Get Path. - * - * @return string */ - public function getPath() + public function getPath(): string { return $this->path; } diff --git a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php index 188e4e8cb5..4b6c1aef62 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php @@ -73,10 +73,8 @@ public function __construct() /** * Get Visible. - * - * @return bool */ - public function getVisible() + public function getVisible(): bool { return $this->visible; } @@ -97,10 +95,8 @@ public function setVisible($visible): static /** * Get Blur radius. - * - * @return int */ - public function getBlurRadius() + public function getBlurRadius(): int { return $this->blurRadius; } @@ -121,10 +117,8 @@ public function setBlurRadius($blurRadius): static /** * Get Shadow distance. - * - * @return int */ - public function getDistance() + public function getDistance(): int { return $this->distance; } @@ -145,10 +139,8 @@ public function setDistance($distance): static /** * Get Shadow direction (in degrees). - * - * @return int */ - public function getDirection() + public function getDirection(): int { return $this->direction; } @@ -169,10 +161,8 @@ public function setDirection($direction): static /** * Get Shadow alignment. - * - * @return string */ - public function getAlignment() + public function getAlignment(): string { return $this->alignment; } @@ -193,10 +183,8 @@ public function setAlignment($alignment): static /** * Get Color. - * - * @return Color */ - public function getColor() + public function getColor(): Color { return $this->color; } @@ -215,10 +203,8 @@ public function setColor(Color $color): static /** * Get Alpha. - * - * @return int */ - public function getAlpha() + public function getAlpha(): int { return $this->alpha; } diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index 4421cc5f2f..61f16feb0a 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -139,10 +139,8 @@ public function __construct() /** * Get OddHeader. - * - * @return string */ - public function getOddHeader() + public function getOddHeader(): string { return $this->oddHeader; } @@ -163,10 +161,8 @@ public function setOddHeader($oddHeader): static /** * Get OddFooter. - * - * @return string */ - public function getOddFooter() + public function getOddFooter(): string { return $this->oddFooter; } @@ -187,10 +183,8 @@ public function setOddFooter($oddFooter): static /** * Get EvenHeader. - * - * @return string */ - public function getEvenHeader() + public function getEvenHeader(): string { return $this->evenHeader; } @@ -211,10 +205,8 @@ public function setEvenHeader($eventHeader): static /** * Get EvenFooter. - * - * @return string */ - public function getEvenFooter() + public function getEvenFooter(): string { return $this->evenFooter; } @@ -235,10 +227,8 @@ public function setEvenFooter($evenFooter): static /** * Get FirstHeader. - * - * @return string */ - public function getFirstHeader() + public function getFirstHeader(): string { return $this->firstHeader; } @@ -259,10 +249,8 @@ public function setFirstHeader($firstHeader): static /** * Get FirstFooter. - * - * @return string */ - public function getFirstFooter() + public function getFirstFooter(): string { return $this->firstFooter; } @@ -283,10 +271,8 @@ public function setFirstFooter($firstFooter): static /** * Get DifferentOddEven. - * - * @return bool */ - public function getDifferentOddEven() + public function getDifferentOddEven(): bool { return $this->differentOddEven; } @@ -307,10 +293,8 @@ public function setDifferentOddEven($differentOddEvent): static /** * Get DifferentFirst. - * - * @return bool */ - public function getDifferentFirst() + public function getDifferentFirst(): bool { return $this->differentFirst; } @@ -331,10 +315,8 @@ public function setDifferentFirst($differentFirst): static /** * Get ScaleWithDocument. - * - * @return bool */ - public function getScaleWithDocument() + public function getScaleWithDocument(): bool { return $this->scaleWithDocument; } @@ -355,10 +337,8 @@ public function setScaleWithDocument($scaleWithDocument): static /** * Get AlignWithMargins. - * - * @return bool */ - public function getAlignWithMargins() + public function getAlignWithMargins(): bool { return $this->alignWithMargins; } diff --git a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php index 817816b191..f6f4c29784 100644 --- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php @@ -263,10 +263,8 @@ public function setImageResource(?GdImage $value): static /** * Get rendering function. - * - * @return string */ - public function getRenderingFunction() + public function getRenderingFunction(): string { return $this->renderingFunction; } @@ -287,10 +285,8 @@ public function setRenderingFunction($value): static /** * Get mime type. - * - * @return string */ - public function getMimeType() + public function getMimeType(): string { return $this->mimeType; } diff --git a/src/PhpSpreadsheet/Worksheet/PageMargins.php b/src/PhpSpreadsheet/Worksheet/PageMargins.php index d19834c616..6a13a6ebb1 100644 --- a/src/PhpSpreadsheet/Worksheet/PageMargins.php +++ b/src/PhpSpreadsheet/Worksheet/PageMargins.php @@ -43,10 +43,8 @@ public function __construct() /** * Get Left. - * - * @return float */ - public function getLeft() + public function getLeft(): float { return $this->left; } @@ -67,10 +65,8 @@ public function setLeft($left): static /** * Get Right. - * - * @return float */ - public function getRight() + public function getRight(): float { return $this->right; } @@ -91,10 +87,8 @@ public function setRight($right): static /** * Get Top. - * - * @return float */ - public function getTop() + public function getTop(): float { return $this->top; } @@ -115,10 +109,8 @@ public function setTop($top): static /** * Get Bottom. - * - * @return float */ - public function getBottom() + public function getBottom(): float { return $this->bottom; } @@ -139,10 +131,8 @@ public function setBottom($bottom): static /** * Get Header. - * - * @return float */ - public function getHeader() + public function getHeader(): float { return $this->header; } @@ -163,10 +153,8 @@ public function setHeader($header): static /** * Get Footer. - * - * @return float */ - public function getFooter() + public function getFooter(): float { return $this->footer; } diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 17c8a0edb6..1d6aee3d67 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -255,10 +255,8 @@ public function __construct() /** * Get Paper Size. - * - * @return int */ - public function getPaperSize() + public function getPaperSize(): int { return $this->paperSize ?? self::$paperSizeDefault; } @@ -295,10 +293,8 @@ public static function setPaperSizeDefault(int $paperSize): void /** * Get Orientation. - * - * @return string */ - public function getOrientation() + public function getOrientation(): string { return $this->orientation; } @@ -333,10 +329,8 @@ public static function setOrientationDefault(string $orientation): void /** * Get Scale. - * - * @return null|int */ - public function getScale() + public function getScale(): ?int { return $this->scale; } @@ -369,10 +363,8 @@ public function setScale($scale, $update = true): static /** * Get Fit To Page. - * - * @return bool */ - public function getFitToPage() + public function getFitToPage(): bool { return $this->fitToPage; } @@ -393,10 +385,8 @@ public function setFitToPage($fitToPage): static /** * Get Fit To Height. - * - * @return null|int */ - public function getFitToHeight() + public function getFitToHeight(): ?int { return $this->fitToHeight; } @@ -421,10 +411,8 @@ public function setFitToHeight($fitToHeight, $update = true): static /** * Get Fit To Width. - * - * @return null|int */ - public function getFitToWidth() + public function getFitToWidth(): ?int { return $this->fitToWidth; } @@ -466,7 +454,7 @@ public function isColumnsToRepeatAtLeftSet(): bool * * @return array Containing start column and end column, empty array if option unset */ - public function getColumnsToRepeatAtLeft() + public function getColumnsToRepeatAtLeft(): array { return $this->columnsToRepeatAtLeft; } @@ -519,7 +507,7 @@ public function isRowsToRepeatAtTopSet(): bool * * @return array Containing start column and end column, empty array if option unset */ - public function getRowsToRepeatAtTop() + public function getRowsToRepeatAtTop(): array { return $this->rowsToRepeatAtTop; } @@ -555,10 +543,8 @@ public function setRowsToRepeatAtTopByStartAndEnd($start, $end): static /** * Get center page horizontally. - * - * @return bool */ - public function getHorizontalCentered() + public function getHorizontalCentered(): bool { return $this->horizontalCentered; } @@ -579,10 +565,8 @@ public function setHorizontalCentered($value): static /** * Get center page vertically. - * - * @return bool */ - public function getVerticalCentered() + public function getVerticalCentered(): bool { return $this->verticalCentered; } @@ -608,10 +592,8 @@ public function setVerticalCentered($value): static * Default behaviour, or a index value of 0, will return all ranges as a comma-separated string * Otherwise, the specific range identified by the value of $index will be returned * Print areas are numbered from 1 - * - * @return string */ - public function getPrintArea($index = 0) + public function getPrintArea($index = 0): string { if ($index == 0) { return (string) $this->printArea; @@ -816,7 +798,7 @@ public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $in * * @return ?int */ - public function getFirstPageNumber() + public function getFirstPageNumber(): ?int { return $this->firstPageNumber; } diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index 4f347902ce..dda7df3948 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -343,10 +343,8 @@ public function setSelectUnlockedCells(?bool $selectUnlockedCells): self /** * Get hashed password. - * - * @return string */ - public function getPassword() + public function getPassword(): string { return $this->password; } diff --git a/src/PhpSpreadsheet/Worksheet/RowDimension.php b/src/PhpSpreadsheet/Worksheet/RowDimension.php index f18686863c..b31eea96a7 100644 --- a/src/PhpSpreadsheet/Worksheet/RowDimension.php +++ b/src/PhpSpreadsheet/Worksheet/RowDimension.php @@ -62,10 +62,8 @@ public function setRowIndex(int $index): static * By default, this will be in points; but this method also accepts an optional unit of measure * argument, and will convert the value from points to the specified UoM. * A value of -1 tells Excel to display this column in its default height. - * - * @return float */ - public function getRowHeight(?string $unitOfMeasure = null) + public function getRowHeight(?string $unitOfMeasure = null): float { return ($unitOfMeasure === null || $this->height < 0) ? $this->height diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index fda64e68ca..1fdf7d1460 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -62,7 +62,7 @@ public function __construct() * * @return ?int */ - public function getZoomScale() + public function getZoomScale(): ?int { return $this->zoomScale; } @@ -93,7 +93,7 @@ public function setZoomScale($zoomScale): static * * @return ?int */ - public function getZoomScaleNormal() + public function getZoomScaleNormal(): ?int { return $this->zoomScaleNormal; } @@ -127,20 +127,15 @@ public function setShowZeros($showZeros): void $this->showZeros = $showZeros; } - /** - * @return bool - */ - public function getShowZeros() + public function getShowZeros(): bool { return $this->showZeros; } /** * Get View. - * - * @return string */ - public function getView() + public function getView(): string { return $this->sheetviewType; } diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index fa557daebb..963f534516 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -384,10 +384,8 @@ public function __destruct() /** * Return the cell collection. - * - * @return Cells */ - public function getCellCollection() + public function getCellCollection(): Cells { // @phpstan-ignore-next-line return $this->cellCollection; @@ -395,10 +393,8 @@ public function getCellCollection() /** * Get array of invalid characters for sheet title. - * - * @return array */ - public static function getInvalidCharacters() + public static function getInvalidCharacters(): array { return self::$invalidCharacters; } @@ -480,17 +476,15 @@ public function getCoordinates($sorted = true): array * * @return RowDimension[] */ - public function getRowDimensions() + public function getRowDimensions(): array { return $this->rowDimensions; } /** * Get default row dimension. - * - * @return RowDimension */ - public function getDefaultRowDimension() + public function getDefaultRowDimension(): RowDimension { return $this->defaultRowDimension; } @@ -500,7 +494,7 @@ public function getDefaultRowDimension() * * @return ColumnDimension[] */ - public function getColumnDimensions() + public function getColumnDimensions(): array { /** @var callable */ $callable = [self::class, 'columnDimensionCompare']; @@ -516,10 +510,8 @@ private static function columnDimensionCompare(ColumnDimension $a, ColumnDimensi /** * Get default column dimension. - * - * @return ColumnDimension */ - public function getDefaultColumnDimension() + public function getDefaultColumnDimension(): ColumnDimension { return $this->defaultColumnDimension; } @@ -529,7 +521,7 @@ public function getDefaultColumnDimension() * * @return ArrayObject */ - public function getDrawingCollection() + public function getDrawingCollection(): ArrayObject { return $this->drawingCollection; } @@ -539,7 +531,7 @@ public function getDrawingCollection() * * @return ArrayObject */ - public function getChartCollection() + public function getChartCollection(): ArrayObject { return $this->chartCollection; } @@ -824,10 +816,8 @@ public function rebindParent(Spreadsheet $parent): static /** * Get title. - * - * @return string */ - public function getTitle() + public function getTitle(): string { return $this->title; } @@ -909,7 +899,7 @@ public function setTitle($title, $updateFormulaCellReferences = true, $validate * * @return string Sheet state (visible, hidden, veryHidden) */ - public function getSheetState() + public function getSheetState(): string { return $this->sheetState; } @@ -930,10 +920,8 @@ public function setSheetState($value): static /** * Get page setup. - * - * @return PageSetup */ - public function getPageSetup() + public function getPageSetup(): PageSetup { return $this->pageSetup; } @@ -952,10 +940,8 @@ public function setPageSetup(PageSetup $pageSetup): static /** * Get page margins. - * - * @return PageMargins */ - public function getPageMargins() + public function getPageMargins(): PageMargins { return $this->pageMargins; } @@ -974,10 +960,8 @@ public function setPageMargins(PageMargins $pageMargins): static /** * Get page header/footer. - * - * @return HeaderFooter */ - public function getHeaderFooter() + public function getHeaderFooter(): HeaderFooter { return $this->headerFooter; } @@ -996,10 +980,8 @@ public function setHeaderFooter(HeaderFooter $headerFooter): static /** * Get sheet view. - * - * @return SheetView */ - public function getSheetView() + public function getSheetView(): SheetView { return $this->sheetView; } @@ -1018,10 +1000,8 @@ public function setSheetView(SheetView $sheetView): static /** * Get Protection. - * - * @return Protection */ - public function getProtection() + public function getProtection(): Protection { return $this->protection; } @@ -1047,7 +1027,7 @@ public function setProtection(Protection $protection): static * * @return string Highest column name */ - public function getHighestColumn($row = null) + public function getHighestColumn($row = null): string { if ($row === null) { return Coordinate::stringFromColumnIndex($this->cachedHighestColumn); @@ -1064,7 +1044,7 @@ public function getHighestColumn($row = null) * * @return string Highest column name that contains data */ - public function getHighestDataColumn($row = null) + public function getHighestDataColumn($row = null): string { return $this->getCellCollection()->getHighestColumn($row); } @@ -1077,7 +1057,7 @@ public function getHighestDataColumn($row = null) * * @return int Highest row number */ - public function getHighestRow($column = null) + public function getHighestRow($column = null): int { if ($column === null) { return $this->cachedHighestRow; @@ -1094,7 +1074,7 @@ public function getHighestRow($column = null) * * @return int Highest row number that contains data */ - public function getHighestDataRow($column = null) + public function getHighestDataRow($column = null): int { return $this->getCellCollection()->getHighestRow($column); } @@ -1474,7 +1454,7 @@ public function getColumnDimensionByColumn(int $columnIndex): ColumnDimension * * @return Style[] */ - public function getStyles() + public function getStyles(): array { return $this->styles; } @@ -1611,10 +1591,8 @@ public function removeConditionalStyles($coordinate): static /** * Get collection of conditional styles. - * - * @return array */ - public function getConditionalStylesCollection() + public function getConditionalStylesCollection(): array { return $this->conditionalStylesCollection; } @@ -1787,7 +1765,7 @@ public function getBreaks(): array * * @return PageBreak[] */ - public function getRowBreaks() + public function getRowBreaks(): array { /** @var callable */ $compareFunction = [self::class, 'compareRowBreaks']; @@ -1817,7 +1795,7 @@ protected static function compareColumnBreaks(string $coordinate1, string $coord * * @return PageBreak[] */ - public function getColumnBreaks() + public function getColumnBreaks(): array { /** @var callable */ $compareFunction = [self::class, 'compareColumnBreaks']; @@ -2039,7 +2017,7 @@ public function unmergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, * * @return string[] */ - public function getMergeCells() + public function getMergeCells(): array { return $this->mergeCells; } @@ -2163,17 +2141,15 @@ public function unprotectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2 * * @return string[] */ - public function getProtectedCells() + public function getProtectedCells(): array { return $this->protectedCells; } /** * Get Autofilter. - * - * @return AutoFilter */ - public function getAutoFilter() + public function getAutoFilter(): AutoFilter { return $this->autoFilter; } @@ -2242,7 +2218,7 @@ public function removeAutoFilter(): self * * @return ArrayObject */ - public function getTableCollection() + public function getTableCollection(): ArrayObject { return $this->tableCollection; } @@ -2335,10 +2311,8 @@ public function removeTableCollection(): self /** * Get Freeze Pane. - * - * @return null|string */ - public function getFreezePane() + public function getFreezePane(): ?string { return $this->freezePane; } @@ -2447,10 +2421,8 @@ public function unfreezePane(): static /** * Get the default position of the right bottom pane. - * - * @return null|string */ - public function getTopLeftCell() + public function getTopLeftCell(): ?string { return $this->topLeftCell; } @@ -2487,7 +2459,7 @@ public function setPane(string $position, ?Pane $pane): self } /** @return (null|Pane)[] */ - public function getPanes() + public function getPanes(): array { return $this->panes; } @@ -2864,7 +2836,7 @@ public function setShowSummaryRight(bool $showSummaryRight): self * * @return Comment[] */ - public function getComments() + public function getComments(): array { return $this->comments; } @@ -2961,17 +2933,15 @@ public function getCommentByColumnAndRow($columnIndex, $row): Comment * * @return string Example: 'A1' */ - public function getActiveCell() + public function getActiveCell(): string { return $this->activeCell; } /** * Get selected cells. - * - * @return string */ - public function getSelectedCells() + public function getSelectedCells(): string { return $this->selectedCells; } @@ -3055,10 +3025,8 @@ public function setSelectedCellByColumnAndRow($columnIndex, $row): static /** * Get right-to-left. - * - * @return bool */ - public function getRightToLeft() + public function getRightToLeft(): bool { return $this->rightToLeft; } @@ -3123,10 +3091,8 @@ public function fromArray(array $source, mixed $nullValue = null, $startCell = ' /** * @throws Exception * @throws \PhpOffice\PhpSpreadsheet\Calculation\Exception - * - * @return mixed */ - protected function cellToArray(Cell $cell, bool $calculateFormulas, bool $formatData, mixed $nullValue) + protected function cellToArray(Cell $cell, bool $calculateFormulas, bool $formatData, mixed $nullValue): mixed { $returnValue = $nullValue; @@ -3416,10 +3382,8 @@ public static function extractSheetTitle($range, $returnRange = false): array|nu * Get hyperlink. * * @param string $cellCoordinate Cell coordinate to get hyperlink for, eg: 'A1' - * - * @return Hyperlink */ - public function getHyperlink($cellCoordinate) + public function getHyperlink($cellCoordinate): Hyperlink { // return hyperlink if we already have one if (isset($this->hyperlinkCollection[$cellCoordinate])) { @@ -3465,7 +3429,7 @@ public function hyperlinkExists($coordinate): bool * * @return Hyperlink[] */ - public function getHyperlinkCollection() + public function getHyperlinkCollection(): array { return $this->hyperlinkCollection; } @@ -3474,10 +3438,8 @@ public function getHyperlinkCollection() * Get data validation. * * @param string $cellCoordinate Cell coordinate to get data validation for, eg: 'A1' - * - * @return DataValidation */ - public function getDataValidation($cellCoordinate) + public function getDataValidation($cellCoordinate): DataValidation { // return data validation if we already have one if (isset($this->dataValidationCollection[$cellCoordinate])) { @@ -3523,7 +3485,7 @@ public function dataValidationExists($coordinate): bool * * @return DataValidation[] */ - public function getDataValidationCollection() + public function getDataValidationCollection(): array { return $this->dataValidationCollection; } @@ -3566,10 +3528,8 @@ public function shrinkRangeToFit($range): string /** * Get tab color. - * - * @return Color */ - public function getTabColor() + public function getTabColor(): Color { if ($this->tabColor === null) { $this->tabColor = new Color(); @@ -3761,10 +3721,8 @@ public function setCodeName($codeName, $validate = true): static /** * Return the code name of the sheet. - * - * @return null|string */ - public function getCodeName() + public function getCodeName(): ?string { return $this->codeName; } diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index a523d80f6f..c7ae9bf501 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -152,10 +152,8 @@ public function save($filename, int $flags = 0): void /** * Save Spreadsheet as html to variable. - * - * @return string */ - public function generateHtmlAll() + public function generateHtmlAll(): string { // garbage collect $this->spreadsheet->garbageCollect(); @@ -274,10 +272,8 @@ public function setSheetIndex($sheetIndex): static /** * Get sheet index. - * - * @return bool */ - public function getGenerateSheetNavigationBlock() + public function getGenerateSheetNavigationBlock(): bool { return $this->generateSheetNavigationBlock; } @@ -613,10 +609,8 @@ private function extendRowsForChartsAndImages(Worksheet $worksheet, int $row): s * Convert Windows file name to file protocol URL. * * @param string $filename file name on local system - * - * @return string */ - public static function winFileToUrl($filename, bool $mpdf = false) + public static function winFileToUrl($filename, bool $mpdf = false): string { // Windows filename if (substr($filename, 1, 2) === ':\\') { @@ -901,10 +895,8 @@ private function buildCssPerSheet(Worksheet $sheet, array &$css): void * Build CSS styles. * * @param bool $generateSurroundingHTML Generate surrounding HTML style? (html { }) - * - * @return array */ - public function buildCSS($generateSurroundingHTML = true) + public function buildCSS($generateSurroundingHTML = true): array { // Cached? if ($this->cssStyles !== null) { @@ -1105,10 +1097,8 @@ private function createCSSStyleBorder(Border $border): string * Create CSS style (Fill). * * @param Fill $fill Fill - * - * @return array */ - private function createCSSStyleFill(Fill $fill) + private function createCSSStyleFill(Fill $fill): array { // Construct HTML $css = []; @@ -1172,10 +1162,8 @@ private function generateTableTag(Worksheet $worksheet, string $id, string &$htm * * @param Worksheet $worksheet The worksheet for the table we are writing * @param bool $showid whether or not to add id to table tag - * - * @return string */ - private function generateTableHeader(Worksheet $worksheet, bool $showid = true) + private function generateTableHeader(Worksheet $worksheet, bool $showid = true): string { $sheetIndex = $worksheet->getParentOrThrow()->getIndex($worksheet); @@ -1547,10 +1535,8 @@ private function assembleCSS(array $values = []): string /** * Get images root. - * - * @return string */ - public function getImagesRoot() + public function getImagesRoot(): string { return $this->imagesRoot; } @@ -1571,10 +1557,8 @@ public function setImagesRoot($imagesRoot): static /** * Get embed images. - * - * @return bool */ - public function getEmbedImages() + public function getEmbedImages(): bool { return $this->embedImages; } @@ -1595,10 +1579,8 @@ public function setEmbedImages($embedImages): static /** * Get use inline CSS? - * - * @return bool */ - public function getUseInlineCss() + public function getUseInlineCss(): bool { return $this->useInlineCss; } @@ -1620,13 +1602,11 @@ public function setUseInlineCss($useInlineCss): static /** * Get use embedded CSS? * - * @return bool - * * @codeCoverageIgnore * * @deprecated no longer used */ - public function getUseEmbeddedCSS() + public function getUseEmbeddedCSS(): bool { return $this->useEmbeddedCSS; } diff --git a/src/PhpSpreadsheet/Writer/Ods.php b/src/PhpSpreadsheet/Writer/Ods.php index fd5a8a825e..638c16f1e1 100644 --- a/src/PhpSpreadsheet/Writer/Ods.php +++ b/src/PhpSpreadsheet/Writer/Ods.php @@ -137,10 +137,8 @@ private function createZip(): ZipStream /** * Get Spreadsheet object. - * - * @return Spreadsheet */ - public function getSpreadsheet() + public function getSpreadsheet(): Spreadsheet { return $this->spreadSheet; } diff --git a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php index 67b0f6b717..366fdd90af 100644 --- a/src/PhpSpreadsheet/Writer/Ods/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Ods/WriterPart.php @@ -13,10 +13,8 @@ abstract class WriterPart /** * Get Ods writer. - * - * @return Ods */ - public function getParentWriter() + public function getParentWriter(): Ods { return $this->parentWriter; } diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index 0ba4ba5379..6526890b88 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -118,10 +118,8 @@ public function __construct(Spreadsheet $spreadsheet) /** * Get Font. - * - * @return string */ - public function getFont() + public function getFont(): string { return $this->font; } @@ -149,7 +147,7 @@ public function setFont($fontName) * * @return ?int */ - public function getPaperSize() + public function getPaperSize(): ?int { return $this->paperSize; } @@ -158,10 +156,8 @@ public function getPaperSize() * Set Paper Size. * * @param int $paperSize Paper size see PageSetup::PAPERSIZE_* - * - * @return self */ - public function setPaperSize($paperSize) + public function setPaperSize($paperSize): self { $this->paperSize = $paperSize; @@ -180,10 +176,8 @@ public function getOrientation(): ?string * Set Orientation. * * @param string $orientation Page orientation see PageSetup::ORIENTATION_* - * - * @return self */ - public function setOrientation($orientation) + public function setOrientation($orientation): self { $this->orientation = $orientation; @@ -192,10 +186,8 @@ public function setOrientation($orientation) /** * Get temporary storage directory. - * - * @return string */ - public function getTempDir() + public function getTempDir(): string { return $this->tempDir; } @@ -204,10 +196,8 @@ public function getTempDir() * Set temporary storage directory. * * @param string $temporaryDirectory Temporary storage directory - * - * @return self */ - public function setTempDir($temporaryDirectory) + public function setTempDir($temporaryDirectory): self { if (is_dir($temporaryDirectory)) { $this->tempDir = $temporaryDirectory; diff --git a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php index f9cafb043b..6569980aca 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Dompdf.php @@ -17,7 +17,7 @@ class Dompdf extends Pdf * * @return \Dompdf\Dompdf implementation */ - protected function createExternalWriterInstance() + protected function createExternalWriterInstance(): \Dompdf\Dompdf { return new \Dompdf\Dompdf(); } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index 53b79d2ad1..45a55de54d 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -19,7 +19,7 @@ class Mpdf extends Pdf * * @return \Mpdf\Mpdf implementation */ - protected function createExternalWriterInstance($config) + protected function createExternalWriterInstance($config): \Mpdf\Mpdf { return new \Mpdf\Mpdf($config); } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php index aefc6b56d0..972964c593 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -28,7 +28,7 @@ public function __construct(Spreadsheet $spreadsheet) * * @return \TCPDF implementation */ - protected function createExternalWriterInstance($orientation, $unit, $paperSize) + protected function createExternalWriterInstance($orientation, $unit, $paperSize): \TCPDF { return new \TCPDF($orientation, $unit, $paperSize); } diff --git a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php index b4fcb208b1..5d8121ae23 100644 --- a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php @@ -75,10 +75,8 @@ public function __construct() /** * Determine the byte order and store it as class data to avoid * recalculating it for each call to new(). - * - * @return int */ - public static function getByteOrder() + public static function getByteOrder(): int { if (!isset(self::$byteOrder)) { // Check if "pack" gives the required IEEE 64bit float @@ -116,10 +114,8 @@ protected function append($data): void * General storage function like append, but returns string instead of modifying $this->_data. * * @param string $data binary data to write - * - * @return string */ - public function writeData($data) + public function writeData($data): string { if (strlen($data) - 4 > $this->limit) { $data = $this->addContinue($data); @@ -190,7 +186,7 @@ public function writeEof(): string * * @return string A very convenient string of continue blocks */ - private function addContinue($data) + private function addContinue($data): string { $limit = $this->limit; $record = 0x003C; // Record identifier diff --git a/src/PhpSpreadsheet/Writer/Xls/Escher.php b/src/PhpSpreadsheet/Writer/Xls/Escher.php index 118fd80d71..9ce3509113 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Escher.php +++ b/src/PhpSpreadsheet/Writer/Xls/Escher.php @@ -46,10 +46,8 @@ public function __construct(mixed $object) /** * Process the object to be written. - * - * @return string */ - public function close() + public function close(): string { // initialize $this->data = ''; @@ -485,20 +483,16 @@ public function close() /** * Gets the shape offsets. - * - * @return array */ - public function getSpOffsets() + public function getSpOffsets(): array { return $this->spOffsets; } /** * Gets the shape types. - * - * @return array */ - public function getSpTypes() + public function getSpTypes(): array { return $this->spTypes; } diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index 5cd68debb6..1a21b22912 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -125,10 +125,8 @@ private static function mapBold(?bool $bold): int * Map underline. * * @param string $underline - * - * @return int */ - private static function mapUnderline($underline) + private static function mapUnderline($underline): int { if (isset(self::$mapUnderline[$underline])) { return self::$mapUnderline[$underline]; diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index 93d94630a0..0276e5800d 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -835,7 +835,7 @@ private function getRefIndex($ext_ref): string * * @return int The sheet index, -1 if the sheet was not found */ - private function getSheetIndex(string $sheet_name) + private function getSheetIndex(string $sheet_name): int { if (!isset($this->externalSheets[$sheet_name])) { return -1; @@ -1130,7 +1130,7 @@ public function parse($formula): bool * * @return mixed The parsed ptg'd tree on success */ - private function condition() + private function condition(): mixed { $result = $this->expression(); if ($this->currentToken == '<') { @@ -1172,7 +1172,7 @@ private function condition() * * @return mixed The parsed ptg'd tree on success */ - private function expression() + private function expression(): mixed { // If it's a string return a string node if (preg_match('/"([^"]|""){0,255}"/', $this->currentToken)) { @@ -1251,7 +1251,7 @@ private function parenthesizedExpression(): array * * @return mixed The parsed ptg'd tree on success */ - private function term() + private function term(): mixed { $result = $this->fact(); while ( @@ -1282,7 +1282,7 @@ private function term() * * @return mixed The parsed ptg'd tree on success */ - private function fact() + private function fact(): mixed { $currentToken = $this->currentToken; if ($currentToken === '(') { @@ -1381,7 +1381,7 @@ private function fact() * * @return mixed The parsed ptg'd tree on success */ - private function func() + private function func(): mixed { $num_args = 0; // number of arguments received $function = strtoupper($this->currentToken); diff --git a/src/PhpSpreadsheet/Writer/Xls/Workbook.php b/src/PhpSpreadsheet/Writer/Xls/Workbook.php index 030f68654b..c00d545438 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -246,7 +246,7 @@ public function addXfWriter(Style $style, $isStyleXf = false): int * * @return int Index to FONT record */ - public function addFont(\PhpOffice\PhpSpreadsheet\Style\Font $font) + public function addFont(\PhpOffice\PhpSpreadsheet\Style\Font $font): int { $fontHashCode = $font->getHashCode(); if (isset($this->addedFonts[$fontHashCode])) { @@ -272,7 +272,7 @@ public function addFont(\PhpOffice\PhpSpreadsheet\Style\Font $font) * * @return int Color index */ - private function addColor($rgb) + private function addColor($rgb): int { if (!isset($this->colors[$rgb])) { $color @@ -921,10 +921,8 @@ private function writeDateMode(): void /** * Stores the COUNTRY record for localization. - * - * @return string */ - private function writeCountry() + private function writeCountry(): string { $record = 0x008C; // Record identifier $length = 4; // Number of bytes to follow @@ -938,10 +936,8 @@ private function writeCountry() /** * Write the RECALCID record. - * - * @return string */ - private function writeRecalcId() + private function writeRecalcId(): string { $record = 0x01C1; // Record identifier $length = 8; // Number of bytes to follow diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index d925d21b7d..1aa3ce1a5b 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -554,7 +554,7 @@ private function writeBIFF8CellRangeAddressFixed($range): string * * @return string The data */ - public function getData() + public function getData(): string { // Return data stored in memory if (isset($this->_data)) { @@ -773,10 +773,8 @@ public static function getAllowThrow(): bool * @param string $formula The formula text string * @param int $xfIndex The XF format index * @param mixed $calculatedValue Calculated value - * - * @return int */ - private function writeFormula(int $row, int $col, string $formula, int $xfIndex, mixed $calculatedValue) + private function writeFormula(int $row, int $col, string $formula, int $xfIndex, mixed $calculatedValue): int { $record = 0x0006; // Record identifier // Initialize possible additional value for STRING record that should be written after the FORMULA record? diff --git a/src/PhpSpreadsheet/Writer/Xls/Xf.php b/src/PhpSpreadsheet/Writer/Xls/Xf.php index fc6a582351..5524e8ffec 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -335,10 +335,8 @@ public function setFontIndex($value): void * Map to BIFF8 codes for text rotation angle. * * @param int $textRotation - * - * @return int */ - private static function mapTextRotation($textRotation) + private static function mapTextRotation($textRotation): int { if ($textRotation >= 0) { return $textRotation; diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index b276cddfab..0cbda2d825 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -516,10 +516,8 @@ public function save($filename, int $flags = 0): void /** * Get Spreadsheet object. - * - * @return Spreadsheet */ - public function getSpreadsheet() + public function getSpreadsheet(): Spreadsheet { return $this->spreadSheet; } @@ -543,7 +541,7 @@ public function setSpreadsheet(Spreadsheet $spreadsheet): static * * @return string[] */ - public function getStringTable() + public function getStringTable(): array { return $this->stringTable; } @@ -553,7 +551,7 @@ public function getStringTable() * * @return HashTable<\PhpOffice\PhpSpreadsheet\Style\Style> */ - public function getStyleHashTable() + public function getStyleHashTable(): HashTable { return $this->styleHashTable; } @@ -563,7 +561,7 @@ public function getStyleHashTable() * * @return HashTable */ - public function getStylesConditionalHashTable() + public function getStylesConditionalHashTable(): HashTable { return $this->stylesConditionalHashTable; } @@ -573,7 +571,7 @@ public function getStylesConditionalHashTable() * * @return HashTable */ - public function getFillHashTable() + public function getFillHashTable(): HashTable { return $this->fillHashTable; } @@ -583,7 +581,7 @@ public function getFillHashTable() * * @return HashTable */ - public function getFontHashTable() + public function getFontHashTable(): HashTable { return $this->fontHashTable; } @@ -593,7 +591,7 @@ public function getFontHashTable() * * @return HashTable */ - public function getBordersHashTable() + public function getBordersHashTable(): HashTable { return $this->bordersHashTable; } @@ -603,7 +601,7 @@ public function getBordersHashTable() * * @return HashTable */ - public function getNumFmtHashTable() + public function getNumFmtHashTable(): HashTable { return $this->numFmtHashTable; } @@ -613,17 +611,15 @@ public function getNumFmtHashTable() * * @return HashTable */ - public function getDrawingHashTable() + public function getDrawingHashTable(): HashTable { return $this->drawingHashTable; } /** * Get Office2003 compatibility. - * - * @return bool */ - public function getOffice2003Compatibility() + public function getOffice2003Compatibility(): bool { return $this->office2003compatibility; } diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index d25ec4bcb2..51311d2e1c 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -26,7 +26,7 @@ class Chart extends WriterPart * * @return string XML Output */ - public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $chart, mixed $calculateCellValues = true) + public function writeChart(\PhpOffice\PhpSpreadsheet\Chart\Chart $chart, mixed $calculateCellValues = true): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index f2b118b7c5..84141231bb 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -14,7 +14,7 @@ class Comments extends WriterPart * * @return string XML Output */ - public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet) + public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet): string { // Create XML writer $objWriter = null; @@ -90,7 +90,7 @@ private function writeComment(XMLWriter $objWriter, $cellReference, Comment $com * * @return string XML Output */ - public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet) + public function writeVMLComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index 8faa3ffc2d..999a35e77c 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -18,7 +18,7 @@ class ContentTypes extends WriterPart * * @return string XML Output */ - public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = false) + public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = false): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php index 8c33f59326..d426d118b9 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/DocProps.php @@ -15,7 +15,7 @@ class DocProps extends WriterPart * * @return string XML Output */ - public function writeDocPropsApp(Spreadsheet $spreadsheet) + public function writeDocPropsApp(Spreadsheet $spreadsheet): string { // Create XML writer $objWriter = null; @@ -113,7 +113,7 @@ public function writeDocPropsApp(Spreadsheet $spreadsheet) * * @return string XML Output */ - public function writeDocPropsCore(Spreadsheet $spreadsheet) + public function writeDocPropsCore(Spreadsheet $spreadsheet): string { // Create XML writer $objWriter = null; @@ -182,7 +182,7 @@ public function writeDocPropsCore(Spreadsheet $spreadsheet) * * @return null|string XML Output */ - public function writeDocPropsCustom(Spreadsheet $spreadsheet) + public function writeDocPropsCustom(Spreadsheet $spreadsheet): ?string { $customPropertyList = $spreadsheet->getProperties()->getCustomProperties(); if (empty($customPropertyList)) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index 6763b508f2..d90034d65a 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -20,7 +20,7 @@ class Drawing extends WriterPart * * @return string XML Output */ - public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, $includeCharts = false) + public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, $includeCharts = false): string { // Create XML writer $objWriter = null; @@ -356,7 +356,7 @@ public function writeDrawing(XMLWriter $objWriter, BaseDrawing $drawing, $relati * * @return string XML Output */ - public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet) + public function writeVMLHeaderFooterImages(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index 977dc9abf6..c29394fa31 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -16,7 +16,7 @@ class Rels extends WriterPart * * @return string XML Output */ - public function writeRelationships(Spreadsheet $spreadsheet) + public function writeRelationships(Spreadsheet $spreadsheet): string { // Create XML writer $objWriter = null; @@ -88,7 +88,7 @@ public function writeRelationships(Spreadsheet $spreadsheet) * * @return string XML Output */ - public function writeWorkbookRelationships(Spreadsheet $spreadsheet) + public function writeWorkbookRelationships(Spreadsheet $spreadsheet): string { // Create XML writer $objWriter = null; @@ -169,7 +169,7 @@ public function writeWorkbookRelationships(Spreadsheet $spreadsheet) * * @return string XML Output */ - public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, $worksheetId = 1, $includeCharts = false, $tableRef = 1) + public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, $worksheetId = 1, $includeCharts = false, $tableRef = 1): string { // Create XML writer $objWriter = null; @@ -315,7 +315,7 @@ private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\W * * @return string XML Output */ - public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, &$chartRef, $includeCharts = false) + public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, &$chartRef, $includeCharts = false): string { // Create XML writer $objWriter = null; @@ -381,7 +381,7 @@ public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Wo * * @return string XML Output */ - public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet) + public function writeHeaderFooterDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php index e231972cf9..93c977798c 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsRibbon.php @@ -13,7 +13,7 @@ class RelsRibbon extends WriterPart * * @return string XML Output */ - public function writeRibbonRelationships(Spreadsheet $spreadsheet) + public function writeRibbonRelationships(Spreadsheet $spreadsheet): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php index d5b6060865..4ec0202588 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/RelsVBA.php @@ -12,7 +12,7 @@ class RelsVBA extends WriterPart * * @return string XML Output */ - public function writeVBARelationships() + public function writeVBARelationships(): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index 6d420b0acf..0200f0d9e8 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -68,7 +68,7 @@ public function createStringTable(ActualWorksheet $worksheet, $existingTable = n * * @return string XML Output */ - public function writeStringTable(array $stringTable) + public function writeStringTable(array $stringTable): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index c268f3d176..d254664fb2 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -22,7 +22,7 @@ class Style extends WriterPart * * @return string XML Output */ - public function writeStyles(Spreadsheet $spreadsheet) + public function writeStyles(Spreadsheet $spreadsheet): string { // Create XML writer $objWriter = null; @@ -608,7 +608,7 @@ private function writeNumFmt(XMLWriter $objWriter, ?NumberFormat $numberFormat, * * @return \PhpOffice\PhpSpreadsheet\Style\Style[] All styles in PhpSpreadsheet */ - public function allStyles(Spreadsheet $spreadsheet) + public function allStyles(Spreadsheet $spreadsheet): array { return $spreadsheet->getCellXfCollection(); } @@ -640,7 +640,7 @@ public function allConditionalStyles(Spreadsheet $spreadsheet): array * * @return Fill[] All fills in PhpSpreadsheet */ - public function allFills(Spreadsheet $spreadsheet) + public function allFills(Spreadsheet $spreadsheet): array { // Get an array of unique fills $aFills = []; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php index 1e8ef5b43a..abacd41106 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Theme.php @@ -14,7 +14,7 @@ class Theme extends WriterPart * * @return string XML Output */ - public function writeTheme(Spreadsheet $spreadsheet) + public function writeTheme(Spreadsheet $spreadsheet): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index 971771f6e1..7f46c4b026 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -18,7 +18,7 @@ class Workbook extends WriterPart * * @return string XML Output */ - public function writeWorkbook(Spreadsheet $spreadsheet, $recalcRequired = false) + public function writeWorkbook(Spreadsheet $spreadsheet, $recalcRequired = false): string { // Create XML writer if ($this->getParentWriter()->getUseDiskCaching()) { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 0c1561de98..08a8290032 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -36,7 +36,7 @@ class Worksheet extends WriterPart * * @return string XML Output */ - public function writeWorksheet(PhpspreadsheetWorksheet $worksheet, array $stringTable = [], $includeCharts = false) + public function writeWorksheet(PhpspreadsheetWorksheet $worksheet, array $stringTable = [], $includeCharts = false): string { $this->numberStoredAsText = ''; $this->formula = ''; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php index 9dbd904556..7715a299b1 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/WriterPart.php @@ -13,10 +13,8 @@ abstract class WriterPart /** * Get parent Xlsx object. - * - * @return Xlsx */ - public function getParentWriter() + public function getParentWriter(): Xlsx { return $this->parentWriter; } diff --git a/tests/PhpSpreadsheetTests/Cell/ValueBinderWithOverriddenDataTypeForValue.php b/tests/PhpSpreadsheetTests/Cell/ValueBinderWithOverriddenDataTypeForValue.php index 0a2ef249da..b3c6c9fd25 100644 --- a/tests/PhpSpreadsheetTests/Cell/ValueBinderWithOverriddenDataTypeForValue.php +++ b/tests/PhpSpreadsheetTests/Cell/ValueBinderWithOverriddenDataTypeForValue.php @@ -10,7 +10,7 @@ class ValueBinderWithOverriddenDataTypeForValue extends DefaultValueBinder { public static bool $called = false; - public static function dataTypeForValue(mixed $value) + public static function dataTypeForValue(mixed $value): string { self::$called = true; diff --git a/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php b/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php index 441e61e6d5..b81208bd6d 100644 --- a/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php +++ b/tests/PhpSpreadsheetTests/Functional/AbstractFunctional.php @@ -16,10 +16,8 @@ abstract class AbstractFunctional extends TestCase { /** * Write spreadsheet to disk, reload and return it. - * - * @return Spreadsheet */ - protected function writeAndReload(Spreadsheet $spreadsheet, string $format, ?callable $readerCustomizer = null, ?callable $writerCustomizer = null) + protected function writeAndReload(Spreadsheet $spreadsheet, string $format, ?callable $readerCustomizer = null, ?callable $writerCustomizer = null): Spreadsheet { $filename = File::temporaryFilename(); $writer = IOFactory::createWriter($spreadsheet, $format); From 959719a4d36fab5a056a3900ae65e70550e5b65c Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 10 Dec 2023 10:36:43 +0100 Subject: [PATCH 07/25] Apply PhpCsFixer `phpdoc_to_param_type` --- .../Calculation/BinaryComparison.php | 4 +- .../Calculation/Calculation.php | 56 ++++------- src/PhpSpreadsheet/Calculation/Database.php | 24 ++--- .../Calculation/Database/DAverage.php | 2 +- .../Calculation/Database/DCount.php | 2 +- .../Calculation/Database/DCountA.php | 2 +- .../Calculation/Database/DGet.php | 2 +- .../Calculation/Database/DMax.php | 2 +- .../Calculation/Database/DMin.php | 2 +- .../Calculation/Database/DProduct.php | 2 +- .../Calculation/Database/DStDev.php | 2 +- .../Calculation/Database/DStDevP.php | 2 +- .../Calculation/Database/DSum.php | 2 +- .../Calculation/Database/DVar.php | 2 +- .../Calculation/Database/DVarP.php | 2 +- .../Calculation/Database/DatabaseAbstract.php | 4 +- src/PhpSpreadsheet/Calculation/DateTime.php | 18 ++-- .../Calculation/DateTimeExcel/Helpers.php | 4 +- .../Calculation/Engine/Logger.php | 8 +- .../Calculation/Engineering.php | 77 ++++++--------- .../Calculation/Engineering/ConvertUOM.php | 4 +- src/PhpSpreadsheet/Calculation/Financial.php | 65 +++++++------ .../Calculation/Financial/CashFlow/Single.php | 10 +- .../CashFlow/Variable/NonPeriodic.php | 4 +- .../Calculation/FormulaParser.php | 2 +- .../Calculation/FormulaToken.php | 15 +-- src/PhpSpreadsheet/Calculation/Functions.php | 4 +- src/PhpSpreadsheet/Calculation/LookupRef.php | 6 +- .../Calculation/LookupRef/Offset.php | 2 +- .../Calculation/LookupRef/Sort.php | 5 +- src/PhpSpreadsheet/Calculation/MathTrig.php | 50 ++++------ .../Calculation/MathTrig/Arabic.php | 5 +- .../Calculation/MathTrig/Helpers.php | 2 +- .../Calculation/MathTrig/Random.php | 2 +- .../Calculation/MathTrig/SumSquares.php | 6 +- .../Calculation/Statistical.php | 91 ++++++------------ .../Calculation/Statistical/Conditional.php | 8 +- .../Calculation/Statistical/Trends.php | 8 +- src/PhpSpreadsheet/Calculation/TextData.php | 22 ++--- .../Calculation/TextData/Extract.php | 3 +- src/PhpSpreadsheet/Cell/Cell.php | 2 +- src/PhpSpreadsheet/Cell/Coordinate.php | 23 ++--- src/PhpSpreadsheet/Cell/DataValidation.php | 42 +++------ src/PhpSpreadsheet/Cell/Hyperlink.php | 10 +- src/PhpSpreadsheet/Chart/Axis.php | 14 +-- src/PhpSpreadsheet/Chart/Chart.php | 50 +++------- src/PhpSpreadsheet/Chart/ChartColor.php | 4 +- src/PhpSpreadsheet/Chart/DataSeries.php | 21 ++--- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 12 +-- src/PhpSpreadsheet/Chart/Layout.php | 4 +- src/PhpSpreadsheet/Chart/Legend.php | 13 +-- src/PhpSpreadsheet/Chart/Properties.php | 81 +++++----------- src/PhpSpreadsheet/Chart/Title.php | 7 +- src/PhpSpreadsheet/Collection/Cells.php | 8 +- .../Collection/Memory/SimpleCache1.php | 27 ++---- .../Collection/Memory/SimpleCache3.php | 27 ++---- src/PhpSpreadsheet/Document/Properties.php | 2 +- src/PhpSpreadsheet/HashTable.php | 2 +- src/PhpSpreadsheet/Helper/Sample.php | 18 +--- .../Reader/DefaultReadFilter.php | 2 +- src/PhpSpreadsheet/Reader/Gnumeric.php | 5 +- src/PhpSpreadsheet/Reader/Html.php | 16 +--- src/PhpSpreadsheet/Reader/Slk.php | 4 +- src/PhpSpreadsheet/Reader/Xls.php | 65 ++++--------- src/PhpSpreadsheet/Reader/Xls/Color.php | 3 +- src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php | 4 +- src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php | 4 +- .../Reader/Xls/Color/BuiltIn.php | 2 +- src/PhpSpreadsheet/Reader/Xls/ErrorCode.php | 4 +- src/PhpSpreadsheet/Reader/Xls/Escher.php | 4 +- src/PhpSpreadsheet/Reader/Xls/RC4.php | 4 +- .../Reader/Xls/Style/FillPattern.php | 4 +- src/PhpSpreadsheet/Reader/Xlsx.php | 5 +- src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 7 +- src/PhpSpreadsheet/Reader/Xlsx/Theme.php | 8 +- src/PhpSpreadsheet/ReferenceHelper.php | 14 +-- src/PhpSpreadsheet/RichText/RichText.php | 4 +- src/PhpSpreadsheet/RichText/Run.php | 2 +- src/PhpSpreadsheet/RichText/TextElement.php | 2 +- src/PhpSpreadsheet/Settings.php | 6 +- src/PhpSpreadsheet/Shared/Date.php | 19 ++-- src/PhpSpreadsheet/Shared/Drawing.php | 12 +-- src/PhpSpreadsheet/Shared/Escher.php | 8 +- .../Shared/Escher/DgContainer.php | 3 +- .../DgContainer/SpgrContainer/SpContainer.php | 28 ++---- .../Shared/Escher/DggContainer.php | 24 ++--- .../DggContainer/BstoreContainer/BSE.php | 4 +- .../DggContainer/BstoreContainer/BSE/Blip.php | 4 +- src/PhpSpreadsheet/Shared/Font.php | 26 +++-- src/PhpSpreadsheet/Shared/OLE.php | 20 ++-- .../Shared/OLE/ChainedBlockStream.php | 8 +- src/PhpSpreadsheet/Shared/OLE/PPS.php | 2 +- src/PhpSpreadsheet/Shared/OLE/PPS/File.php | 2 +- src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 4 +- src/PhpSpreadsheet/Shared/OLERead.php | 8 +- src/PhpSpreadsheet/Shared/StringHelper.php | 8 +- src/PhpSpreadsheet/Shared/Trend/BestFit.php | 43 ++++----- .../Shared/Trend/ExponentialBestFit.php | 13 ++- .../Shared/Trend/LinearBestFit.php | 9 +- .../Shared/Trend/LogarithmicBestFit.php | 9 +- .../Shared/Trend/PolynomialBestFit.php | 17 ++-- .../Shared/Trend/PowerBestFit.php | 11 +-- src/PhpSpreadsheet/Shared/Trend/Trend.php | 7 +- src/PhpSpreadsheet/Shared/XMLWriter.php | 2 +- src/PhpSpreadsheet/Shared/Xls.php | 12 +-- src/PhpSpreadsheet/Spreadsheet.php | 72 ++++++-------- src/PhpSpreadsheet/Style/Alignment.php | 28 ++---- src/PhpSpreadsheet/Style/Border.php | 6 +- src/PhpSpreadsheet/Style/Borders.php | 8 +- src/PhpSpreadsheet/Style/Color.php | 18 ++-- src/PhpSpreadsheet/Style/Conditional.php | 12 +-- .../ConditionalFormatting/Wizard/Blanks.php | 3 +- .../Wizard/CellValue.php | 3 +- .../Wizard/DateValue.php | 3 +- .../Wizard/Duplicates.php | 3 +- .../ConditionalFormatting/Wizard/Errors.php | 3 +- .../Wizard/Expression.php | 3 +- .../Wizard/TextValue.php | 3 +- src/PhpSpreadsheet/Style/Fill.php | 12 +-- src/PhpSpreadsheet/Style/Font.php | 22 ++--- src/PhpSpreadsheet/Style/NumberFormat.php | 16 +--- .../Style/NumberFormat/Formatter.php | 2 +- src/PhpSpreadsheet/Style/Protection.php | 10 +- src/PhpSpreadsheet/Style/RgbTint.php | 2 +- src/PhpSpreadsheet/Style/Style.php | 16 +--- src/PhpSpreadsheet/Style/Supervisor.php | 9 +- src/PhpSpreadsheet/Theme.php | 6 +- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 22 ++--- .../Worksheet/AutoFilter/Column.php | 20 ++-- .../Worksheet/AutoFilter/Column/Rule.php | 11 +-- src/PhpSpreadsheet/Worksheet/Column.php | 10 +- .../Worksheet/ColumnCellIterator.php | 4 +- .../Worksheet/ColumnDimension.php | 2 +- .../Worksheet/ColumnIterator.php | 4 +- src/PhpSpreadsheet/Worksheet/Dimension.php | 2 +- src/PhpSpreadsheet/Worksheet/Drawing.php | 2 +- .../Worksheet/Drawing/Shadow.php | 24 ++--- src/PhpSpreadsheet/Worksheet/HeaderFooter.php | 48 +++------- .../Worksheet/MemoryDrawing.php | 4 +- src/PhpSpreadsheet/Worksheet/PageMargins.php | 24 ++--- src/PhpSpreadsheet/Worksheet/PageSetup.php | 47 ++++------ src/PhpSpreadsheet/Worksheet/Protection.php | 3 +- src/PhpSpreadsheet/Worksheet/Row.php | 10 +- .../Worksheet/RowCellIterator.php | 4 +- src/PhpSpreadsheet/Worksheet/RowDimension.php | 4 +- src/PhpSpreadsheet/Worksheet/RowIterator.php | 4 +- src/PhpSpreadsheet/Worksheet/SheetView.php | 10 +- src/PhpSpreadsheet/Worksheet/Table.php | 8 +- src/PhpSpreadsheet/Worksheet/Table/Column.php | 4 +- src/PhpSpreadsheet/Worksheet/Worksheet.php | 94 +++++++++---------- src/PhpSpreadsheet/Writer/Html.php | 36 +++---- src/PhpSpreadsheet/Writer/Pdf.php | 12 +-- src/PhpSpreadsheet/Writer/Pdf/Mpdf.php | 6 +- src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php | 2 +- src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php | 8 +- src/PhpSpreadsheet/Writer/Xls/Font.php | 8 +- src/PhpSpreadsheet/Writer/Xls/Parser.php | 25 +++-- src/PhpSpreadsheet/Writer/Xls/Workbook.php | 12 +-- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 44 ++++----- src/PhpSpreadsheet/Writer/Xls/Xf.php | 30 +++--- src/PhpSpreadsheet/Writer/Xlsx.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 9 +- src/PhpSpreadsheet/Writer/Xlsx/Comments.php | 2 +- .../Writer/Xlsx/ContentTypes.php | 8 +- src/PhpSpreadsheet/Writer/Xlsx/Drawing.php | 16 +--- src/PhpSpreadsheet/Writer/Xlsx/Rels.php | 7 +- .../Writer/Xlsx/StringTable.php | 4 +- src/PhpSpreadsheet/Writer/Xlsx/Table.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Workbook.php | 6 +- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 4 +- .../Functions/Statistical/RankTest.php | 2 +- .../Functional/ReadFilterFilter.php | 2 +- 172 files changed, 838 insertions(+), 1406 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/BinaryComparison.php b/src/PhpSpreadsheet/Calculation/BinaryComparison.php index 6b6dd97e32..e4bc156af0 100644 --- a/src/PhpSpreadsheet/Calculation/BinaryComparison.php +++ b/src/PhpSpreadsheet/Calculation/BinaryComparison.php @@ -17,7 +17,7 @@ class BinaryComparison * @param null|string $str1 First string value for the comparison * @param null|string $str2 Second string value for the comparison */ - private static function strcmpLowercaseFirst($str1, $str2): int + private static function strcmpLowercaseFirst(?string $str1, ?string $str2): int { $inversedStr1 = StringHelper::strCaseReverse($str1 ?? ''); $inversedStr2 = StringHelper::strCaseReverse($str2 ?? ''); @@ -31,7 +31,7 @@ private static function strcmpLowercaseFirst($str1, $str2): int * @param null|string $str1 First string value for the comparison * @param null|string $str2 Second string value for the comparison */ - private static function strcmpAllowNull($str1, $str2): int + private static function strcmpAllowNull(?string $str1, ?string $str2): int { return strcmp($str1 ?? '', $str2 ?? ''); } diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index d7b1a56afd..8d2e2e290e 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -2978,7 +2978,7 @@ public static function getFALSE(): string * * @return bool Success or failure */ - public static function setArrayReturnType($returnType): bool + public static function setArrayReturnType(string $returnType): bool { if ( ($returnType == self::RETURN_ARRAY_AS_VALUE) @@ -3013,10 +3013,8 @@ public function getCalculationCacheEnabled(): bool /** * Enable/disable calculation cache. - * - * @param bool $calculationCacheEnabled */ - public function setCalculationCacheEnabled($calculationCacheEnabled): void + public function setCalculationCacheEnabled(bool $calculationCacheEnabled): void { $this->calculationCacheEnabled = $calculationCacheEnabled; $this->clearCalculationCache(); @@ -3048,10 +3046,8 @@ public function clearCalculationCache(): void /** * Clear calculation cache for a specified worksheet. - * - * @param string $worksheetName */ - public function clearCalculationCacheForWorksheet($worksheetName): void + public function clearCalculationCacheForWorksheet(string $worksheetName): void { if (isset($this->calculationCache[$worksheetName])) { unset($this->calculationCache[$worksheetName]); @@ -3060,11 +3056,8 @@ public function clearCalculationCacheForWorksheet($worksheetName): void /** * Rename calculation cache for a specified worksheet. - * - * @param string $fromWorksheetName - * @param string $toWorksheetName */ - public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName): void + public function renameCalculationCacheForWorksheet(string $fromWorksheetName, string $toWorksheetName): void { if (isset($this->calculationCache[$fromWorksheetName])) { $this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName]; @@ -3356,10 +3349,7 @@ public function _translateFormulaToEnglish(string $formula): string return self::translateFormula(self::$functionReplaceFromLocale, self::$functionReplaceToExcel, $formula, self::$localeArgumentSeparator, ','); } - /** - * @param string $function - */ - public static function localeFunc($function): string + public static function localeFunc(string $function): string { if (self::$localeLanguage !== 'en_us') { $functionName = trim($function, '('); @@ -3435,7 +3425,7 @@ public function calculate(?Cell $cell = null): mixed * @param Cell $cell Cell to calculate * @param bool $resetLog Flag indicating whether the debug log should be reset or not */ - public function calculateCellValue(?Cell $cell = null, $resetLog = true): mixed + public function calculateCellValue(?Cell $cell = null, bool $resetLog = true): mixed { if ($cell === null) { return null; @@ -3532,7 +3522,7 @@ public function calculateCellValue(?Cell $cell = null, $resetLog = true): mixed * * @return array|bool */ - public function parseFormula($formula) + public function parseFormula(string $formula) { // Basic validation that this is indeed a formula // We return an empty array if not @@ -3556,7 +3546,7 @@ public function parseFormula($formula) * @param string $cellID Address of the cell to calculate * @param Cell $cell Cell to calculate */ - public function calculateFormula($formula, $cellID = null, ?Cell $cell = null): mixed + public function calculateFormula(string $formula, ?string $cellID = null, ?Cell $cell = null): mixed { // Initialise the logging settings $this->formulaError = null; @@ -3605,10 +3595,7 @@ public function getValueFromCache(string $cellReference, mixed &$cellValue): boo return false; } - /** - * @param string $cellReference - */ - public function saveValueToCache($cellReference, mixed $cellValue): void + public function saveValueToCache(string $cellReference, mixed $cellValue): void { if ($this->calculationCacheEnabled) { $this->calculationCache[$cellReference] = $cellValue; @@ -3623,7 +3610,7 @@ public function saveValueToCache($cellReference, mixed $cellValue): void * @param Cell $cell Cell to calculate * @param bool $ignoreQuotePrefix If set to true, evaluate the formyla even if the referenced cell is quote prefixed */ - public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false): mixed + public function _calculateFormulaValue(string $formula, ?string $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false): mixed { $cellValue = null; @@ -3704,7 +3691,7 @@ public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = n * 1 = shrink to fit * 2 = extend to fit */ - private static function checkMatrixOperands(mixed &$operand1, mixed &$operand2, $resize = 1): array + private static function checkMatrixOperands(mixed &$operand1, mixed &$operand2, int $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 @@ -3770,7 +3757,7 @@ public static function getMatrixDimensions(array &$matrix): array * @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand */ - private static function resizeMatricesShrink(array &$matrix1, array &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void + private static function resizeMatricesShrink(array &$matrix1, array &$matrix2, int $matrix1Rows, int $matrix1Columns, int $matrix2Rows, int $matrix2Columns): void { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Rows < $matrix1Rows) { @@ -3813,7 +3800,7 @@ private static function resizeMatricesShrink(array &$matrix1, array &$matrix2, $ * @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand */ - private static function resizeMatricesExtend(array &$matrix1, array &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void + private static function resizeMatricesExtend(array &$matrix1, array &$matrix2, int $matrix1Rows, int $matrix1Columns, int $matrix2Rows, int $matrix2Columns): void { if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Columns < $matrix1Columns) { @@ -4022,11 +4009,9 @@ private function convertMatrixReferences(string $formula): false|string // Convert infix to postfix notation /** - * @param string $formula - * * @return array|false */ - private function internalParseFormula($formula, ?Cell $cell = null): bool|array + private function internalParseFormula(string $formula, ?Cell $cell = null): bool|array { if (($formula = $this->convertMatrixReferences(trim($formula))) === false) { return false; @@ -4536,11 +4521,9 @@ private static function dataTestReference(array &$operandData): mixed } /** - * @param null|string $cellID - * * @return array|false */ - private function processTokenStack(mixed $tokens, $cellID = null, ?Cell $cell = null) + private function processTokenStack(mixed $tokens, ?string $cellID = null, ?Cell $cell = null) { if ($tokens === false) { return false; @@ -5211,12 +5194,9 @@ private function executeBinaryComparisonOperation(mixed $operand1, mixed $operan } /** - * @param string $operation - * @param Stack $stack - * * @return bool|mixed */ - private function executeNumericBinaryOperation(mixed $operand1, mixed $operand2, $operation, &$stack) + private function executeNumericBinaryOperation(mixed $operand1, mixed $operand2, string $operation, Stack &$stack) { // Validate the two operands if ( @@ -5369,7 +5349,7 @@ protected function raiseFormulaError(string $errorMessage, int $code = 0, ?Throw * * @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, bool $resetLog = true): array + public function extractCellRange(string &$range = 'A1', ?Worksheet $worksheet = null, bool $resetLog = true): array { // Return value $returnValue = []; @@ -5480,7 +5460,7 @@ public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet = * * @param string $function Function Name */ - public function isImplemented($function): bool + public function isImplemented(string $function): bool { $function = strtoupper($function); $notImplemented = !isset(self::$phpSpreadsheetFunctions[$function]) || (is_array(self::$phpSpreadsheetFunctions[$function]['functionCall']) && self::$phpSpreadsheetFunctions[$function]['functionCall'][1] === 'DUMMY'); diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php index 40a2926f07..90dabcd824 100644 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ b/src/PhpSpreadsheet/Calculation/Database.php @@ -38,7 +38,7 @@ class Database * * @return float|string */ - public static function DAVERAGE($database, $field, $criteria) + public static function DAVERAGE(array $database, $field, array $criteria) { return Database\DAverage::evaluate($database, $field, $criteria); } @@ -74,7 +74,7 @@ public static function DAVERAGE($database, $field, $criteria) * @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): string|int + public static function DCOUNT(array $database, $field, array $criteria): string|int { return Database\DCount::evaluate($database, $field, $criteria); } @@ -106,7 +106,7 @@ public static function DCOUNT($database, $field, $criteria): string|int * the column label in which you specify a condition for the * column. */ - public static function DCOUNTA($database, $field, $criteria): string|int + public static function DCOUNTA(array $database, $field, array $criteria): string|int { return Database\DCountA::evaluate($database, $field, $criteria); } @@ -139,7 +139,7 @@ public static function DCOUNTA($database, $field, $criteria): string|int * the column label in which you specify a condition for the * column. */ - public static function DGET($database, $field, $criteria): mixed + public static function DGET(array $database, $field, array $criteria): mixed { return Database\DGet::evaluate($database, $field, $criteria); } @@ -174,7 +174,7 @@ public static function DGET($database, $field, $criteria): mixed * * @return null|float|string */ - public static function DMAX($database, $field, $criteria) + public static function DMAX(array $database, $field, array $criteria) { return Database\DMax::evaluate($database, $field, $criteria); } @@ -209,7 +209,7 @@ public static function DMAX($database, $field, $criteria) * * @return null|float|string */ - public static function DMIN($database, $field, $criteria) + public static function DMIN(array $database, $field, array $criteria) { return Database\DMin::evaluate($database, $field, $criteria); } @@ -243,7 +243,7 @@ public static function DMIN($database, $field, $criteria) * * @return float|string */ - public static function DPRODUCT($database, $field, $criteria) + public static function DPRODUCT(array $database, $field, array $criteria) { return Database\DProduct::evaluate($database, $field, $criteria); } @@ -278,7 +278,7 @@ public static function DPRODUCT($database, $field, $criteria) * * @return float|string */ - public static function DSTDEV($database, $field, $criteria) + public static function DSTDEV(array $database, $field, array $criteria) { return Database\DStDev::evaluate($database, $field, $criteria); } @@ -313,7 +313,7 @@ public static function DSTDEV($database, $field, $criteria) * * @return float|string */ - public static function DSTDEVP($database, $field, $criteria) + public static function DSTDEVP(array $database, $field, array $criteria) { return Database\DStDevP::evaluate($database, $field, $criteria); } @@ -347,7 +347,7 @@ public static function DSTDEVP($database, $field, $criteria) * * @return null|float|string */ - public static function DSUM($database, $field, $criteria) + public static function DSUM(array $database, $field, array $criteria) { return Database\DSum::evaluate($database, $field, $criteria); } @@ -382,7 +382,7 @@ public static function DSUM($database, $field, $criteria) * * @return float|string (string if result is an error) */ - public static function DVAR($database, $field, $criteria) + public static function DVAR(array $database, $field, array $criteria) { return Database\DVar::evaluate($database, $field, $criteria); } @@ -417,7 +417,7 @@ public static function DVAR($database, $field, $criteria) * * @return float|string (string if result is an error) */ - public static function DVARP($database, $field, $criteria) + public static function DVARP(array $database, $field, array $criteria) { return Database\DVarP::evaluate($database, $field, $criteria); } diff --git a/src/PhpSpreadsheet/Calculation/Database/DAverage.php b/src/PhpSpreadsheet/Calculation/Database/DAverage.php index 20a1eef27a..1f09eb1f3f 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DAverage.php +++ b/src/PhpSpreadsheet/Calculation/Database/DAverage.php @@ -30,7 +30,7 @@ class DAverage extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria): string|int|float + public static function evaluate(array $database, $field, array $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 82795d84b7..27cf02ea67 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DCount.php +++ b/src/PhpSpreadsheet/Calculation/Database/DCount.php @@ -31,7 +31,7 @@ class DCount extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria, bool $returnError = true): string|int + public static function evaluate(array $database, $field, array $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 fee8e5a547..5350c6583c 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DCountA.php +++ b/src/PhpSpreadsheet/Calculation/Database/DCountA.php @@ -30,7 +30,7 @@ class DCountA extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria): string|int + public static function evaluate(array $database, $field, array $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 188f5e6787..e79ee8de19 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DGet.php +++ b/src/PhpSpreadsheet/Calculation/Database/DGet.php @@ -30,7 +30,7 @@ class DGet extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria): null|float|int|string + public static function evaluate(array $database, $field, array $criteria): null|float|int|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DMax.php b/src/PhpSpreadsheet/Calculation/Database/DMax.php index 14153a95b9..c111600c96 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DMax.php +++ b/src/PhpSpreadsheet/Calculation/Database/DMax.php @@ -31,7 +31,7 @@ class DMax extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria, bool $returnError = true): null|float|string + public static function evaluate(array $database, $field, array $criteria, bool $returnError = true): null|float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DMin.php b/src/PhpSpreadsheet/Calculation/Database/DMin.php index 586dcd6230..a901601156 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DMin.php +++ b/src/PhpSpreadsheet/Calculation/Database/DMin.php @@ -31,7 +31,7 @@ class DMin extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria, bool $returnError = true): float|string|null + public static function evaluate(array $database, $field, array $criteria, bool $returnError = true): float|string|null { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DProduct.php b/src/PhpSpreadsheet/Calculation/Database/DProduct.php index c420ab6b55..67090aa05a 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DProduct.php +++ b/src/PhpSpreadsheet/Calculation/Database/DProduct.php @@ -30,7 +30,7 @@ class DProduct extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria): string|float + public static function evaluate(array $database, $field, array $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 403e672dc2..93e9c0e052 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DStDev.php +++ b/src/PhpSpreadsheet/Calculation/Database/DStDev.php @@ -31,7 +31,7 @@ class DStDev extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria): float|string + public static function evaluate(array $database, $field, array $criteria): float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DStDevP.php b/src/PhpSpreadsheet/Calculation/Database/DStDevP.php index 31534797e2..13b80014e4 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DStDevP.php +++ b/src/PhpSpreadsheet/Calculation/Database/DStDevP.php @@ -31,7 +31,7 @@ class DStDevP extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria): float|string + public static function evaluate(array $database, $field, array $criteria): float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DSum.php b/src/PhpSpreadsheet/Calculation/Database/DSum.php index 2c17d531a3..625599fce8 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DSum.php +++ b/src/PhpSpreadsheet/Calculation/Database/DSum.php @@ -30,7 +30,7 @@ class DSum extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate($database, $field, $criteria, bool $returnNull = false): null|float|string + public static function evaluate(array $database, $field, array $criteria, bool $returnNull = false): null|float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DVar.php b/src/PhpSpreadsheet/Calculation/Database/DVar.php index d579ce357a..8dd4d38867 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DVar.php +++ b/src/PhpSpreadsheet/Calculation/Database/DVar.php @@ -33,7 +33,7 @@ class DVar extends DatabaseAbstract * * @return float|string (string if result is an error) */ - public static function evaluate($database, $field, $criteria): string|float + public static function evaluate(array $database, $field, array $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 8a990d77c8..93b3eda146 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DVarP.php +++ b/src/PhpSpreadsheet/Calculation/Database/DVarP.php @@ -33,7 +33,7 @@ class DVarP extends DatabaseAbstract * * @return float|string (string if result is an error) */ - public static function evaluate($database, $field, $criteria): string|float + public static function evaluate(array $database, $field, array $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 ea74a759d3..a1542b7195 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php +++ b/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php @@ -9,11 +9,9 @@ abstract class DatabaseAbstract { /** - * @param array $database * @param null|int|string $field - * @param array $criteria */ - abstract public static function evaluate($database, $field, $criteria): null|float|int|string; + abstract public static function evaluate(array $database, $field, array $criteria): null|float|int|string; /** * fieldExtract. diff --git a/src/PhpSpreadsheet/Calculation/DateTime.php b/src/PhpSpreadsheet/Calculation/DateTime.php index 589f75d9a8..949b549976 100644 --- a/src/PhpSpreadsheet/Calculation/DateTime.php +++ b/src/PhpSpreadsheet/Calculation/DateTime.php @@ -149,7 +149,7 @@ public static function DATENOW(): mixed * @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 */ - public static function DATE($year = 0, $month = 1, $day = 1): mixed + public static function DATE(int $year = 0, int $month = 1, int $day = 1): mixed { return DateTimeExcel\Date::fromYMD($year, $month, $day); } @@ -184,7 +184,7 @@ public static function DATE($year = 0, $month = 1, $day = 1): mixed * @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): string|float|int|\DateTime|array + public static function TIME(int $hour = 0, int $minute = 0, int $second = 0): string|float|int|\DateTime|array { return DateTimeExcel\Time::fromHMS($hour, $minute, $second); } @@ -218,7 +218,7 @@ public static function TIME($hour = 0, $minute = 0, $second = 0): string|float|i * @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 */ - public static function DATEVALUE($dateValue): mixed + public static function DATEVALUE(string $dateValue): mixed { return DateTimeExcel\DateValue::fromString($dateValue); } @@ -248,7 +248,7 @@ public static function DATEVALUE($dateValue): mixed * @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): string|\Datetime|int|float|array + public static function TIMEVALUE(string $timeValue): string|\Datetime|int|float|array { return DateTimeExcel\TimeValue::fromString($timeValue); } @@ -424,7 +424,7 @@ public static function NETWORKDAYS(mixed $startDate, mixed $endDate, mixed ...$d * @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 */ - public static function WORKDAY(mixed $startDate, $endDays, mixed ...$dateArgs): mixed + public static function WORKDAY(mixed $startDate, int $endDays, mixed ...$dateArgs): mixed { return DateTimeExcel\WorkDay::date($startDate, $endDays, ...$dateArgs); } @@ -474,7 +474,7 @@ public static function DAYOFMONTH(mixed $dateValue = 1): int|string|array * * @return array|int|string Day of the week value */ - public static function WEEKDAY($dateValue = 1, $style = 1): string|int|array + public static function WEEKDAY($dateValue = 1, int $style = 1): string|int|array { return DateTimeExcel\Week::day($dateValue, $style); } @@ -685,7 +685,7 @@ public static function WEEKDAY($dateValue = 1, $style = 1): string|int|array * * @return array|int|string Week Number */ - public static function WEEKNUM(mixed $dateValue = 1, $method = self::STARTWEEK_SUNDAY): int|string|array + public static function WEEKNUM(mixed $dateValue = 1, int $method = self::STARTWEEK_SUNDAY): int|string|array { return DateTimeExcel\Week::number($dateValue, $method); } @@ -851,7 +851,7 @@ public static function SECOND(mixed $timeValue = 0): string|int|array * @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 */ - public static function EDATE(mixed $dateValue = 1, $adjustmentMonths = 0): mixed + public static function EDATE(mixed $dateValue = 1, int $adjustmentMonths = 0): mixed { return DateTimeExcel\Month::adjust($dateValue, $adjustmentMonths); } @@ -879,7 +879,7 @@ public static function EDATE(mixed $dateValue = 1, $adjustmentMonths = 0): mixed * @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 */ - public static function EOMONTH(mixed $dateValue = 1, $adjustmentMonths = 0): mixed + public static function EOMONTH(mixed $dateValue = 1, int $adjustmentMonths = 0): mixed { return DateTimeExcel\Month::lastDay($dateValue, $adjustmentMonths); } diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index 58dc9fd030..5f355d47f7 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -58,11 +58,9 @@ public static function getDateValue(mixed $dateValue, bool $allowBool = true): f /** * getTimeValue. * - * @param string $timeValue - * * @return mixed Excel date/time serial value, or string if error */ - public static function getTimeValue($timeValue): mixed + public static function getTimeValue(string $timeValue): mixed { $saveReturnDateType = Functions::getReturnDateType(); Functions::setReturnDateType(Functions::RETURNDATE_EXCEL); diff --git a/src/PhpSpreadsheet/Calculation/Engine/Logger.php b/src/PhpSpreadsheet/Calculation/Engine/Logger.php index 35242aaf90..9adcd55957 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/Logger.php +++ b/src/PhpSpreadsheet/Calculation/Engine/Logger.php @@ -41,10 +41,8 @@ public function __construct(CyclicReferenceStack $stack) /** * Enable/Disable Calculation engine logging. - * - * @param bool $writeDebugLog */ - public function setWriteDebugLog($writeDebugLog): void + public function setWriteDebugLog(bool $writeDebugLog): void { $this->writeDebugLog = $writeDebugLog; } @@ -59,10 +57,8 @@ public function getWriteDebugLog(): bool /** * Enable/Disable echoing of debug log information. - * - * @param bool $echoDebugLog */ - public function setEchoDebugLog($echoDebugLog): void + public function setEchoDebugLog(bool $echoDebugLog): void { $this->echoDebugLog = $echoDebugLog; } diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php index 0725512ba7..81cc891ef1 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ b/src/PhpSpreadsheet/Calculation/Engineering.php @@ -41,7 +41,7 @@ class Engineering * * @return array|float|string Result, or a string containing an error */ - public static function BESSELI($x, $ord) + public static function BESSELI(float $x, int $ord) { return Engineering\BesselI::BESSELI($x, $ord); } @@ -66,7 +66,7 @@ public static function BESSELI($x, $ord) * * @return array|float|string Result, or a string containing an error */ - public static function BESSELJ($x, $ord) + public static function BESSELJ(float $x, int $ord) { return Engineering\BesselJ::BESSELJ($x, $ord); } @@ -92,7 +92,7 @@ public static function BESSELJ($x, $ord) * * @return array|float|string Result, or a string containing an error */ - public static function BESSELK($x, $ord) + public static function BESSELK(float $x, int $ord) { return Engineering\BesselK::BESSELK($x, $ord); } @@ -117,7 +117,7 @@ public static function BESSELK($x, $ord) * * @return array|float|string Result, or a string containing an error */ - public static function BESSELY($x, $ord) + public static function BESSELY(float $x, int $ord) { return Engineering\BesselY::BESSELY($x, $ord); } @@ -560,7 +560,7 @@ 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 */ - public static function IMAGINARY($complexNumber): string|float|array + public static function IMAGINARY(string $complexNumber): string|float|array { return Engineering\Complex::IMAGINARY($complexNumber); } @@ -579,7 +579,7 @@ public static function IMAGINARY($complexNumber): string|float|array * * @param string $complexNumber the complex number for which you want the real coefficient */ - public static function IMREAL($complexNumber): string|float|array + public static function IMREAL(string $complexNumber): string|float|array { return Engineering\Complex::IMREAL($complexNumber); } @@ -600,7 +600,7 @@ public static function IMREAL($complexNumber): string|float|array * * @return array|float|string */ - public static function IMABS($complexNumber) + public static function IMABS(string $complexNumber) { return ComplexFunctions::IMABS($complexNumber); } @@ -769,7 +769,7 @@ public static function IMCSCH($complexNumber) * * @return array|float|string */ - public static function IMSIN($complexNumber) + public static function IMSIN(string $complexNumber) { return ComplexFunctions::IMSIN($complexNumber); } @@ -790,7 +790,7 @@ public static function IMSIN($complexNumber) * * @return array|float|string */ - public static function IMSINH($complexNumber) + public static function IMSINH(string $complexNumber) { return ComplexFunctions::IMSINH($complexNumber); } @@ -811,7 +811,7 @@ public static function IMSINH($complexNumber) * * @return array|float|string */ - public static function IMSEC($complexNumber) + public static function IMSEC(string $complexNumber) { return ComplexFunctions::IMSEC($complexNumber); } @@ -832,7 +832,7 @@ public static function IMSEC($complexNumber) * * @return array|float|string */ - public static function IMSECH($complexNumber) + public static function IMSECH(string $complexNumber) { return ComplexFunctions::IMSECH($complexNumber); } @@ -853,7 +853,7 @@ public static function IMSECH($complexNumber) * * @return array|float|string */ - public static function IMTAN($complexNumber) + public static function IMTAN(string $complexNumber) { return ComplexFunctions::IMTAN($complexNumber); } @@ -874,7 +874,7 @@ public static function IMTAN($complexNumber) * * @return array|string */ - public static function IMSQRT($complexNumber) + public static function IMSQRT(string $complexNumber) { return ComplexFunctions::IMSQRT($complexNumber); } @@ -895,7 +895,7 @@ public static function IMSQRT($complexNumber) * * @return array|string */ - public static function IMLN($complexNumber) + public static function IMLN(string $complexNumber) { return ComplexFunctions::IMLN($complexNumber); } @@ -916,7 +916,7 @@ public static function IMLN($complexNumber) * * @return array|string */ - public static function IMLOG10($complexNumber) + public static function IMLOG10(string $complexNumber) { return ComplexFunctions::IMLOG10($complexNumber); } @@ -937,7 +937,7 @@ public static function IMLOG10($complexNumber) * * @return array|string */ - public static function IMLOG2($complexNumber) + public static function IMLOG2(string $complexNumber) { return ComplexFunctions::IMLOG2($complexNumber); } @@ -958,7 +958,7 @@ public static function IMLOG2($complexNumber) * * @return array|string */ - public static function IMEXP($complexNumber) + public static function IMEXP(string $complexNumber) { return ComplexFunctions::IMEXP($complexNumber); } @@ -980,7 +980,7 @@ public static function IMEXP($complexNumber) * * @return array|string */ - public static function IMPOWER($complexNumber, $realNumber) + public static function IMPOWER(string $complexNumber, float $realNumber) { return ComplexFunctions::IMPOWER($complexNumber, $realNumber); } @@ -1002,7 +1002,7 @@ public static function IMPOWER($complexNumber, $realNumber) * * @return array|string */ - public static function IMDIV($complexDividend, $complexDivisor) + public static function IMDIV(string $complexDividend, string $complexDivisor) { return ComplexOperations::IMDIV($complexDividend, $complexDivisor); } @@ -1024,7 +1024,7 @@ public static function IMDIV($complexDividend, $complexDivisor) * * @return array|string */ - public static function IMSUB($complexNumber1, $complexNumber2) + public static function IMSUB(string $complexNumber1, string $complexNumber2) { return ComplexOperations::IMSUB($complexNumber1, $complexNumber2); } @@ -1087,7 +1087,7 @@ public static function IMPRODUCT(...$complexNumbers): string * * @return array|int|string (string in the event of an error) */ - public static function DELTA($a, $b = 0) + public static function DELTA(float $a, float $b = 0) { return Engineering\Compare::DELTA($a, $b); } @@ -1111,7 +1111,7 @@ public static function DELTA($a, $b = 0) * * @return array|int|string (string in the event of an error) */ - public static function GESTEP($number, $step = 0) + public static function GESTEP(float $number, float $step = 0) { return Engineering\Compare::GESTEP($number, $step); } @@ -1128,12 +1128,9 @@ public static function GESTEP($number, $step = 0) * Use the BITAND() method in the Engineering\BitWise class instead * @see Engineering\BitWise::BITAND() * - * @param int $number1 - * @param int $number2 - * * @return array|int|string */ - public static function BITAND($number1, $number2) + public static function BITAND(int $number1, int $number2) { return Engineering\BitWise::BITAND($number1, $number2); } @@ -1150,12 +1147,9 @@ public static function BITAND($number1, $number2) * Use the BITOR() method in the Engineering\BitWise class instead * @see Engineering\BitWise::BITOR() * - * @param int $number1 - * @param int $number2 - * * @return array|int|string */ - public static function BITOR($number1, $number2) + public static function BITOR(int $number1, int $number2) { return Engineering\BitWise::BITOR($number1, $number2); } @@ -1172,12 +1166,9 @@ public static function BITOR($number1, $number2) * Use the BITXOR() method in the Engineering\BitWise class instead * @see Engineering\BitWise::BITXOR() * - * @param int $number1 - * @param int $number2 - * * @return array|int|string */ - public static function BITXOR($number1, $number2) + public static function BITXOR(int $number1, int $number2) { return Engineering\BitWise::BITXOR($number1, $number2); } @@ -1194,12 +1185,9 @@ public static function BITXOR($number1, $number2) * Use the BITLSHIFT() method in the Engineering\BitWise class instead * @see Engineering\BitWise::BITLSHIFT() * - * @param int $number - * @param int $shiftAmount - * * @return array|float|int|string */ - public static function BITLSHIFT($number, $shiftAmount) + public static function BITLSHIFT(int $number, int $shiftAmount) { return Engineering\BitWise::BITLSHIFT($number, $shiftAmount); } @@ -1216,12 +1204,9 @@ public static function BITLSHIFT($number, $shiftAmount) * Use the BITRSHIFT() method in the Engineering\BitWise class instead * @see Engineering\BitWise::BITRSHIFT() * - * @param int $number - * @param int $shiftAmount - * * @return array|float|int|string */ - public static function BITRSHIFT($number, $shiftAmount) + public static function BITRSHIFT(int $number, int $shiftAmount) { return Engineering\BitWise::BITRSHIFT($number, $shiftAmount); } @@ -1247,7 +1232,7 @@ public static function BITRSHIFT($number, $shiftAmount) * @param float $upper upper bound for integrating ERF. * If omitted, ERF integrates between zero and lower_limit */ - public static function ERF($lower, $upper = null): float|string|array + public static function ERF(float $lower, ?float $upper = null): float|string|array { return Engineering\Erf::ERF($lower, $upper); } @@ -1268,7 +1253,7 @@ public static function ERF($lower, $upper = null): float|string|array * * @return array|float|string */ - public static function ERFPRECISE($limit) + public static function ERFPRECISE(float $limit) { return Engineering\Erf::ERFPRECISE($limit); } @@ -1294,7 +1279,7 @@ public static function ERFPRECISE($limit) * * @return array|float|string */ - public static function ERFC($x) + public static function ERFC(float $x) { return Engineering\ErfC::ERFC($x); } @@ -1393,7 +1378,7 @@ public static function getBinaryConversionMultipliers(): array * * @return array|float|string */ - public static function CONVERTUOM($value, $fromUOM, $toUOM) + public static function CONVERTUOM($value, string $fromUOM, string $toUOM) { return Engineering\ConvertUOM::CONVERT($value, $fromUOM, $toUOM); } diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php index ada0aaa804..9be40289c7 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php @@ -452,7 +452,7 @@ public static function getConversionCategories(): array * * @param string $category The group whose units of measure you want to retrieve */ - public static function getConversionCategoryUnits($category = null): array + public static function getConversionCategoryUnits(?string $category = null): array { $conversionGroups = []; foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) { @@ -469,7 +469,7 @@ public static function getConversionCategoryUnits($category = null): array * * @param string $category The group whose units of measure you want to retrieve */ - public static function getConversionCategoryUnitDetails($category = null): array + public static function getConversionCategoryUnitDetails(?string $category = null): array { $conversionGroups = []; foreach (self::$conversionUnits as $conversionUnit => $conversionGroup) { diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php index 9e299a57d2..0d1b911e9c 100644 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ b/src/PhpSpreadsheet/Calculation/Financial.php @@ -143,7 +143,7 @@ public static function ACCRINTM(mixed $issue, mixed $settlement, mixed $rate, mi * * @return float|string (string containing the error type if there is an error) */ - public static function AMORDEGRC($cost, mixed $purchased, mixed $firstPeriod, mixed $salvage, $period, $rate, $basis = 0) + public static function AMORDEGRC(float $cost, mixed $purchased, mixed $firstPeriod, mixed $salvage, float $period, float $rate, int $basis = 0) { return Amortization::AMORDEGRC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis); } @@ -177,7 +177,7 @@ public static function AMORDEGRC($cost, mixed $purchased, mixed $firstPeriod, mi * * @return float|string (string containing the error type if there is an error) */ - public static function AMORLINC($cost, mixed $purchased, mixed $firstPeriod, mixed $salvage, $period, $rate, $basis = 0) + public static function AMORLINC(float $cost, mixed $purchased, mixed $firstPeriod, mixed $salvage, float $period, float $rate, int $basis = 0) { return Amortization::AMORLINC($cost, $purchased, $firstPeriod, $salvage, $period, $rate, $basis); } @@ -213,7 +213,7 @@ public static function AMORLINC($cost, mixed $purchased, mixed $firstPeriod, mix * * @return float|string */ - public static function COUPDAYBS(mixed $settlement, mixed $maturity, $frequency, $basis = 0) + public static function COUPDAYBS(mixed $settlement, mixed $maturity, int $frequency, int $basis = 0) { return Coupons::COUPDAYBS($settlement, $maturity, $frequency, $basis); } @@ -249,7 +249,7 @@ public static function COUPDAYBS(mixed $settlement, mixed $maturity, $frequency, * * @return float|string */ - public static function COUPDAYS(mixed $settlement, mixed $maturity, mixed $frequency, $basis = 0) + public static function COUPDAYS(mixed $settlement, mixed $maturity, mixed $frequency, int $basis = 0) { return Coupons::COUPDAYS($settlement, $maturity, $frequency, $basis); } @@ -285,7 +285,7 @@ public static function COUPDAYS(mixed $settlement, mixed $maturity, mixed $frequ * * @return float|string */ - public static function COUPDAYSNC(mixed $settlement, mixed $maturity, mixed $frequency, $basis = 0) + public static function COUPDAYSNC(mixed $settlement, mixed $maturity, mixed $frequency, int $basis = 0) { return Coupons::COUPDAYSNC($settlement, $maturity, $frequency, $basis); } @@ -321,7 +321,7 @@ public static function COUPDAYSNC(mixed $settlement, mixed $maturity, mixed $fre * * @return float|string Excel date/time serial value or error message */ - public static function COUPNCD(mixed $settlement, mixed $maturity, mixed $frequency, $basis = 0): string|float + public static function COUPNCD(mixed $settlement, mixed $maturity, mixed $frequency, int $basis = 0): string|float { return Coupons::COUPNCD($settlement, $maturity, $frequency, $basis); } @@ -358,7 +358,7 @@ public static function COUPNCD(mixed $settlement, mixed $maturity, mixed $freque * * @return int|string */ - public static function COUPNUM(mixed $settlement, mixed $maturity, mixed $frequency, $basis = 0) + public static function COUPNUM(mixed $settlement, mixed $maturity, mixed $frequency, int $basis = 0) { return Coupons::COUPNUM($settlement, $maturity, $frequency, $basis); } @@ -394,7 +394,7 @@ public static function COUPNUM(mixed $settlement, mixed $maturity, mixed $freque * * @return float|string Excel date/time serial value or error message */ - public static function COUPPCD(mixed $settlement, mixed $maturity, mixed $frequency, $basis = 0): string|float + public static function COUPPCD(mixed $settlement, mixed $maturity, mixed $frequency, int $basis = 0): string|float { return Coupons::COUPPCD($settlement, $maturity, $frequency, $basis); } @@ -423,7 +423,7 @@ public static function COUPPCD(mixed $settlement, mixed $maturity, mixed $freque * * @return float|string */ - public static function CUMIPMT($rate, $nper, $pv, $start, $end, $type = 0) + public static function CUMIPMT(float $rate, int $nper, float $pv, int $start, int $end, int $type = 0) { return Financial\CashFlow\Constant\Periodic\Cumulative::interest($rate, $nper, $pv, $start, $end, $type); } @@ -452,7 +452,7 @@ public static function CUMIPMT($rate, $nper, $pv, $start, $end, $type = 0) * * @return float|string */ - public static function CUMPRINC($rate, $nper, $pv, $start, $end, $type = 0) + public static function CUMPRINC(float $rate, int $nper, float $pv, int $start, int $end, int $type = 0) { return Financial\CashFlow\Constant\Periodic\Cumulative::principal($rate, $nper, $pv, $start, $end, $type); } @@ -486,7 +486,7 @@ public static function CUMPRINC($rate, $nper, $pv, $start, $end, $type = 0) * * @return float|string */ - public static function DB($cost, $salvage, $life, $period, $month = 12) + public static function DB(float $cost, float $salvage, int $life, int $period, int $month = 12) { return Depreciation::DB($cost, $salvage, $life, $period, $month); } @@ -517,7 +517,7 @@ public static function DB($cost, $salvage, $life, $period, $month = 12) * * @return float|string */ - public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) + public static function DDB(float $cost, float $salvage, int $life, int $period, float $factor = 2.0) { return Depreciation::DDB($cost, $salvage, $life, $period, $factor); } @@ -550,7 +550,7 @@ public static function DDB($cost, $salvage, $life, $period, $factor = 2.0) * * @return float|string */ - public static function DISC(mixed $settlement, mixed $maturity, mixed $price, $redemption, $basis = 0) + public static function DISC(mixed $settlement, mixed $maturity, mixed $price, int $redemption, int $basis = 0) { return Financial\Securities\Rates::discount($settlement, $maturity, $price, $redemption, $basis); } @@ -615,7 +615,7 @@ public static function DOLLARFR($decimal_dollar = null, $fraction = 0): string|f * @param float $nominalRate Nominal interest rate * @param int $periodsPerYear Number of compounding payments per year */ - public static function EFFECT($nominalRate = 0, $periodsPerYear = 0): string|float + public static function EFFECT(float $nominalRate = 0, int $periodsPerYear = 0): string|float { return Financial\InterestRate::effective($nominalRate, $periodsPerYear); } @@ -643,7 +643,7 @@ public static function EFFECT($nominalRate = 0, $periodsPerYear = 0): string|flo * 0 or omitted At the end of the period. * 1 At the beginning of the period. */ - public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0): string|float + public static function FV(float $rate = 0, int $nper = 0, float $pmt = 0, float $pv = 0, int $type = 0): string|float { return Financial\CashFlow\Constant\Periodic::futureValue($rate, $nper, $pmt, $pv, $type); } @@ -666,7 +666,7 @@ public static function FV($rate = 0, $nper = 0, $pmt = 0, $pv = 0, $type = 0): s * * @return float|string */ - public static function FVSCHEDULE($principal, $schedule) + public static function FVSCHEDULE(float $principal, array $schedule) { return Financial\CashFlow\Single::futureValue($principal, $schedule); } @@ -699,7 +699,7 @@ public static function FVSCHEDULE($principal, $schedule) * * @return float|string */ - public static function INTRATE(mixed $settlement, mixed $maturity, $investment, $redemption, $basis = 0) + public static function INTRATE(mixed $settlement, mixed $maturity, int $investment, int $redemption, int $basis = 0) { return Financial\Securities\Rates::interest($settlement, $maturity, $investment, $redemption, $basis); } @@ -724,7 +724,7 @@ public static function INTRATE(mixed $settlement, mixed $maturity, $investment, * @param float $fv Future Value * @param int $type Payment type: 0 = at the end of each period, 1 = at the beginning of each period */ - public static function IPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0): string|float + public static function IPMT(float $rate, int $per, int $nper, float $pv, float $fv = 0, int $type = 0): string|float { return Financial\CashFlow\Constant\Periodic\Interest::payment($rate, $per, $nper, $pv, $fv, $type); } @@ -830,7 +830,7 @@ public static function MIRR(mixed $values, mixed $finance_rate, mixed $reinvestm * * @return float|string Result, or a string containing an error */ - public static function NOMINAL($effectiveRate = 0, $periodsPerYear = 0): string|float + public static function NOMINAL(float $effectiveRate = 0, int $periodsPerYear = 0): string|float { return InterestRate::nominal($effectiveRate, $periodsPerYear); } @@ -852,7 +852,7 @@ public static function NOMINAL($effectiveRate = 0, $periodsPerYear = 0): string| * * @return float|string Result, or a string containing an error */ - public static function NPER($rate = 0, $pmt = 0, $pv = 0, $fv = 0, $type = 0) + public static function NPER(float $rate = 0, int $pmt = 0, float $pv = 0, float $fv = 0, int $type = 0) { return Financial\CashFlow\Constant\Periodic::periods($rate, $pmt, $pv, $fv, $type); } @@ -888,7 +888,7 @@ public static function NPV(...$args): float * * @return float|string Result, or a string containing an error */ - public static function PDURATION($rate = 0, $pv = 0, $fv = 0) + public static function PDURATION(float $rate = 0, float $pv = 0, float $fv = 0) { return Financial\CashFlow\Single::periods($rate, $pv, $fv); } @@ -910,7 +910,7 @@ public static function PDURATION($rate = 0, $pv = 0, $fv = 0) * * @return float|string Result, or a string containing an error */ - public static function PMT($rate = 0, $nper = 0, $pv = 0, $fv = 0, $type = 0) + public static function PMT(float $rate = 0, int $nper = 0, float $pv = 0, float $fv = 0, int $type = 0) { return Financial\CashFlow\Constant\Periodic\Payments::annuity($rate, $nper, $pv, $fv, $type); } @@ -934,7 +934,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): string|float + public static function PPMT(float $rate, int $per, int $nper, float $pv, float $fv = 0, int $type = 0): string|float { return Financial\CashFlow\Constant\Periodic\Payments::interestPayment($rate, $per, $nper, $pv, $fv, $type); } @@ -959,7 +959,6 @@ public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0): string * For annual payments, frequency = 1; * for semiannual, frequency = 2; * for quarterly, frequency = 4. - * @param int $frequency * @param int $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual @@ -969,7 +968,7 @@ public static function PPMT($rate, $per, $nper, $pv, $fv = 0, $type = 0): string * * @return float|string Result, or a string containing an error */ - public static function PRICE(mixed $settlement, mixed $maturity, $rate, $yield, $redemption, $frequency, $basis = 0): string|float + public static function PRICE(mixed $settlement, mixed $maturity, float $rate, float $yield, float $redemption, int $frequency, int $basis = 0): string|float { return Securities\Price::price($settlement, $maturity, $rate, $yield, $redemption, $frequency, $basis); } @@ -999,7 +998,7 @@ public static function PRICE(mixed $settlement, mixed $maturity, $rate, $yield, * * @return float|string Result, or a string containing an error */ - public static function PRICEDISC(mixed $settlement, mixed $maturity, mixed $discount, $redemption, $basis = 0) + public static function PRICEDISC(mixed $settlement, mixed $maturity, mixed $discount, int $redemption, int $basis = 0) { return Securities\Price::priceDiscounted($settlement, $maturity, $discount, $redemption, $basis); } @@ -1030,7 +1029,7 @@ public static function PRICEDISC(mixed $settlement, mixed $maturity, mixed $disc * * @return float|string Result, or a string containing an error */ - public static function PRICEMAT(mixed $settlement, mixed $maturity, mixed $issue, mixed $rate, mixed $yield, $basis = 0) + public static function PRICEMAT(mixed $settlement, mixed $maturity, mixed $issue, mixed $rate, mixed $yield, int $basis = 0) { return Securities\Price::priceAtMaturity($settlement, $maturity, $issue, $rate, $yield, $basis); } @@ -1052,7 +1051,7 @@ public static function PRICEMAT(mixed $settlement, mixed $maturity, mixed $issue * * @return float|string Result, or a string containing an error */ - public static function PV($rate = 0, $nper = 0, $pmt = 0, $fv = 0, $type = 0): string|float + public static function PV(float $rate = 0, int $nper = 0, float $pmt = 0, float $fv = 0, int $type = 0): string|float { return Financial\CashFlow\Constant\Periodic::presentValue($rate, $nper, $pmt, $fv, $type); } @@ -1140,7 +1139,7 @@ public static function RECEIVED(mixed $settlement, mixed $maturity, mixed $inves * * @return float|string Result, or a string containing an error */ - public static function RRI($nper = 0, $pv = 0, $fv = 0) + public static function RRI(float $nper = 0, float $pv = 0, float $fv = 0) { return Financial\CashFlow\Single::interestRate($nper, $pv, $fv); } @@ -1274,7 +1273,7 @@ public static function TBILLYIELD(mixed $settlement, mixed $maturity, mixed $pri * * @return float|mixed|string */ - public static function XIRR(array $values, array $dates, $guess = 0.1) + public static function XIRR(array $values, array $dates, float $guess = 0.1) { return Financial\CashFlow\Variable\NonPeriodic::rate($values, $dates, $guess); } @@ -1305,7 +1304,7 @@ public static function XIRR(array $values, array $dates, $guess = 0.1) * * @return float|mixed|string */ - public static function XNPV($rate, $values, $dates) + public static function XNPV(float $rate, array $values, array $dates) { return Financial\CashFlow\Variable\NonPeriodic::presentValue($rate, $values, $dates); } @@ -1335,7 +1334,7 @@ public static function XNPV($rate, $values, $dates) * * @return float|string Result, or a string containing an error */ - public static function YIELDDISC(mixed $settlement, mixed $maturity, mixed $price, $redemption, $basis = 0) + public static function YIELDDISC(mixed $settlement, mixed $maturity, mixed $price, int $redemption, int $basis = 0) { return Securities\Yields::yieldDiscounted($settlement, $maturity, $price, $redemption, $basis); } @@ -1366,7 +1365,7 @@ public static function YIELDDISC(mixed $settlement, mixed $maturity, mixed $pric * * @return float|string Result, or a string containing an error */ - public static function YIELDMAT(mixed $settlement, mixed $maturity, mixed $issue, mixed $rate, mixed $price, $basis = 0) + public static function YIELDMAT(mixed $settlement, mixed $maturity, mixed $issue, mixed $rate, mixed $price, int $basis = 0) { return Securities\Yields::yieldAtMaturity($settlement, $maturity, $issue, $rate, $price, $basis); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php index 8a4f16e1a0..6f60a2af18 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Single.php @@ -20,7 +20,7 @@ class Single * @param mixed $principal the present value * @param float[] $schedule an array of interest rates to apply */ - public static function futureValue(mixed $principal, $schedule): string|float + public static function futureValue(mixed $principal, array $schedule): string|float { $principal = Functions::flattenSingleValue($principal); $schedule = Functions::flattenArray($schedule); @@ -77,13 +77,13 @@ public static function periods(mixed $rate, mixed $presentValue, mixed $futureVa * * Calculates the interest rate required for an investment to grow to a specified future value . * - * @param float $periods The number of periods over which the investment is made - * @param float $presentValue Present Value - * @param float $futureValue Future Value + * @param array|float $periods The number of periods over which the investment is made + * @param array|float $presentValue Present Value + * @param array|float $futureValue Future Value * * @return float|string Result, or a string containing an error */ - public static function interestRate($periods = 0.0, $presentValue = 0.0, $futureValue = 0.0): string|float + public static function interestRate(array|float $periods = 0.0, array|float $presentValue = 0.0, array|float $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 2c6453ab35..8c6f615b87 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/Variable/NonPeriodic.php @@ -106,7 +106,7 @@ public static function rate(array $values, array $dates, mixed $guess = self::DE * Excel Function: * =XNPV(rate,values,dates) * - * @param float $rate the discount rate to apply to the cash flows + * @param array|float $rate the discount rate to apply to the cash flows * @param float[] $values A series of cash flows that corresponds to a schedule of payments in dates. * The first payment is optional and corresponds to a cost or payment that occurs * at the beginning of the investment. @@ -117,7 +117,7 @@ public static function rate(array $values, array $dates, mixed $guess = self::DE * The first payment date indicates the beginning of the schedule of payments. * All other dates must be later than this date, but they may occur in any order. */ - public static function presentValue($rate, $values, $dates): float|string + public static function presentValue(array|float $rate, array $values, array $dates): float|string { return self::xnpvOrdered($rate, $values, $dates, true); } diff --git a/src/PhpSpreadsheet/Calculation/FormulaParser.php b/src/PhpSpreadsheet/Calculation/FormulaParser.php index 12938a5abc..a2a08f3914 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaParser.php +++ b/src/PhpSpreadsheet/Calculation/FormulaParser.php @@ -61,7 +61,7 @@ class FormulaParser * * @param ?string $formula Formula to parse */ - public function __construct($formula = '') + public function __construct(?string $formula = '') { // Check parameters if ($formula === null) { diff --git a/src/PhpSpreadsheet/Calculation/FormulaToken.php b/src/PhpSpreadsheet/Calculation/FormulaToken.php index ab6c09c7e6..cc7d48fcd2 100644 --- a/src/PhpSpreadsheet/Calculation/FormulaToken.php +++ b/src/PhpSpreadsheet/Calculation/FormulaToken.php @@ -70,11 +70,10 @@ class FormulaToken /** * Create a new FormulaToken. * - * @param string $value * @param string $tokenType Token type (represented by TOKEN_TYPE_*) * @param string $tokenSubType Token Subtype (represented by TOKEN_SUBTYPE_*) */ - public function __construct($value, $tokenType = self::TOKEN_TYPE_UNKNOWN, $tokenSubType = self::TOKEN_SUBTYPE_NOTHING) + public function __construct(string $value, string $tokenType = self::TOKEN_TYPE_UNKNOWN, string $tokenSubType = self::TOKEN_SUBTYPE_NOTHING) { // Initialise values $this->value = $value; @@ -92,10 +91,8 @@ public function getValue(): string /** * Set Value. - * - * @param string $value */ - public function setValue($value): void + public function setValue(string $value): void { $this->value = $value; } @@ -110,10 +107,8 @@ public function getTokenType(): string /** * Set Token Type (represented by TOKEN_TYPE_*). - * - * @param string $value */ - public function setTokenType($value): void + public function setTokenType(string $value): void { $this->tokenType = $value; } @@ -128,10 +123,8 @@ public function getTokenSubType(): string /** * Set Token SubType (represented by TOKEN_SUBTYPE_*). - * - * @param string $value */ - public function setTokenSubType($value): void + public function setTokenSubType(string $value): void { $this->tokenSubType = $value; } diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 14de737093..a0230b4405 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -47,7 +47,7 @@ class Functions * * @return bool (Success or Failure) */ - public static function setCompatibilityMode($compatibilityMode): bool + public static function setCompatibilityMode(string $compatibilityMode): bool { if ( ($compatibilityMode == self::COMPATIBILITY_EXCEL) @@ -87,7 +87,7 @@ public static function getCompatibilityMode(): string * * @return bool Success or failure */ - public static function setReturnDateType($returnDateType): bool + public static function setReturnDateType(string $returnDateType): bool { if ( ($returnDateType == self::RETURNDATE_UNIX_TIMESTAMP) diff --git a/src/PhpSpreadsheet/Calculation/LookupRef.php b/src/PhpSpreadsheet/Calculation/LookupRef.php index 0a3a372db9..6836d2adce 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef.php @@ -41,7 +41,7 @@ class LookupRef * FALSE CELL_ADDRESS returns an R1C1-style reference * @param array|string $sheetText Optional Name of worksheet to use */ - public static function cellAddress(mixed $row, mixed $column, $relativity = 1, $referenceStyle = true, $sheetText = ''): string|array + public static function cellAddress(mixed $row, mixed $column, int $relativity = 1, bool $referenceStyle = true, $sheetText = ''): string|array { return Address::cell($row, $column, $relativity, $referenceStyle, $sheetText); } @@ -222,7 +222,7 @@ public static function INDIRECT($cellAddress, Cell $cell) * * @return array|int|string An array containing a cell or range of cells, or a string on error */ - public static function OFFSET($cellAddress = null, mixed $rows = 0, mixed $columns = 0, mixed $height = null, mixed $width = null, ?Cell $cell = null) + public static function OFFSET(?string $cellAddress = null, mixed $rows = 0, mixed $columns = 0, mixed $height = null, mixed $width = null, ?Cell $cell = null) { return Offset::OFFSET($cellAddress, $rows, $columns, $height, $width, $cell); } @@ -311,7 +311,7 @@ public static function INDEX(mixed $matrix, mixed $rowNum = 0, mixed $columnNum * 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): array + public static function TRANSPOSE(array $matrixData): array { return Matrix::transpose($matrixData); } diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php b/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php index bb15e199fc..260ccc3a59 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Offset.php @@ -41,7 +41,7 @@ class Offset * * @return array|string An array containing a cell or range of cells, or a string on error */ - public static function OFFSET($cellAddress = null, mixed $rows = 0, mixed $columns = 0, mixed $height = null, mixed $width = null, ?Cell $cell = null): string|array + public static function OFFSET(?string $cellAddress = null, mixed $rows = 0, mixed $columns = 0, mixed $height = null, mixed $width = null, ?Cell $cell = null): string|array { $rows = Functions::flattenSingleValue($rows); $columns = Functions::flattenSingleValue($columns); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php b/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php index 97986715cf..9ad47b4ed9 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Sort.php @@ -158,10 +158,7 @@ private static function validateSortOrder(mixed $sortOrder): int return $sortOrder; } - /** - * @param array $sortIndex - */ - private static function validateArrayArgumentsForSort(&$sortIndex, mixed &$sortOrder, int $sortArraySize): void + private static function validateArrayArgumentsForSort(array &$sortIndex, mixed &$sortOrder, int $sortArraySize): void { // It doesn't matter if they're row or column vectors, it works either way $sortIndex = Functions::flattenArray($sortIndex); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig.php b/src/PhpSpreadsheet/Calculation/MathTrig.php index 58a56a0b74..c452b05d35 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig.php @@ -70,13 +70,9 @@ public static function ATAN2($xCoordinate = null, $yCoordinate = null): string|f * Use the evaluate method in the MathTrig\Base class instead * @see MathTrig\Base::evaluate() * - * @param float $number - * @param float $radix - * @param int $minLength - * * @return array|string the text representation with the given radix (base) */ - public static function BASE($number, $radix, $minLength = null): string|array + public static function BASE(float $number, float $radix, ?int $minLength = null): string|array { return MathTrig\Base::evaluate($number, $radix, $minLength); } @@ -101,7 +97,7 @@ public static function BASE($number, $radix, $minLength = null): string|array * * @return array|float|string Rounded Number, or a string containing an error */ - public static function CEILING($number, $significance = null) + public static function CEILING(float $number, ?float $significance = null) { return MathTrig\Ceiling::ceiling($number, $significance); } @@ -226,7 +222,7 @@ public static function FACTDOUBLE($factVal) * * @return array|float|string Rounded Number, or a string containing an error */ - public static function FLOOR($number, $significance = null) + public static function FLOOR(float $number, ?float $significance = null) { return MathTrig\Floor::floor($number, $significance); } @@ -249,7 +245,7 @@ public static function FLOOR($number, $significance = null) * * @return array|float|string Rounded Number, or a string containing an error */ - public static function FLOORMATH($number, $significance = null, $mode = 0) + public static function FLOORMATH(float $number, ?float $significance = null, int $mode = 0) { return MathTrig\Floor::math($number, $significance, $mode); } @@ -271,7 +267,7 @@ public static function FLOORMATH($number, $significance = null, $mode = 0) * * @return array|float|string Rounded Number, or a string containing an error */ - public static function FLOORPRECISE($number, $significance = 1) + public static function FLOORPRECISE(float $number, float $significance = 1) { return MathTrig\Floor::precise($number, $significance); } @@ -361,7 +357,7 @@ public static function LCM(mixed ...$args) * * @return array|float|string The result, or a string containing an error */ - public static function logBase($number, $base = 10): string|float|array + public static function logBase(float $number, float $base = 10): string|float|array { return MathTrig\Logarithms::withBase($number, $base); } @@ -382,7 +378,7 @@ public static function logBase($number, $base = 10): string|float|array * * @return float|string The result, or a string containing an error */ - public static function MDETERM($matrixValues) + public static function MDETERM(array $matrixValues) { return MathTrig\MatrixFunctions::determinant($matrixValues); } @@ -403,7 +399,7 @@ public static function MDETERM($matrixValues) * * @return array|string The result, or a string containing an error */ - public static function MINVERSE($matrixValues): string|array + public static function MINVERSE(array $matrixValues): string|array { return MathTrig\MatrixFunctions::inverse($matrixValues); } @@ -420,7 +416,7 @@ public static function MINVERSE($matrixValues): string|array * * @return array|string The result, or a string containing an error */ - public static function MMULT($matrixData1, $matrixData2): string|array + public static function MMULT(array $matrixData1, array $matrixData2): string|array { return MathTrig\MatrixFunctions::multiply($matrixData1, $matrixData2); } @@ -437,7 +433,7 @@ public static function MMULT($matrixData1, $matrixData2): string|array * * @return array|float|int|string Remainder, or a string containing an error */ - public static function MOD($a = 1, $b = 1) + public static function MOD(int $a = 1, int $b = 1) { return MathTrig\Operations::mod($a, $b); } @@ -456,7 +452,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): string|int|float|array + public static function MROUND(float $number, $multiple): string|int|float|array { return MathTrig\Round::multiple($number, $multiple); } @@ -506,12 +502,9 @@ public static function ODD($number): string|int|float|array * Use the evaluate method in the MathTrig\Power class instead * @see MathTrig\Operations::power() * - * @param float $x - * @param float $y - * * @return array|float|int|string The result, or a string containing an error */ - public static function POWER($x = 0, $y = 2) + public static function POWER(float $x = 0, float $y = 2) { return MathTrig\Operations::power($x, $y); } @@ -569,7 +562,7 @@ public static function QUOTIENT(mixed $numerator, mixed $denominator) * * @return array|int|string Random number */ - public static function RAND($min = 0, $max = 0): string|int|array + public static function RAND(int $min = 0, int $max = 0): string|int|array { return MathTrig\Random::randBetween($min, $max); } @@ -721,7 +714,7 @@ public static function SQRTPI($number): string|float|array * * @return float|string */ - public static function SUBTOTAL($functionType, ...$args) + public static function SUBTOTAL(int $functionType, ...$args) { return MathTrig\Subtotal::evaluate($functionType, ...$args); } @@ -764,7 +757,7 @@ public static function SUM(mixed ...$args) * * @return null|float|string */ - public static function SUMIF(array $range, $criteria, array $sumRange = []) + public static function SUMIF(array $range, string $criteria, array $sumRange = []) { return Statistical\Conditional::SUMIF($range, $criteria, $sumRange); } @@ -842,7 +835,7 @@ public static function SUMSQ(mixed ...$args) * * @return float|string */ - public static function SUMX2MY2($matrixData1, $matrixData2) + public static function SUMX2MY2(array $matrixData1, array $matrixData2) { return MathTrig\SumSquares::sumXSquaredMinusYSquared($matrixData1, $matrixData2); } @@ -859,7 +852,7 @@ public static function SUMX2MY2($matrixData1, $matrixData2) * * @return float|string */ - public static function SUMX2PY2($matrixData1, $matrixData2) + public static function SUMX2PY2(array $matrixData1, array $matrixData2) { return MathTrig\SumSquares::sumXSquaredPlusYSquared($matrixData1, $matrixData2); } @@ -876,7 +869,7 @@ public static function SUMX2PY2($matrixData1, $matrixData2) * * @return float|string */ - public static function SUMXMY2($matrixData1, $matrixData2) + public static function SUMXMY2(array $matrixData1, array $matrixData2) { return MathTrig\SumSquares::sumXMinusYSquared($matrixData1, $matrixData2); } @@ -890,12 +883,9 @@ public static function SUMXMY2($matrixData1, $matrixData2) * Use the evaluate() method in the MathTrig\Trunc class instead * @see MathTrig\Trunc::evaluate() * - * @param float $value - * @param int $digits - * * @return array|float|string Truncated value, or a string containing an error */ - public static function TRUNC($value = 0, $digits = 0) + public static function TRUNC(float $value = 0, int $digits = 0) { return MathTrig\Trunc::evaluate($value, $digits); } @@ -1037,7 +1027,7 @@ public static function ACOT($number) * * @return float|string */ - public static function numberOrNan($result) + public static function numberOrNan(float $result) { return MathTrig\Helpers::numberOrNan($result); } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php b/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php index 4b780ab13a..57918a1f9d 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php @@ -22,11 +22,8 @@ class Arabic /** * Recursively calculate the arabic value of a roman numeral. - * - * @param int $sum - * @param int $subtract */ - private static function calculateArabic(array $roman, &$sum = 0, $subtract = 0): int + private static function calculateArabic(array $roman, int &$sum = 0, int $subtract = 0): int { $numeral = array_shift($roman); if (!isset(self::ROMAN_LOOKUP[$numeral])) { diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php b/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php index 28b9711ae2..d2e680bc4c 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php @@ -118,7 +118,7 @@ public static function getEven(float $number): float * * @return float|string */ - public static function numberOrNan($result) + public static function numberOrNan(float $result) { return is_nan($result) ? ExcelError::NAN() : $result; } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Random.php b/src/PhpSpreadsheet/Calculation/MathTrig/Random.php index 055872bbce..16f7f21c32 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Random.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Random.php @@ -67,7 +67,7 @@ public static function randBetween(mixed $min, mixed $max): array|string|int * * @return array|string The resulting array, or a string containing an error */ - public static function randArray(mixed $rows = 1, mixed $columns = 1, mixed $min = 0, mixed $max = 1, $wholeNumber = false): string|array + public static function randArray(mixed $rows = 1, mixed $columns = 1, mixed $min = 0, mixed $max = 1, bool $wholeNumber = false): string|array { try { $rows = (int) Helpers::validateNumericNullSubstitution($rows, 1); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php b/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php index 1e5b5d55e7..4c931a7044 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php @@ -63,7 +63,7 @@ private static function numericNotString(mixed $item): bool * * @return float|string */ - public static function sumXSquaredMinusYSquared($matrixData1, $matrixData2): string|int|float + public static function sumXSquaredMinusYSquared(array $matrixData1, array $matrixData2): string|int|float { try { $array1 = Functions::flattenArray($matrixData1); @@ -91,7 +91,7 @@ public static function sumXSquaredMinusYSquared($matrixData1, $matrixData2): str * * @return float|string */ - public static function sumXSquaredPlusYSquared($matrixData1, $matrixData2): string|int|float + public static function sumXSquaredPlusYSquared(array $matrixData1, array $matrixData2): string|int|float { try { $array1 = Functions::flattenArray($matrixData1); @@ -119,7 +119,7 @@ public static function sumXSquaredPlusYSquared($matrixData1, $matrixData2): stri * * @return float|string */ - public static function sumXMinusYSquared($matrixData1, $matrixData2): string|int|float + public static function sumXMinusYSquared(array $matrixData1, array $matrixData2): string|int|float { try { $array1 = Functions::flattenArray($matrixData1); diff --git a/src/PhpSpreadsheet/Calculation/Statistical.php b/src/PhpSpreadsheet/Calculation/Statistical.php index 1cb08a54ed..340fa4e233 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical.php +++ b/src/PhpSpreadsheet/Calculation/Statistical.php @@ -105,7 +105,7 @@ public static function AVERAGEA(mixed ...$args) * * @return null|float|string */ - public static function AVERAGEIF(mixed $range, $condition, $averageRange = []) + public static function AVERAGEIF(mixed $range, string $condition, array $averageRange = []) { return Conditional::AVERAGEIF($range, $condition, $averageRange); } @@ -123,7 +123,7 @@ public static function AVERAGEIF(mixed $range, $condition, $averageRange = []) * @param float $alpha Parameter to the distribution * @param float $beta Parameter to the distribution */ - public static function BETADIST($value, $alpha, $beta, mixed $rMin = 0, mixed $rMax = 1): string|float|array + public static function BETADIST(float $value, float $alpha, float $beta, mixed $rMin = 0, mixed $rMax = 1): string|float|array { return Statistical\Distributions\Beta::distribution($value, $alpha, $beta, $rMin, $rMax); } @@ -145,7 +145,7 @@ public static function BETADIST($value, $alpha, $beta, mixed $rMin = 0, mixed $r * * @return array|float|string */ - public static function BETAINV($probability, $alpha, $beta, $rMin = 0, $rMax = 1) + public static function BETAINV(float $probability, float $alpha, float $beta, float $rMin = 0, float $rMax = 1) { return Statistical\Distributions\Beta::inverse($probability, $alpha, $beta, $rMin, $rMax); } @@ -188,7 +188,7 @@ public static function BINOMDIST(mixed $value, mixed $trials, mixed $probability * * @return array|float|string */ - public static function CHIDIST($value, $degrees) + public static function CHIDIST(float $value, float $degrees) { return Statistical\Distributions\ChiSquared::distributionRightTail($value, $degrees); } @@ -207,7 +207,7 @@ public static function CHIDIST($value, $degrees) * * @return array|float|string */ - public static function CHIINV($probability, $degrees) + public static function CHIINV(float $probability, float $degrees) { return Statistical\Distributions\ChiSquared::inverseRightTail($probability, $degrees); } @@ -221,13 +221,11 @@ public static function CHIINV($probability, $degrees) * Use the CONFIDENCE() method in the Statistical\Confidence class instead * @see Statistical\Confidence::CONFIDENCE() * - * @param float $alpha * @param float $stdDev Standard Deviation - * @param float $size * * @return array|float|string */ - public static function CONFIDENCE($alpha, $stdDev, $size) + public static function CONFIDENCE(float $alpha, float $stdDev, float $size) { return Confidence::CONFIDENCE($alpha, $stdDev, $size); } @@ -325,7 +323,7 @@ public static function COUNTBLANK(mixed $range): int * * @return int|string */ - public static function COUNTIF(mixed $range, $condition) + public static function COUNTIF(mixed $range, string $condition) { return Conditional::COUNTIF($range, $condition); } @@ -388,7 +386,7 @@ public static function COVAR(array $yValues, array $xValues) * * @return array|int|string */ - public static function CRITBINOM($trials, $probability, $alpha) + public static function CRITBINOM(float $trials, float $probability, float $alpha) { return Statistical\Distributions\Binomial::inverse($trials, $probability, $alpha); } @@ -427,11 +425,10 @@ public static function DEVSQ(mixed ...$args) * * @param float $value Value of the function * @param float $lambda The parameter value - * @param bool $cumulative * * @return array|float|string */ - public static function EXPONDIST($value, $lambda, $cumulative) + public static function EXPONDIST(float $value, float $lambda, bool $cumulative) { return Statistical\Distributions\Exponential::distribution($value, $lambda, $cumulative); } @@ -456,7 +453,7 @@ public static function EXPONDIST($value, $lambda, $cumulative) * * @return array|float|string */ - public static function FDIST2($value, $u, $v, $cumulative) + public static function FDIST2(float $value, int $u, int $v, bool $cumulative) { return Statistical\Distributions\F::distribution($value, $u, $v, $cumulative); } @@ -472,11 +469,9 @@ public static function FDIST2($value, $u, $v, $cumulative) * Use the distribution() method in the Statistical\Distributions\Fisher class instead * @see Statistical\Distributions\Fisher::distribution() * - * @param float $value - * * @return array|float|string */ - public static function FISHER($value) + public static function FISHER(float $value) { return Statistical\Distributions\Fisher::distribution($value); } @@ -492,11 +487,9 @@ public static function FISHER($value) * Use the inverse() method in the Statistical\Distributions\Fisher class instead * @see Statistical\Distributions\Fisher::inverse() * - * @param float $value - * * @return array|float|string */ - public static function FISHERINV($value) + public static function FISHERINV(float $value) { return Statistical\Distributions\Fisher::inverse($value); } @@ -516,7 +509,7 @@ public static function FISHERINV($value) * * @return array|bool|float|string */ - public static function FORECAST($xValue, array $yValues, array $xValues) + public static function FORECAST(float $xValue, array $yValues, array $xValues) { return Trends::FORECAST($xValue, $yValues, $xValues); } @@ -530,11 +523,9 @@ public static function FORECAST($xValue, array $yValues, array $xValues) * Use the gamma() method in the Statistical\Distributions\Gamma class instead * @see Statistical\Distributions\Gamma::gamma() * - * @param float $value - * * @return array|float|string The result, or a string containing an error */ - public static function GAMMAFunction($value): string|float|array + public static function GAMMAFunction(float $value): string|float|array { return Statistical\Distributions\Gamma::gamma($value); } @@ -551,11 +542,10 @@ public static function GAMMAFunction($value): string|float|array * @param float $value Value at which you want to evaluate the distribution * @param float $a Parameter to the distribution * @param float $b Parameter to the distribution - * @param bool $cumulative * * @return array|float|string */ - public static function GAMMADIST($value, $a, $b, $cumulative) + public static function GAMMADIST(float $value, float $a, float $b, bool $cumulative) { return Statistical\Distributions\Gamma::distribution($value, $a, $b, $cumulative); } @@ -575,7 +565,7 @@ public static function GAMMADIST($value, $a, $b, $cumulative) * * @return array|float|string */ - public static function GAMMAINV($probability, $alpha, $beta) + public static function GAMMAINV(float $probability, float $alpha, float $beta) { return Statistical\Distributions\Gamma::inverse($probability, $alpha, $beta); } @@ -588,10 +578,8 @@ public static function GAMMAINV($probability, $alpha, $beta) * @deprecated 1.18.0 * Use the ln() method in the Statistical\Distributions\Gamma class instead * @see Statistical\Distributions\Gamma::ln() - * - * @param float $value */ - public static function GAMMALN($value): string|float|array + public static function GAMMALN(float $value): string|float|array { return Statistical\Distributions\Gamma::ln($value); } @@ -606,11 +594,9 @@ public static function GAMMALN($value): string|float|array * Use the gauss() method in the Statistical\Distributions\StandardNormal class instead * @see Statistical\Distributions\StandardNormal::gauss() * - * @param float $value - * * @return array|float|string The result, or a string containing an error */ - public static function GAUSS($value) + public static function GAUSS(float $value) { return Statistical\Distributions\StandardNormal::gauss($value); } @@ -654,7 +640,7 @@ public static function GEOMEAN(mixed ...$args) * * @return float[] */ - public static function GROWTH($yValues, $xValues = [], $newValues = [], $const = true): array + public static function GROWTH(array $yValues, array $xValues = [], array $newValues = [], bool $const = true): array { return Trends::GROWTH($yValues, $xValues, $newValues, $const); } @@ -787,7 +773,7 @@ public static function LARGE(mixed ...$args) * * @return array|string The result, or a string containing an error */ - public static function LINEST(array $yValues, $xValues = null, $const = true, $stats = false): string|array + public static function LINEST(array $yValues, ?array $xValues = null, bool $const = true, bool $stats = false): string|array { return Trends::LINEST($yValues, $xValues, $const, $stats); } @@ -809,7 +795,7 @@ public static function LINEST(array $yValues, $xValues = null, $const = true, $s * * @return array|string The result, or a string containing an error */ - public static function LOGEST(array $yValues, $xValues = null, $const = true, $stats = false): string|array + public static function LOGEST(array $yValues, ?array $xValues = null, bool $const = true, bool $stats = false): string|array { return Trends::LOGEST($yValues, $xValues, $const, $stats); } @@ -823,17 +809,13 @@ public static function LOGEST(array $yValues, $xValues = null, $const = true, $s * Use the inverse() method in the Statistical\Distributions\LogNormal class instead * @see Statistical\Distributions\LogNormal::inverse() * - * @param float $probability - * @param float $mean - * @param float $stdDev - * * @return array|float|string The result, or a string containing an error * * @TODO Try implementing P J Acklam's refinement algorithm for greater * 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): string|float|array + public static function LOGINV(float $probability, float $mean, float $stdDev): string|float|array { return Statistical\Distributions\LogNormal::inverse($probability, $mean, $stdDev); } @@ -848,13 +830,9 @@ public static function LOGINV($probability, $mean, $stdDev): string|float|array * Use the cumulative() method in the Statistical\Distributions\LogNormal class instead * @see Statistical\Distributions\LogNormal::cumulative() * - * @param float $value - * @param float $mean - * @param float $stdDev - * * @return array|float|string The result, or a string containing an error */ - public static function LOGNORMDIST($value, $mean, $stdDev) + public static function LOGNORMDIST(float $value, float $mean, float $stdDev) { return Statistical\Distributions\LogNormal::cumulative($value, $mean, $stdDev); } @@ -869,14 +847,9 @@ public static function LOGNORMDIST($value, $mean, $stdDev) * Use the distribution() method in the Statistical\Distributions\LogNormal class instead * @see Statistical\Distributions\LogNormal::distribution() * - * @param float $value - * @param float $mean - * @param float $stdDev - * @param bool $cumulative - * * @return array|float|string The result, or a string containing an error */ - public static function LOGNORMDIST2($value, $mean, $stdDev, $cumulative = false) + public static function LOGNORMDIST2(float $value, float $mean, float $stdDev, bool $cumulative = false) { return Statistical\Distributions\LogNormal::distribution($value, $mean, $stdDev, $cumulative); } @@ -1221,7 +1194,7 @@ public static function PERCENTRANK(mixed $valueSet, mixed $value, mixed $signifi * * @return array|float|int|string Number of permutations, or a string containing an error */ - public static function PERMUT($numObjs, $numInSet) + public static function PERMUT(int $numObjs, int $numInSet) { return Permutations::PERMUT($numObjs, $numInSet); } @@ -1383,7 +1356,7 @@ public static function SMALL(mixed ...$args) * * @return array|float|string Standardized value, or a string containing an error */ - public static function STANDARDIZE($value, $mean, $stdDev) + public static function STANDARDIZE(float $value, float $mean, float $stdDev) { return Statistical\Standardize::execute($value, $mean, $stdDev); } @@ -1507,7 +1480,7 @@ public static function STEYX(array $yValues, array $xValues) * * @return array|float|string The result, or a string containing an error */ - public static function TDIST($value, $degrees, $tails) + public static function TDIST(float $value, float $degrees, float $tails) { return Statistical\Distributions\StudentT::distribution($value, $degrees, $tails); } @@ -1526,7 +1499,7 @@ public static function TDIST($value, $degrees, $tails) * * @return array|float|string The result, or a string containing an error */ - public static function TINV($probability, $degrees) + public static function TINV(float $probability, float $degrees) { return Statistical\Distributions\StudentT::inverse($probability, $degrees); } @@ -1547,7 +1520,7 @@ public static function TINV($probability, $degrees) * * @return float[] */ - public static function TREND($yValues, $xValues = [], $newValues = [], $const = true): array + public static function TREND(array $yValues, array $xValues = [], array $newValues = [], bool $const = true): array { return Trends::TREND($yValues, $xValues, $newValues, $const); } @@ -1669,14 +1642,12 @@ public static function VARPA(mixed ...$args) * Use the distribution() method in the Statistical\Distributions\Weibull class instead * @see Statistical\Distributions\Weibull::distribution() * - * @param float $value * @param float $alpha Alpha Parameter * @param float $beta Beta Parameter - * @param bool $cumulative * * @return array|float|string (string if result is an error) */ - public static function WEIBULL($value, $alpha, $beta, $cumulative) + public static function WEIBULL(float $value, float $alpha, float $beta, bool $cumulative) { return Statistical\Distributions\Weibull::distribution($value, $alpha, $beta, $cumulative); } @@ -1698,7 +1669,7 @@ public static function WEIBULL($value, $alpha, $beta, $cumulative) * * @return array|float|string (string if result is an error) */ - public static function ZTEST(mixed $dataSet, $m0, $sigma = null) + public static function ZTEST(mixed $dataSet, float $m0, ?float $sigma = null) { return Statistical\Distributions\StandardNormal::zTest($dataSet, $m0, $sigma); } diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php index 02c2811284..3f15c9b1b2 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php @@ -25,12 +25,12 @@ class Conditional * AVERAGEIF(range,condition[, average_range]) * * @param mixed $range Data values - * @param string $condition the criteria that defines which cells will be checked + * @param null|array|string $condition the criteria that defines which cells will be checked * @param mixed $averageRange Data values * * @return null|float|string */ - public static function AVERAGEIF(mixed $range, $condition, mixed $averageRange = []) + public static function AVERAGEIF(mixed $range, null|array|string $condition, mixed $averageRange = []) { if (!is_array($range) || !is_array($averageRange) || array_key_exists(0, $range) || array_key_exists(0, $averageRange)) { throw new CalcException('Must specify range of cells, not any kind of literal'); @@ -81,9 +81,9 @@ public static function AVERAGEIFS(mixed ...$args) * COUNTIF(range,condition) * * @param mixed[] $range Data values - * @param string $condition the criteria that defines which cells will be counted + * @param null|array|string $condition the criteria that defines which cells will be counted */ - public static function COUNTIF($range, $condition): string|int + public static function COUNTIF(array $range, null|array|string $condition): string|int { // Filter out any empty values that shouldn't be included in a COUNT $range = array_filter( diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php index 3db6c0606a..dcc55d72e5 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php @@ -155,7 +155,7 @@ public static function FORECAST(mixed $xValue, array $yValues, array $xValues) * * @return float[] */ - public static function GROWTH($yValues, $xValues = [], $newValues = [], mixed $const = true): array + public static function GROWTH(array $yValues, array $xValues = [], array $newValues = [], mixed $const = true): array { $yValues = Functions::flattenArray($yValues); $xValues = Functions::flattenArray($xValues); @@ -212,7 +212,7 @@ public static function INTERCEPT(array $yValues, array $xValues) * * @return array|string The result, or a string containing an error */ - public static function LINEST(array $yValues, $xValues = null, mixed $const = true, mixed $stats = false): string|array + public static function LINEST(array $yValues, ?array $xValues = null, mixed $const = true, mixed $stats = false): string|array { $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats); @@ -273,7 +273,7 @@ public static function LINEST(array $yValues, $xValues = null, mixed $const = tr * * @return array|string The result, or a string containing an error */ - public static function LOGEST(array $yValues, $xValues = null, mixed $const = true, mixed $stats = false): string|array + public static function LOGEST(array $yValues, ?array $xValues = null, mixed $const = true, mixed $stats = false): string|array { $const = ($const === null) ? true : (bool) Functions::flattenSingleValue($const); $stats = ($stats === null) ? false : (bool) Functions::flattenSingleValue($stats); @@ -412,7 +412,7 @@ public static function STEYX(array $yValues, array $xValues) * * @return float[] */ - public static function TREND($yValues, $xValues = [], $newValues = [], mixed $const = true): array + public static function TREND(array $yValues, array $xValues = [], array $newValues = [], mixed $const = true): array { $yValues = Functions::flattenArray($yValues); $xValues = Functions::flattenArray($xValues); diff --git a/src/PhpSpreadsheet/Calculation/TextData.php b/src/PhpSpreadsheet/Calculation/TextData.php index 94edad898f..0adb6ca9a9 100644 --- a/src/PhpSpreadsheet/Calculation/TextData.php +++ b/src/PhpSpreadsheet/Calculation/TextData.php @@ -20,7 +20,7 @@ class TextData * * @return array|string */ - public static function CHARACTER($character) + public static function CHARACTER(string $character) { return TextData\CharacterConvert::character($character); } @@ -102,7 +102,7 @@ public static function CONCATENATE(...$args): string * * @return array|string */ - public static function DOLLAR($value = 0, $decimals = 2) + public static function DOLLAR(float $value = 0, int $decimals = 2) { return TextData\Format::DOLLAR($value, $decimals); } @@ -151,12 +151,10 @@ public static function SEARCHINSENSITIVE($needle, $haystack, $offset = 1) * @see TextData\Format::FIXEDFORMAT() * * @param mixed $value Value to check - * @param int $decimals - * @param bool $no_commas * * @return array|string */ - public static function FIXEDFORMAT(mixed $value, $decimals = 2, $no_commas = false) + public static function FIXEDFORMAT(mixed $value, int $decimals = 2, bool $no_commas = false) { return TextData\Format::FIXEDFORMAT($value, $decimals, $no_commas); } @@ -216,7 +214,7 @@ public static function RIGHT($value = '', $chars = 1): string|array * * @param string $value Value */ - public static function STRINGLENGTH($value = ''): int|array + public static function STRINGLENGTH(string $value = ''): int|array { return TextData\Text::length($value); } @@ -245,10 +243,8 @@ public static function LOWERCASE($mixedCaseString): string|array * @deprecated 1.18.0 * Use the upper() method in the TextData\CaseConvert class instead * @see TextData\CaseConvert::upper() - * - * @param string $mixedCaseString */ - public static function UPPERCASE($mixedCaseString): string|array + public static function UPPERCASE(string $mixedCaseString): string|array { return TextData\CaseConvert::upper($mixedCaseString); } @@ -283,7 +279,7 @@ public static function PROPERCASE($mixedCaseString): string|array * * @return array|string */ - public static function REPLACE($oldText, $start, $chars, $newText) + public static function REPLACE(string $oldText, int $start, int $chars, string $newText) { return TextData\Replace::replace($oldText, $start, $chars, $newText); } @@ -302,7 +298,7 @@ public static function REPLACE($oldText, $start, $chars, $newText) * * @return array|string */ - public static function SUBSTITUTE($text = '', $fromText = '', $toText = '', $instance = 0) + public static function SUBSTITUTE(string $text = '', string $fromText = '', string $toText = '', int $instance = 0) { return TextData\Replace::substitute($text, $fromText, $toText, $instance); } @@ -333,7 +329,7 @@ public static function RETURNSTRING(mixed $testValue = ''): string|array * * @return array|string */ - public static function TEXTFORMAT(mixed $value, $format) + public static function TEXTFORMAT(mixed $value, string $format) { return TextData\Format::TEXTFORMAT($value, $format); } @@ -367,7 +363,7 @@ public static function VALUE(mixed $value = '') * * @return array|float|string */ - public static function NUMBERVALUE(mixed $value = '', $decimalSeparator = null, $groupSeparator = null) + public static function NUMBERVALUE(mixed $value = '', ?string $decimalSeparator = null, ?string $groupSeparator = null) { return TextData\Format::NUMBERVALUE($value, $decimalSeparator, $groupSeparator); } diff --git a/src/PhpSpreadsheet/Calculation/TextData/Extract.php b/src/PhpSpreadsheet/Calculation/TextData/Extract.php index 275b2395e9..5b99b919ec 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Extract.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Extract.php @@ -218,11 +218,10 @@ public static function after(mixed $text, $delimiter, mixed $instance = 1, mixed /** * @param null|array|string $delimiter - * @param int $matchEnd * * @return array|string */ - private static function validateTextBeforeAfter(string $text, $delimiter, int $instance, int $matchMode, $matchEnd, mixed $ifNotFound) + private static function validateTextBeforeAfter(string $text, $delimiter, int $instance, int $matchMode, int $matchEnd, mixed $ifNotFound) { $flags = self::matchFlags($matchMode); $delimiter = self::buildDelimiter($delimiter); diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index 79c02f0f06..3a2b689d58 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -431,7 +431,7 @@ public function getDataType(): string * * @param string $dataType see DataType::TYPE_* */ - public function setDataType($dataType): self + public function setDataType(string $dataType): self { $this->setValueExplicit($this->value, $dataType); diff --git a/src/PhpSpreadsheet/Cell/Coordinate.php b/src/PhpSpreadsheet/Cell/Coordinate.php index e371941afc..e06a3d068b 100644 --- a/src/PhpSpreadsheet/Cell/Coordinate.php +++ b/src/PhpSpreadsheet/Cell/Coordinate.php @@ -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): bool + public static function coordinateIsRange(string $cellAddress): bool { return str_contains($cellAddress, ':') || str_contains($cellAddress, ','); } @@ -76,13 +76,14 @@ public static function coordinateIsRange($cellAddress): bool /** * Make string row, column or cell coordinate absolute. * - * @param string $cellAddress e.g. 'A' or '1' or 'A1' + * @param int|string $cellAddress e.g. 'A' or '1' or 'A1' * Note that this value can be a row or column reference as well as a cell reference * * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1' */ - public static function absoluteReference($cellAddress): string + public static function absoluteReference(int|string $cellAddress): string { + $cellAddress = (string) $cellAddress; if (self::coordinateIsRange($cellAddress)) { throw new Exception('Cell coordinate string can not be a range of cells'); } @@ -140,7 +141,7 @@ public static function absoluteCoordinate(string $cellAddress): string * e.g. ['B4','D9'] or [['B4','D9'], ['H2','O11']] * or ['B4'] */ - public static function splitRange($range): array + public static function splitRange(string $range): array { // Ensure $pRange is a valid range if (empty($range)) { @@ -345,7 +346,7 @@ public static function stringFromColumnIndex(int|string $columnIndex): string * * @return array Array containing single cell references */ - public static function extractAllCellReferencesInRange($cellRange): array + public static function extractAllCellReferencesInRange(string $cellRange): array { if (substr_count($cellRange, '!') > 1) { throw new Exception('3-D Range References are not supported'); @@ -424,7 +425,7 @@ private static function sortCellReferenceArray(array $cellList): array * * @return array All individual cells in that range */ - private static function getReferencesForCellBlock($cellBlock): array + private static function getReferencesForCellBlock(string $cellBlock): array { $returnValue = []; @@ -561,11 +562,9 @@ public static function mergeRangesInCollection(array $coordinateCollection): arr * Get the individual cell blocks from a range string, removing any $ characters. * then splitting by operators and returning an array with ranges and operators. * - * @param string $rangeString - * * @return array[] */ - private static function getCellBlocksFromRangeString($rangeString): array + private static function getCellBlocksFromRangeString(string $rangeString): array { $rangeString = str_replace('$', '', strtoupper($rangeString)); @@ -583,12 +582,8 @@ private static function getCellBlocksFromRangeString($rangeString): array * row. * * @param string $cellBlock The original range, for displaying a meaningful error message - * @param int $startColumnIndex - * @param int $endColumnIndex - * @param int $currentRow - * @param int $endRow */ - private static function validateRange(string $cellBlock, $startColumnIndex, $endColumnIndex, $currentRow, $endRow): void + private static function validateRange(string $cellBlock, int $startColumnIndex, int $endColumnIndex, int $currentRow, int $endRow): void { if ($startColumnIndex >= $endColumnIndex || $currentRow > $endRow) { throw new Exception('Invalid range: "' . $cellBlock . '"'); diff --git a/src/PhpSpreadsheet/Cell/DataValidation.php b/src/PhpSpreadsheet/Cell/DataValidation.php index 0ba116349c..184564b8df 100644 --- a/src/PhpSpreadsheet/Cell/DataValidation.php +++ b/src/PhpSpreadsheet/Cell/DataValidation.php @@ -152,11 +152,9 @@ public function getType(): string /** * Set Type. * - * @param string $type - * * @return $this */ - public function setType($type): static + public function setType(string $type): static { $this->type = $type; @@ -178,7 +176,7 @@ public function getErrorStyle(): string * * @return $this */ - public function setErrorStyle($errorStyle): static + public function setErrorStyle(string $errorStyle): static { $this->errorStyle = $errorStyle; @@ -196,11 +194,9 @@ public function getOperator(): string /** * Set Operator. * - * @param string $operator - * * @return $this */ - public function setOperator($operator): static + public function setOperator(string $operator): static { $this->operator = $operator; @@ -218,11 +214,9 @@ public function getAllowBlank(): bool /** * Set Allow Blank. * - * @param bool $allowBlank - * * @return $this */ - public function setAllowBlank($allowBlank): static + public function setAllowBlank(bool $allowBlank): static { $this->allowBlank = $allowBlank; @@ -240,11 +234,9 @@ public function getShowDropDown(): bool /** * Set Show DropDown. * - * @param bool $showDropDown - * * @return $this */ - public function setShowDropDown($showDropDown): static + public function setShowDropDown(bool $showDropDown): static { $this->showDropDown = $showDropDown; @@ -262,11 +254,9 @@ public function getShowInputMessage(): bool /** * Set Show InputMessage. * - * @param bool $showInputMessage - * * @return $this */ - public function setShowInputMessage($showInputMessage): static + public function setShowInputMessage(bool $showInputMessage): static { $this->showInputMessage = $showInputMessage; @@ -284,11 +274,9 @@ public function getShowErrorMessage(): bool /** * Set Show ErrorMessage. * - * @param bool $showErrorMessage - * * @return $this */ - public function setShowErrorMessage($showErrorMessage): static + public function setShowErrorMessage(bool $showErrorMessage): static { $this->showErrorMessage = $showErrorMessage; @@ -306,11 +294,9 @@ public function getErrorTitle(): string /** * Set Error title. * - * @param string $errorTitle - * * @return $this */ - public function setErrorTitle($errorTitle): static + public function setErrorTitle(string $errorTitle): static { $this->errorTitle = $errorTitle; @@ -328,11 +314,9 @@ public function getError(): string /** * Set Error. * - * @param string $error - * * @return $this */ - public function setError($error): static + public function setError(string $error): static { $this->error = $error; @@ -350,11 +334,9 @@ public function getPromptTitle(): string /** * Set Prompt title. * - * @param string $promptTitle - * * @return $this */ - public function setPromptTitle($promptTitle): static + public function setPromptTitle(string $promptTitle): static { $this->promptTitle = $promptTitle; @@ -372,11 +354,9 @@ public function getPrompt(): string /** * Set Prompt. * - * @param string $prompt - * * @return $this */ - public function setPrompt($prompt): static + public function setPrompt(string $prompt): static { $this->prompt = $prompt; diff --git a/src/PhpSpreadsheet/Cell/Hyperlink.php b/src/PhpSpreadsheet/Cell/Hyperlink.php index 667f4153b8..3117a7d86d 100644 --- a/src/PhpSpreadsheet/Cell/Hyperlink.php +++ b/src/PhpSpreadsheet/Cell/Hyperlink.php @@ -20,7 +20,7 @@ class Hyperlink * @param string $url Url to link the cell to * @param string $tooltip Tooltip to display on the hyperlink */ - public function __construct($url = '', $tooltip = '') + public function __construct(string $url = '', string $tooltip = '') { // Initialise member variables $this->url = $url; @@ -38,11 +38,9 @@ public function getUrl(): string /** * Set URL. * - * @param string $url - * * @return $this */ - public function setUrl($url): static + public function setUrl(string $url): static { $this->url = $url; @@ -60,11 +58,9 @@ public function getTooltip(): string /** * Set tooltip. * - * @param string $tooltip - * * @return $this */ - public function setTooltip($tooltip): static + public function setTooltip(string $tooltip): static { $this->tooltip = $tooltip; diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index 2b31baf1e7..af1642e9fe 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -185,10 +185,8 @@ public function getAxisOptionsProperty(string $property): ?string /** * Set Axis Orientation Property. - * - * @param string $orientation */ - public function setAxisOrientation($orientation): void + public function setAxisOrientation(string $orientation): void { $this->axisOptions['orientation'] = (string) $orientation; } @@ -214,17 +212,15 @@ public function setAxisType(string $type): self * * @param ?int $alpha */ - public function setFillParameters(?string $color, $alpha = null, ?string $AlphaType = ChartColor::EXCEL_COLOR_TYPE_RGB): void + public function setFillParameters(?string $color, ?int $alpha = null, ?string $AlphaType = ChartColor::EXCEL_COLOR_TYPE_RGB): void { $this->fillColor->setColorProperties($color, $alpha, $AlphaType); } /** * Get Fill Property. - * - * @param string $property */ - public function getFillProperty($property): string + public function getFillProperty(string $property): string { return (string) $this->fillColor->getColorProperty($property); } @@ -240,10 +236,8 @@ public function getFillColorObject(): ChartColor * @deprecated 1.24.0 * Use the getLineColor property in the Properties class instead * @see Properties::getLineColorProperty() - * - * @param string $propertyName */ - public function getLineProperty($propertyName): null|int|string + public function getLineProperty(string $propertyName): null|int|string { return $this->getLineColorProperty($propertyName); } diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index a9ac2410dd..60e0272d4b 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -125,10 +125,8 @@ class Chart /** * Create a new Chart. * majorGridlines and minorGridlines are deprecated, moved to Axis. - * - * @param string $displayBlanksAs */ - public function __construct(mixed $name, ?Title $title = null, ?Legend $legend = null, ?PlotArea $plotArea = null, mixed $plotVisibleOnly = true, $displayBlanksAs = DataSeries::EMPTY_AS_GAP, ?Title $xAxisLabel = null, ?Title $yAxisLabel = null, ?Axis $xAxis = null, ?Axis $yAxis = null, ?GridLines $majorGridlines = null, ?GridLines $minorGridlines = null) + public function __construct(mixed $name, ?Title $title = null, ?Legend $legend = null, ?PlotArea $plotArea = null, mixed $plotVisibleOnly = true, string $displayBlanksAs = DataSeries::EMPTY_AS_GAP, ?Title $xAxisLabel = null, ?Title $yAxisLabel = null, ?Axis $xAxis = null, ?Axis $yAxis = null, ?GridLines $majorGridlines = null, ?GridLines $minorGridlines = null) { $this->name = $name; $this->title = $title; @@ -284,11 +282,9 @@ public function getPlotVisibleOnly(): bool /** * Set Plot Visible Only. * - * @param bool $plotVisibleOnly - * * @return $this */ - public function setPlotVisibleOnly($plotVisibleOnly): static + public function setPlotVisibleOnly(bool $plotVisibleOnly): static { $this->plotVisibleOnly = $plotVisibleOnly; @@ -306,11 +302,9 @@ public function getDisplayBlanksAs(): string /** * Set Display Blanks as. * - * @param string $displayBlanksAs - * * @return $this */ - public function setDisplayBlanksAs($displayBlanksAs): static + public function setDisplayBlanksAs(string $displayBlanksAs): static { $this->displayBlanksAs = $displayBlanksAs; @@ -376,13 +370,9 @@ public function getMinorGridlines(): ?GridLines /** * Set the Top Left position for the chart. * - * @param string $cellAddress - * @param int $xOffset - * @param int $yOffset - * * @return $this */ - public function setTopLeftPosition($cellAddress, $xOffset = null, $yOffset = null): static + public function setTopLeftPosition(string $cellAddress, ?int $xOffset = null, ?int $yOffset = null): static { $this->topLeftCellRef = $cellAddress; if ($xOffset !== null) { @@ -422,11 +412,9 @@ public function getTopLeftCell(): string /** * Set the Top Left cell position for the chart. * - * @param string $cellAddress - * * @return $this */ - public function setTopLeftCell($cellAddress): static + public function setTopLeftCell(string $cellAddress): static { $this->topLeftCellRef = $cellAddress; @@ -441,7 +429,7 @@ public function setTopLeftCell($cellAddress): static * * @return $this */ - public function setTopLeftOffset($xOffset, $yOffset): static + public function setTopLeftOffset(?int $xOffset, ?int $yOffset): static { if ($xOffset !== null) { $this->setTopLeftXOffset($xOffset); @@ -468,11 +456,9 @@ public function getTopLeftOffset(): array } /** - * @param int $xOffset - * * @return $this */ - public function setTopLeftXOffset($xOffset): static + public function setTopLeftXOffset(int $xOffset): static { $this->topLeftXOffset = $xOffset; @@ -485,11 +471,9 @@ public function getTopLeftXOffset(): int } /** - * @param int $yOffset - * * @return $this */ - public function setTopLeftYOffset($yOffset): static + public function setTopLeftYOffset(int $yOffset): static { $this->topLeftYOffset = $yOffset; @@ -504,13 +488,9 @@ public function getTopLeftYOffset(): int /** * Set the Bottom Right position of the chart. * - * @param string $cellAddress - * @param int $xOffset - * @param int $yOffset - * * @return $this */ - public function setBottomRightPosition($cellAddress = '', $xOffset = null, $yOffset = null): static + public function setBottomRightPosition(string $cellAddress = '', ?int $xOffset = null, ?int $yOffset = null): static { $this->bottomRightCellRef = $cellAddress; if ($xOffset !== null) { @@ -565,7 +545,7 @@ public function getBottomRightCell(): string * * @return $this */ - public function setBottomRightOffset($xOffset, $yOffset): static + public function setBottomRightOffset(?int $xOffset, ?int $yOffset): static { if ($xOffset !== null) { $this->setBottomRightXOffset($xOffset); @@ -592,11 +572,9 @@ public function getBottomRightOffset(): array } /** - * @param int $xOffset - * * @return $this */ - public function setBottomRightXOffset($xOffset): static + public function setBottomRightXOffset(int $xOffset): static { $this->bottomRightXOffset = $xOffset; @@ -609,11 +587,9 @@ public function getBottomRightXOffset(): int } /** - * @param int $yOffset - * * @return $this */ - public function setBottomRightYOffset($yOffset): static + public function setBottomRightYOffset(int $yOffset): static { $this->bottomRightYOffset = $yOffset; @@ -639,7 +615,7 @@ public function refresh(): void * * @return bool true on success */ - public function render($outputDestination = null): bool + public function render(?string $outputDestination = null): bool { if ($outputDestination == 'php://output') { $outputDestination = null; diff --git a/src/PhpSpreadsheet/Chart/ChartColor.php b/src/PhpSpreadsheet/Chart/ChartColor.php index c85793071c..e36e042e46 100644 --- a/src/PhpSpreadsheet/Chart/ChartColor.php +++ b/src/PhpSpreadsheet/Chart/ChartColor.php @@ -138,11 +138,9 @@ public function isUsable(): bool /** * Get Color Property. * - * @param string $propertyName - * * @return null|int|string */ - public function getColorProperty($propertyName) + public function getColorProperty(string $propertyName) { $retVal = null; if ($propertyName === 'value') { diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index adcab17bc8..a03180fdae 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -112,9 +112,6 @@ class DataSeries * @param DataSeriesValues[] $plotLabel * @param DataSeriesValues[] $plotCategory * @param DataSeriesValues[] $plotValues - * @param null|string $plotDirection - * @param bool $smoothLine - * @param null|string $plotStyle */ public function __construct( $plotType = null, @@ -123,9 +120,9 @@ public function __construct( array $plotLabel = [], array $plotCategory = [], array $plotValues = [], - $plotDirection = null, - $smoothLine = false, - $plotStyle = null + ?string $plotDirection = null, + bool $smoothLine = false, + ?string $plotStyle = null ) { $this->plotType = $plotType; $this->plotGrouping = $plotGrouping; @@ -202,11 +199,9 @@ public function getPlotDirection(): string /** * Set Plot Direction. * - * @param string $plotDirection - * * @return $this */ - public function setPlotDirection($plotDirection): static + public function setPlotDirection(string $plotDirection): static { $this->plotDirection = $plotDirection; @@ -286,11 +281,9 @@ public function getPlotStyle(): ?string /** * Set Plot Style. * - * @param null|string $plotStyle - * * @return $this */ - public function setPlotStyle($plotStyle): static + public function setPlotStyle(?string $plotStyle): static { $this->plotStyle = $plotStyle; @@ -363,11 +356,9 @@ public function getSmoothLine(): bool /** * Set Smooth Line. * - * @param bool $smoothLine - * * @return $this */ - public function setSmoothLine($smoothLine): static + public function setSmoothLine(bool $smoothLine): static { $this->smoothLine = $smoothLine; diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index e5130224f6..4b1c5a60dc 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -126,7 +126,7 @@ public function getDataType(): string * * @return $this */ - public function setDataType($dataType): static + public function setDataType(string $dataType): static { if (!in_array($dataType, self::DATA_TYPE_VALUES)) { throw new Exception('Invalid datatype for chart data series values'); @@ -153,7 +153,7 @@ public function getDataSource(): ?string * * @return $this */ - public function setDataSource($dataSource): static + public function setDataSource(?string $dataSource): static { $this->dataSource = $dataSource; @@ -425,11 +425,9 @@ public function getDataValue(): mixed /** * Set Series Data Values. * - * @param array $dataValues - * * @return $this */ - public function setDataValues($dataValues): static + public function setDataValues(array $dataValues): static { $this->dataValues = Functions::flattenArray($dataValues); $this->pointCount = count($dataValues); @@ -520,11 +518,9 @@ public function getSmoothLine(): bool /** * Set Smooth Line. * - * @param bool $smoothLine - * * @return $this */ - public function setSmoothLine($smoothLine): static + public function setSmoothLine(bool $smoothLine): static { $this->smoothLine = $smoothLine; diff --git a/src/PhpSpreadsheet/Chart/Layout.php b/src/PhpSpreadsheet/Chart/Layout.php index aeb8e08dba..b91e9f2dbe 100644 --- a/src/PhpSpreadsheet/Chart/Layout.php +++ b/src/PhpSpreadsheet/Chart/Layout.php @@ -208,7 +208,7 @@ public function getXMode(): ?string * * @return $this */ - public function setXMode($mode): static + public function setXMode(?string $mode): static { $this->xMode = (string) $mode; @@ -232,7 +232,7 @@ public function getYMode(): ?string * * @return $this */ - public function setYMode($mode): static + public function setYMode(?string $mode): static { $this->yMode = (string) $mode; diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index a6fd72b450..53407a590e 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -50,11 +50,8 @@ class Legend /** * Create a new Legend. - * - * @param string $position - * @param bool $overlay */ - public function __construct($position = self::POSITION_RIGHT, ?Layout $layout = null, $overlay = false) + public function __construct(string $position = self::POSITION_RIGHT, ?Layout $layout = null, bool $overlay = false) { $this->setPosition($position); $this->layout = $layout; @@ -81,7 +78,7 @@ public function getPosition(): string * * @param string $position see self::POSITION_* */ - public function setPosition($position): bool + public function setPosition(string $position): bool { if (!in_array($position, self::POSITION_XLREF)) { return false; @@ -105,7 +102,7 @@ public function getPositionXL(): false|int * * @param int $positionXL see self::XL_LEGEND_POSITION_* */ - public function setPositionXL($positionXL): bool + public function setPositionXL(int $positionXL): bool { if (!isset(self::POSITION_XLREF[$positionXL])) { return false; @@ -126,10 +123,8 @@ public function getOverlay(): bool /** * Set allow overlay of other elements? - * - * @param bool $overlay */ - public function setOverlay($overlay): void + public function setOverlay(bool $overlay): void { $this->overlay = $overlay; } diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index 2e34b2721b..21ffa48101 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -432,12 +432,11 @@ protected function getArrayElementsValue(mixed $properties, mixed $elements): mi /** * Set Glow Properties. * - * @param float $size * @param ?string $colorValue * @param ?int $colorAlpha * @param ?string $colorType */ - public function setGlowProperties($size, $colorValue = null, $colorAlpha = null, $colorType = null): void + public function setGlowProperties(float $size, ?string $colorValue = null, ?int $colorAlpha = null, ?string $colorType = null): void { $this ->activateObject() @@ -479,11 +478,9 @@ public function getGlowProperty($property) /** * Get Glow Color Property. * - * @param string $propertyName - * * @return null|int|string */ - public function getGlowColor($propertyName) + public function getGlowColor(string $propertyName) { return $this->glowColor->getColorProperty($propertyName); } @@ -510,7 +507,7 @@ public function getGlowSize(): ?float * * @return $this */ - protected function setGlowSize($size) + protected function setGlowSize(?float $size) { $this->glowSize = $size; @@ -522,7 +519,7 @@ protected function setGlowSize($size) * * @param ?float $size */ - public function setSoftEdges($size): void + public function setSoftEdges(?float $size): void { if ($size !== null) { $this->activateObject(); @@ -553,15 +550,9 @@ public function setShadowProperty(string $propertyName, mixed $value): self /** * Set Shadow Properties. * - * @param int $presets - * @param string $colorValue - * @param string $colorType * @param null|float|int|string $colorAlpha - * @param null|float $blur - * @param null|int $angle - * @param null|float $distance */ - public function setShadowProperties($presets, $colorValue = null, $colorType = null, $colorAlpha = null, $blur = null, $angle = null, $distance = null): void + public function setShadowProperties(int $presets, ?string $colorValue = null, ?string $colorType = null, $colorAlpha = null, ?float $blur = null, ?int $angle = null, ?float $distance = null): void { $this->activateObject()->setShadowPresetsProperties((int) $presets); if ($presets === 0) { @@ -632,7 +623,7 @@ protected function setShadowPropertiesMapValues(array $propertiesMap, ?array &$r * * @return $this */ - protected function setShadowBlur($blur) + protected function setShadowBlur(?float $blur) { if ($blur !== null) { $this->shadowProperties['blur'] = $blur; @@ -664,7 +655,7 @@ protected function setShadowAngle($angle) * * @return $this */ - protected function setShadowDistance($distance) + protected function setShadowDistance(?float $distance) { if ($distance !== null) { $this->shadowProperties['distance'] = $distance; @@ -752,7 +743,7 @@ public function getLineColor(): ChartColor * * @param ?int $alpha */ - public function setLineColorProperties(?string $value, $alpha = null, ?string $colorType = null): void + public function setLineColorProperties(?string $value, ?int $alpha = null, ?string $colorType = null): void { $this->activateObject(); $this->lineColor->setColorPropertiesArray( @@ -767,44 +758,30 @@ public function setLineColorProperties(?string $value, $alpha = null, ?string $c /** * Get Line Color Property. * - * @param string $propertyName - * * @return null|int|string */ - public function getLineColorProperty($propertyName) + public function getLineColorProperty(string $propertyName) { return $this->lineColor->getColorProperty($propertyName); } /** * Set Line Style Properties. - * - * @param null|float|int|string $lineWidth - * @param string $compoundType - * @param string $dashType - * @param string $capType - * @param string $joinType - * @param string $headArrowType - * @param string $endArrowType - * @param string $headArrowWidth - * @param string $headArrowLength - * @param string $endArrowWidth - * @param string $endArrowLength */ public function setLineStyleProperties( - $lineWidth = null, - $compoundType = '', - $dashType = '', - $capType = '', - $joinType = '', - $headArrowType = '', + null|float|int|string $lineWidth = null, + ?string $compoundType = '', + ?string $dashType = '', + ?string $capType = '', + ?string $joinType = '', + ?string $headArrowType = '', int $headArrowSize = 0, - $endArrowType = '', + ?string $endArrowType = '', int $endArrowSize = 0, - $headArrowWidth = '', - $headArrowLength = '', - $endArrowWidth = '', - $endArrowLength = '' + ?string $headArrowWidth = '', + ?string $headArrowLength = '', + ?string $endArrowWidth = '', + ?string $endArrowLength = '' ): void { $this->activateObject(); if (is_numeric($lineWidth)) { @@ -909,42 +886,32 @@ public function getLineStyleProperty($elements): ?string /** * Get Line Style Arrow Size. - * - * @param int $arraySelector - * @param string $arrayKaySelector */ - protected function getLineStyleArrowSize($arraySelector, $arrayKaySelector): string + protected function getLineStyleArrowSize(int $arraySelector, string $arrayKaySelector): string { return self::ARROW_SIZES[$arraySelector][$arrayKaySelector] ?? ''; } /** * Get Line Style Arrow Parameters. - * - * @param string $arrowSelector - * @param string $propertySelector */ - public function getLineStyleArrowParameters($arrowSelector, $propertySelector): string + public function getLineStyleArrowParameters(string $arrowSelector, string $propertySelector): string { return $this->getLineStyleArrowSize($this->lineStyleProperties['arrow'][$arrowSelector]['size'], $propertySelector); } /** * Get Line Style Arrow Width. - * - * @param string $arrow */ - public function getLineStyleArrowWidth($arrow): ?string + public function getLineStyleArrowWidth(string $arrow): ?string { return $this->getLineStyleProperty(['arrow', $arrow, 'w']); } /** * Get Line Style Arrow Excel Length. - * - * @param string $arrow */ - public function getLineStyleArrowLength($arrow): ?string + public function getLineStyleArrowLength(string $arrow): ?string { return $this->getLineStyleProperty(['arrow', $arrow, 'len']); } diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index 89df6bb716..dd2742164b 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -27,9 +27,8 @@ class Title * Create a new Title. * * @param array|RichText|string $caption - * @param bool $overlay */ - public function __construct($caption = '', ?Layout $layout = null, $overlay = false) + public function __construct($caption = '', ?Layout $layout = null, bool $overlay = false) { $this->caption = $caption; $this->layout = $layout; @@ -93,10 +92,8 @@ public function getOverlay(): bool /** * Set allow overlay of other elements? - * - * @param bool $overlay */ - public function setOverlay($overlay): void + public function setOverlay(bool $overlay): void { $this->overlay = $overlay; } diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index b9b8e77338..a51b7d1415 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -77,7 +77,7 @@ public function getParent(): ?Worksheet * * @param string $cellCoordinate Coordinate of the cell to check */ - public function has($cellCoordinate): bool + public function has(string $cellCoordinate): bool { return ($cellCoordinate === $this->currentCoordinate) || isset($this->index[$cellCoordinate]); } @@ -229,7 +229,7 @@ public function getHighestColumn($row = null): string * * @return int Highest row number */ - public function getHighestRow($column = null): int + public function getHighestRow(?string $column = null): int { if ($column === null) { return $this->getHighestRowAndColumn()['row']; @@ -316,7 +316,7 @@ public function removeRow($row): void * * @param string $column Column ID to remove */ - public function removeColumn($column): void + public function removeColumn(string $column): void { $this->storeCurrentCell(); @@ -363,7 +363,7 @@ private function destructIfNeeded(self $cells, string $message): void * @param string $cellCoordinate Coordinate of the cell to update * @param Cell $cell Cell to update */ - public function add($cellCoordinate, Cell $cell): Cell + public function add(string $cellCoordinate, Cell $cell): Cell { if ($cellCoordinate !== $this->currentCoordinate) { $this->storeCurrentCell(); diff --git a/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php b/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php index 70129c947b..a49361ded8 100644 --- a/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php +++ b/src/PhpSpreadsheet/Collection/Memory/SimpleCache1.php @@ -25,20 +25,14 @@ public function clear(): bool return true; } - /** - * @param string $key - */ - public function delete($key): bool + public function delete(string $key): bool { unset($this->cache[$key]); return true; } - /** - * @param iterable $keys - */ - public function deleteMultiple($keys): bool + public function deleteMultiple(iterable $keys): bool { foreach ($keys as $key) { $this->delete($key); @@ -48,10 +42,9 @@ public function deleteMultiple($keys): bool } /** - * @param string $key * @param mixed $default */ - public function get($key, $default = null): mixed + public function get(string $key, $default = null): mixed { if ($this->has($key)) { return $this->cache[$key]; @@ -61,10 +54,9 @@ public function get($key, $default = null): mixed } /** - * @param iterable $keys * @param mixed $default */ - public function getMultiple($keys, $default = null): iterable + public function getMultiple(iterable $keys, $default = null): iterable { $results = []; foreach ($keys as $key) { @@ -74,20 +66,16 @@ public function getMultiple($keys, $default = null): iterable return $results; } - /** - * @param string $key - */ - public function has($key): bool + public function has(string $key): bool { return array_key_exists($key, $this->cache); } /** - * @param string $key * @param mixed $value * @param null|DateInterval|int $ttl */ - public function set($key, $value, $ttl = null): bool + public function set(string $key, $value, $ttl = null): bool { $this->cache[$key] = $value; @@ -95,10 +83,9 @@ public function set($key, $value, $ttl = null): bool } /** - * @param iterable $values * @param null|DateInterval|int $ttl */ - public function setMultiple($values, $ttl = null): bool + public function setMultiple(iterable $values, $ttl = null): bool { foreach ($values as $key => $value) { $this->set($key, $value); diff --git a/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php b/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php index dab9f4eedd..b89ee16b35 100644 --- a/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php +++ b/src/PhpSpreadsheet/Collection/Memory/SimpleCache3.php @@ -25,20 +25,14 @@ public function clear(): bool return true; } - /** - * @param string $key - */ - public function delete($key): bool + public function delete(string $key): bool { unset($this->cache[$key]); return true; } - /** - * @param iterable $keys - */ - public function deleteMultiple($keys): bool + public function deleteMultiple(iterable $keys): bool { foreach ($keys as $key) { $this->delete($key); @@ -48,10 +42,9 @@ public function deleteMultiple($keys): bool } /** - * @param string $key * @param mixed $default */ - public function get($key, $default = null): mixed + public function get(string $key, $default = null): mixed { if ($this->has($key)) { return $this->cache[$key]; @@ -61,10 +54,9 @@ public function get($key, $default = null): mixed } /** - * @param iterable $keys * @param mixed $default */ - public function getMultiple($keys, $default = null): iterable + public function getMultiple(iterable $keys, $default = null): iterable { $results = []; foreach ($keys as $key) { @@ -74,20 +66,16 @@ public function getMultiple($keys, $default = null): iterable return $results; } - /** - * @param string $key - */ - public function has($key): bool + public function has(string $key): bool { return array_key_exists($key, $this->cache); } /** - * @param string $key * @param mixed $value * @param null|DateInterval|int $ttl */ - public function set($key, $value, $ttl = null): bool + public function set(string $key, $value, $ttl = null): bool { $this->cache[$key] = $value; @@ -95,10 +83,9 @@ public function set($key, $value, $ttl = null): bool } /** - * @param iterable $values * @param null|DateInterval|int $ttl */ - public function setMultiple($values, $ttl = null): bool + public function setMultiple(iterable $values, $ttl = null): bool { foreach ($values as $key => $value) { $this->set($key, $value); diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index 6e5a99da29..246ebd3324 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -416,7 +416,7 @@ private function identifyPropertyType(mixed $propertyValue): string * * @return $this */ - public function setCustomProperty(string $propertyName, mixed $propertyValue = '', $propertyType = null): self + public function setCustomProperty(string $propertyName, mixed $propertyValue = '', ?string $propertyType = null): self { if (($propertyType === null) || (!in_array($propertyType, self::VALID_PROPERTY_TYPE_LIST))) { $propertyType = $this->identifyPropertyType($propertyValue); diff --git a/src/PhpSpreadsheet/HashTable.php b/src/PhpSpreadsheet/HashTable.php index 87c49ee7e6..c306cdb396 100644 --- a/src/PhpSpreadsheet/HashTable.php +++ b/src/PhpSpreadsheet/HashTable.php @@ -26,7 +26,7 @@ class HashTable * * @param T[] $source Optional source array to create HashTable from */ - public function __construct($source = null) + public function __construct(?array $source = null) { if ($source !== null) { // Create HashTable diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index 3d53f1e053..5c9382bdab 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -111,10 +111,9 @@ public function getSamples(): array /** * Write documents. * - * @param string $filename * @param string[] $writers */ - public function write(Spreadsheet $spreadsheet, $filename, array $writers = ['Xlsx', 'Xls'], bool $withCharts = false, ?callable $writerCallback = null): void + public function write(Spreadsheet $spreadsheet, string $filename, array $writers = ['Xlsx', 'Xls'], bool $withCharts = false, ?callable $writerCallback = null): void { // Set active sheet index to the first sheet, so Excel opens this as the first sheet $spreadsheet->setActiveSheetIndex(0); @@ -160,10 +159,8 @@ public function getTemporaryFolder(): string /** * Returns the filename that should be used for sample output. - * - * @param string $filename */ - public function getFilename($filename, string $extension = 'xlsx'): string + public function getFilename(string $filename, string $extension = 'xlsx'): string { $originalExtension = pathinfo($filename, PATHINFO_EXTENSION); @@ -257,11 +254,8 @@ public function logEndingNotes(): void /** * Log a line about the write operation. - * - * @param string $path - * @param float $callStartTime */ - public function logWrite(IWriter $writer, $path, $callStartTime): void + public function logWrite(IWriter $writer, string $path, float $callStartTime): void { $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; @@ -276,12 +270,8 @@ public function logWrite(IWriter $writer, $path, $callStartTime): void /** * Log a line about the read operation. - * - * @param string $format - * @param string $path - * @param float $callStartTime */ - public function logRead($format, $path, $callStartTime): void + public function logRead(string $format, string $path, float $callStartTime): void { $callEndTime = microtime(true); $callTime = $callEndTime - $callStartTime; diff --git a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php index bfabb07fa0..0c4b87b61a 100644 --- a/src/PhpSpreadsheet/Reader/DefaultReadFilter.php +++ b/src/PhpSpreadsheet/Reader/DefaultReadFilter.php @@ -11,7 +11,7 @@ class DefaultReadFilter implements IReadFilter * @param int $row Row number * @param string $worksheetName Optional worksheet name */ - public function readCell($columnAddress, $row, $worksheetName = ''): bool + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return true; } diff --git a/src/PhpSpreadsheet/Reader/Gnumeric.php b/src/PhpSpreadsheet/Reader/Gnumeric.php index ebf4aae037..59723e4dd5 100644 --- a/src/PhpSpreadsheet/Reader/Gnumeric.php +++ b/src/PhpSpreadsheet/Reader/Gnumeric.php @@ -170,10 +170,7 @@ public function listWorksheetInfo(string $filename): array return $worksheetInfo; } - /** - * @param string $filename - */ - private function gzfileGetContents($filename): string + private function gzfileGetContents(string $filename): string { $data = ''; $contents = @file_get_contents($filename); diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 149cf04530..47e46dfe35 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -216,7 +216,7 @@ public function loadSpreadsheetFromFile(string $filename): Spreadsheet * * @deprecated no use is made of this property */ - public function setInputEncoding($inputEncoding): static + public function setInputEncoding(string $inputEncoding): static { $this->inputEncoding = $inputEncoding; @@ -763,10 +763,8 @@ private static function replaceNonAscii(array $matches): string /** * Spreadsheet from content. - * - * @param string $content */ - public function loadFromString($content, ?Spreadsheet $spreadsheet = null): Spreadsheet + public function loadFromString(string $content, ?Spreadsheet $spreadsheet = null): Spreadsheet { // Create a new DOM object $dom = new DOMDocument(); @@ -831,7 +829,7 @@ public function getSheetIndex(): int * * @return $this */ - public function setSheetIndex($sheetIndex): static + public function setSheetIndex(int $sheetIndex): static { $this->sheetIndex = $sheetIndex; @@ -847,10 +845,8 @@ public function setSheetIndex($sheetIndex): static * * TODO : * - Implement to other propertie, such as border - * - * @param int $row */ - private function applyInlineStyle(Worksheet &$sheet, $row, string $column, array $attributeArray): void + private function applyInlineStyle(Worksheet &$sheet, int $row, string $column, array $attributeArray): void { if (!isset($attributeArray['style'])) { return; @@ -1101,10 +1097,8 @@ public static function getBorderMappings(): array /** * Map html border style to PhpSpreadsheet border style. - * - * @param string $style */ - public function getBorderStyle($style): ?string + public function getBorderStyle(string $style): ?string { return self::BORDER_MAPPINGS[$style] ?? null; } diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 480c29eb13..51e3eec3a5 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -98,7 +98,7 @@ private function canReadOrBust(string $filename): void * * @codeCoverageIgnore */ - public function setInputEncoding($inputEncoding): static + public function setInputEncoding(string $inputEncoding): static { $this->inputEncoding = $inputEncoding; @@ -590,7 +590,7 @@ public function getSheetIndex(): int * * @return $this */ - public function setSheetIndex($sheetIndex): static + public function setSheetIndex(int $sheetIndex): static { $this->sheetIndex = $sheetIndex; diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 15a074a30a..ece024f687 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -1201,7 +1201,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet * * @return string Record data */ - private function readRecordData($data, int $pos, int $len): string + private function readRecordData(string $data, int $pos, int $len): string { $data = substr($data, $pos, $len); @@ -1746,7 +1746,7 @@ private function readFilepass(): void * @param int $block Block for which to create decrypto * @param string $valContext MD5 context state */ - private function makeKey(int $block, $valContext): Xls\RC4 + private function makeKey(int $block, string $valContext): Xls\RC4 { $pwarray = str_repeat("\0", 64); @@ -1781,7 +1781,7 @@ private function makeKey(int $block, $valContext): Xls\RC4 * * @return bool Success */ - private function verifyPassword(string $password, string $docid, string $salt_data, string $hashedsalt_data, &$valContext): bool + private function verifyPassword(string $password, string $docid, string $salt_data, string $hashedsalt_data, string &$valContext): bool { $pwarray = str_repeat("\0", 64); @@ -5071,7 +5071,7 @@ private function getSplicedRecordData(): array * * @return string Human readable formula */ - private function getFormulaFromStructure($formulaStructure, $baseCell = 'A1'): string + private function getFormulaFromStructure(string $formulaStructure, string $baseCell = 'A1'): string { // offset: 0; size: 2; size of the following formula data $sz = self::getUInt2d($formulaStructure, 0); @@ -6615,7 +6615,7 @@ private function readBIFF8CellAddress(string $cellAddressStructure): string * * @param string $baseCell Base cell, only needed when formula contains tRefN tokens, e.g. with shared formulas */ - private function readBIFF8CellAddressB(string $cellAddressStructure, $baseCell = 'A1'): string + private function readBIFF8CellAddressB(string $cellAddressStructure, string $baseCell = 'A1'): string { [$baseCol, $baseRow] = Coordinate::coordinateFromString($baseCell); $baseCol = Coordinate::columnIndexFromString($baseCol) - 1; @@ -6961,10 +6961,8 @@ private function readSheetRangeByRefIndex(int $index): string|false * read BIFF8 constant value array from array data * returns e.g. ['value' => '{1,2;3,4}', 'size' => 40] * section 2.5.8. - * - * @param string $arrayData */ - private static function readBIFF8ConstantArray($arrayData): array + private static function readBIFF8ConstantArray(string $arrayData): array { // offset: 0; size: 1; number of columns decreased by 1 $nc = ord($arrayData[0]); @@ -6998,10 +6996,8 @@ private static function readBIFF8ConstantArray($arrayData): array * read BIFF8 constant value which may be 'Empty Value', 'Number', 'String Value', 'Boolean Value', 'Error Value' * section 2.5.7 * returns e.g. ['value' => '5', 'size' => 9]. - * - * @param string $valueData */ - private static function readBIFF8Constant($valueData): array + private static function readBIFF8Constant(string $valueData): array { // offset: 0; size: 1; identifier for type of constant $identifier = ord($valueData[0]); @@ -7057,7 +7053,7 @@ private static function readBIFF8Constant($valueData): array * * @param string $rgb Encoded RGB value (4 bytes) */ - private static function readRGB($rgb): array + private static function readRGB(string $rgb): array { // offset: 0; size 1; Red component $r = ord($rgb[0]); @@ -7115,10 +7111,8 @@ private function readByteStringLong(string $subData): array * Extracts an Excel Unicode short string (8-bit string length) * OpenOffice documentation: 2.5.3 * function will automatically find out where the Unicode string ends. - * - * @param string $subData */ - private static function readUnicodeStringShort($subData): array + private static function readUnicodeStringShort(string $subData): array { $value = ''; @@ -7137,10 +7131,8 @@ private static function readUnicodeStringShort($subData): array * Extracts an Excel Unicode long string (16-bit string length) * OpenOffice documentation: 2.5.3 * this function is under construction, needs to support rich text, and Asian phonetic settings. - * - * @param string $subData */ - private static function readUnicodeStringLong($subData): array + private static function readUnicodeStringLong(string $subData): array { $value = ''; @@ -7159,11 +7151,8 @@ private static function readUnicodeStringLong($subData): array * Read Unicode string with no string length field, but with known character count * this function is under construction, needs to support rich text, and Asian phonetic settings * OpenOffice.org's Documentation of the Microsoft Excel File Format, section 2.5.3. - * - * @param string $subData - * @param int $characterCount */ - private static function readUnicodeString($subData, $characterCount): array + private static function readUnicodeString(string $subData, int $characterCount): array { $value = ''; @@ -7194,7 +7183,7 @@ private static function readUnicodeString($subData, $characterCount): array * * @param string $value UTF-8 encoded string */ - private static function UTF8toExcelDoubleQuoted($value): string + private static function UTF8toExcelDoubleQuoted(string $value): string { return '"' . str_replace('"', '""', $value) . '"'; } @@ -7206,7 +7195,7 @@ private static function UTF8toExcelDoubleQuoted($value): string * * @return float */ - private static function extractNumber($data): int|float + private static function extractNumber(string $data): int|float { $rknumhigh = self::getInt4d($data, 4); $rknumlow = self::getInt4d($data, 0); @@ -7230,11 +7219,9 @@ private static function extractNumber($data): int|float } /** - * @param int $rknum - * * @return float */ - private static function getIEEE754($rknum): float|int + private static function getIEEE754(int $rknum): float|int { if (($rknum & 0x02) != 0) { $value = $rknum >> 2; @@ -7262,11 +7249,8 @@ private static function getIEEE754($rknum): float|int /** * Get UTF-8 string from (compressed or uncompressed) UTF-16 string. - * - * @param string $string - * @param bool $compressed */ - private static function encodeUTF16($string, $compressed = false): string + private static function encodeUTF16(string $string, bool $compressed = false): string { if ($compressed) { $string = self::uncompressByteString($string); @@ -7277,10 +7261,8 @@ private static function encodeUTF16($string, $compressed = false): string /** * Convert UTF-16 string in compressed notation to uncompressed form. Only used for BIFF8. - * - * @param string $string */ - private static function uncompressByteString($string): string + private static function uncompressByteString(string $string): string { $uncompressedString = ''; $strLen = strlen($string); @@ -7301,33 +7283,24 @@ private function decodeCodepage(string $string): string /** * Read 16-bit unsigned integer. - * - * @param string $data - * @param int $pos */ - public static function getUInt2d($data, $pos): int + public static function getUInt2d(string $data, int $pos): int { return ord($data[$pos]) | (ord($data[$pos + 1]) << 8); } /** * Read 16-bit signed integer. - * - * @param string $data - * @param int $pos */ - public static function getInt2d($data, $pos): int + public static function getInt2d(string $data, int $pos): int { return unpack('s', $data[$pos] . $data[$pos + 1])[1]; // @phpstan-ignore-line } /** * Read 32-bit signed integer. - * - * @param string $data - * @param int $pos */ - public static function getInt4d($data, $pos): int + public static function getInt4d(string $data, int $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 diff --git a/src/PhpSpreadsheet/Reader/Xls/Color.php b/src/PhpSpreadsheet/Reader/Xls/Color.php index 56e9e660dc..6fd346bfa9 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color.php @@ -11,11 +11,10 @@ class Color * * @param int $color Indexed color * @param array $palette Color palette - * @param int $version * * @return array RGB color value, example: ['rgb' => 'FF0000'] */ - public static function map($color, array $palette, $version): array + public static function map(int $color, array $palette, int $version): array { 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 5569bbd482..2c0790c9ce 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color/BIFF5.php @@ -65,10 +65,8 @@ class BIFF5 /** * Map color array from BIFF5 built-in color index. - * - * @param int $color */ - public static function lookup($color): array + public static function lookup(int $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 baa2c57fcf..914034df26 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color/BIFF8.php @@ -65,10 +65,8 @@ class BIFF8 /** * Map color array from BIFF8 built-in color index. - * - * @param int $color */ - public static function lookup($color): array + public static function lookup(int $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 c1d34f0152..a715b110b9 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php +++ b/src/PhpSpreadsheet/Reader/Xls/Color/BuiltIn.php @@ -22,7 +22,7 @@ class BuiltIn * * @param int $color Indexed color */ - public static function lookup($color): array + public static function lookup(int $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 b33163dfa7..fa8f8cd5d8 100644 --- a/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php +++ b/src/PhpSpreadsheet/Reader/Xls/ErrorCode.php @@ -16,10 +16,8 @@ class ErrorCode /** * Map error code, e.g. '#N/A'. - * - * @param int $code */ - public static function lookup($code): string|bool + public static function lookup(int $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 feefb4fa43..edb5cabf95 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Escher.php +++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php @@ -87,11 +87,9 @@ public function __construct(mixed $object) /** * Load Escher stream data. May be a partial Escher stream. * - * @param string $data - * * @return BSE|BstoreContainer|DgContainer|DggContainer|\PhpOffice\PhpSpreadsheet\Shared\Escher|SpContainer|SpgrContainer */ - public function load($data) + public function load(string $data) { $this->data = $data; diff --git a/src/PhpSpreadsheet/Reader/Xls/RC4.php b/src/PhpSpreadsheet/Reader/Xls/RC4.php index f00f905813..663f36723a 100644 --- a/src/PhpSpreadsheet/Reader/Xls/RC4.php +++ b/src/PhpSpreadsheet/Reader/Xls/RC4.php @@ -16,7 +16,7 @@ class RC4 * * @param string $key Encryption key/passphrase */ - public function __construct($key) + public function __construct(string $key) { $len = strlen($key); @@ -39,7 +39,7 @@ public function __construct($key) * * @param string $data Data to encrypt/decrypt */ - public function RC4($data): string + public function RC4(string $data): string { $len = strlen($data); for ($c = 0; $c < $len; ++$c) { diff --git a/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php b/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php index a9f0d7dfe8..4e379509e5 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php +++ b/src/PhpSpreadsheet/Reader/Xls/Style/FillPattern.php @@ -34,10 +34,8 @@ class FillPattern /** * Get fill pattern from index * OpenOffice documentation: 2.5.12. - * - * @param int $index */ - public static function lookup($index): string + public static function lookup(int $index): string { if (isset(self::$fillPatternMap[$index])) { return self::$fillPatternMap[$index]; diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index fda8abcc89..495e42a963 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -353,10 +353,7 @@ private function fileExistsInArchive(ZipArchive $archive, string $fileName = '') return $contents !== false; } - /** - * @param string $fileName - */ - private function getFromZipArchive(ZipArchive $archive, $fileName = ''): string + private function getFromZipArchive(ZipArchive $archive, string $fileName = ''): string { // Root-relative paths if (str_contains($fileName, '//')) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 4a2d660c66..71777f230f 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -74,10 +74,7 @@ private static function getAttributeFloat(SimpleXMLElement $component, string $n return null; } - /** - * @param string $chartName - */ - public function readChart(SimpleXMLElement $chartElements, $chartName): \PhpOffice\PhpSpreadsheet\Chart\Chart + public function readChart(SimpleXMLElement $chartElements, string $chartName): \PhpOffice\PhpSpreadsheet\Chart\Chart { $chartElementsC = $chartElements->children($this->cNamespace); @@ -1208,7 +1205,7 @@ private function parseFont(SimpleXMLElement $titleDetailPart): ?Font /** * @param ?SimpleXMLElement $chartDetail */ - private function readChartAttributes($chartDetail): array + private function readChartAttributes(?SimpleXMLElement $chartDetail): array { $plotAttributes = []; if (isset($chartDetail->dLbls)) { diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Theme.php b/src/PhpSpreadsheet/Reader/Xlsx/Theme.php index af4a559852..4a31c3e18b 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Theme.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Theme.php @@ -24,11 +24,9 @@ class Theme /** * Create a new Theme. * - * @param string $themeName - * @param string $colourSchemeName * @param string[] $colourMap */ - public function __construct($themeName, $colourSchemeName, $colourMap) + public function __construct(string $themeName, string $colourSchemeName, array $colourMap) { // Initialise values $this->themeName = $themeName; @@ -58,10 +56,8 @@ public function getColourSchemeName(): string /** * Get colour Map Value by Position. - * - * @param int $index */ - public function getColourByIndex($index): ?string + public function getColourByIndex(int $index): ?string { return $this->colourMap[$index] ?? null; } diff --git a/src/PhpSpreadsheet/ReferenceHelper.php b/src/PhpSpreadsheet/ReferenceHelper.php index c6a9f7dd3c..fc9429a9c9 100644 --- a/src/PhpSpreadsheet/ReferenceHelper.php +++ b/src/PhpSpreadsheet/ReferenceHelper.php @@ -323,7 +323,7 @@ protected function adjustColumnDimensions(Worksheet $worksheet): void * @param int $beforeRow Number of the row we're inserting/deleting before * @param int $numberOfRows Number of rows to insert/delete (negative values indicate deletion) */ - protected function adjustRowDimensions(Worksheet $worksheet, $beforeRow, $numberOfRows): void + protected function adjustRowDimensions(Worksheet $worksheet, int $beforeRow, int $numberOfRows): void { $aRowDimensions = array_reverse($worksheet->getRowDimensions(), true); if (!empty($aRowDimensions)) { @@ -547,11 +547,11 @@ public function insertNewBefore( * @return string Updated formula */ public function updateFormulaReferences( - $formula = '', - $beforeCellAddress = 'A1', - $numberOfColumns = 0, - $numberOfRows = 0, - $worksheetName = '', + string $formula = '', + string $beforeCellAddress = 'A1', + int $numberOfColumns = 0, + int $numberOfRows = 0, + string $worksheetName = '', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false ): string { @@ -837,7 +837,7 @@ private function updateRowRangesAllWorksheets(string $formula, int $numberOfRows * * @return string Updated cell range */ - private function updateCellReference($cellReference = 'A1', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false): string + private function updateCellReference(string $cellReference = 'A1', bool $includeAbsoluteReferences = false, bool $onlyAbsoluteReferences = false): string { // Is it in another worksheet? Will not have to update anything. if (str_contains($cellReference, '!')) { diff --git a/src/PhpSpreadsheet/RichText/RichText.php b/src/PhpSpreadsheet/RichText/RichText.php index 37c69f0ffb..32b3727be2 100644 --- a/src/PhpSpreadsheet/RichText/RichText.php +++ b/src/PhpSpreadsheet/RichText/RichText.php @@ -57,7 +57,7 @@ public function addText(ITextElement $text): static * * @param string $text Text */ - public function createText($text): TextElement + public function createText(string $text): TextElement { $objText = new TextElement($text); $this->addText($objText); @@ -70,7 +70,7 @@ public function createText($text): TextElement * * @param string $text Text */ - public function createTextRun($text): Run + public function createTextRun(string $text): Run { $objText = new Run($text); $this->addText($objText); diff --git a/src/PhpSpreadsheet/RichText/Run.php b/src/PhpSpreadsheet/RichText/Run.php index 3a18b4a4a4..6284468450 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -18,7 +18,7 @@ class Run extends TextElement implements ITextElement * * @param string $text Text */ - public function __construct($text = '') + public function __construct(string $text = '') { parent::__construct($text); // Initialise variables diff --git a/src/PhpSpreadsheet/RichText/TextElement.php b/src/PhpSpreadsheet/RichText/TextElement.php index c56fe51e66..e509d272d2 100644 --- a/src/PhpSpreadsheet/RichText/TextElement.php +++ b/src/PhpSpreadsheet/RichText/TextElement.php @@ -16,7 +16,7 @@ class TextElement implements ITextElement * * @param string $text Text */ - public function __construct($text = '') + public function __construct(string $text = '') { // Initialise variables $this->text = $text; diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index e8bcf61770..9f61d070b5 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -94,7 +94,7 @@ public static function htmlEntityFlags(): int * * @param ?int $options Default options for libxml loader */ - public static function setLibXmlLoaderOptions($options): int + public static function setLibXmlLoaderOptions(?int $options): int { if ($options === null) { $options = defined('LIBXML_DTDLOAD') ? (LIBXML_DTDLOAD | LIBXML_DTDATTR) : 0; @@ -122,13 +122,11 @@ public static function getLibXmlLoaderOptions(): int /** * Deprecated, has no effect. * - * @param bool $state - * * @deprecated will be removed without replacement as it is no longer necessary on PHP 7.3.0+ * * @codeCoverageIgnore */ - public static function setLibXmlDisableEntityLoader($state): void + public static function setLibXmlDisableEntityLoader(bool $state): void { // noop } diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 1b4af061af..98952b223d 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -68,7 +68,7 @@ class Date * * @return bool Success or failure */ - public static function setExcelCalendar($baseYear): bool + public static function setExcelCalendar(int $baseYear): bool { if ( ($baseYear == self::CALENDAR_WINDOWS_1900) @@ -320,16 +320,11 @@ public static function timestampToExcel($unixTimestamp): bool|float /** * formattedPHPToExcel. * - * @param int $year - * @param int $month - * @param int $day - * @param int $hours - * @param int $minutes * @param float|int $seconds * * @return float Excel date/time value */ - public static function formattedPHPToExcel($year, $month, $day, $hours = 0, $minutes = 0, $seconds = 0): float + public static function formattedPHPToExcel(int $year, int $month, int $day, int $hours = 0, int $minutes = 0, $seconds = 0): float { if (self::$excelCalendar == self::CALENDAR_WINDOWS_1900) { // @@ -407,10 +402,8 @@ public static function isDateTimeFormat(NumberFormat $excelFormatCode, bool $dat /** * Is a given number format code a date/time? - * - * @param string $excelFormatCode */ - public static function isDateTimeFormatCode($excelFormatCode, bool $dateWithoutTimeOkay = true): bool + public static function isDateTimeFormatCode(string $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) @@ -470,7 +463,7 @@ public static function isDateTimeFormatCode($excelFormatCode, bool $dateWithoutT * * @return false|float Excel date/time serial value */ - public static function stringToExcel($dateValue): bool|float + public static function stringToExcel(string $dateValue): bool|float { if (strlen($dateValue) < 2) { return false; @@ -503,7 +496,7 @@ public static function stringToExcel($dateValue): bool|float * * @return int|string Month number (1 - 12), or the original string argument if it isn't a valid month name */ - public static function monthStringToNumber($monthName) + public static function monthStringToNumber(string $monthName) { $monthIndex = 1; foreach (self::$monthNames as $shortMonthName => $longMonthName) { @@ -523,7 +516,7 @@ public static function monthStringToNumber($monthName) * * @return int|string The integer value with any ordinal stripped, or the original string argument if it isn't a valid numeric */ - public static function dayStringToNumber($day) + public static function dayStringToNumber(string $day) { $strippedDayValue = (str_replace(self::$numberSuffixes, '', $day)); if (is_numeric($strippedDayValue)) { diff --git a/src/PhpSpreadsheet/Shared/Drawing.php b/src/PhpSpreadsheet/Shared/Drawing.php index f7ce022c51..44934f7b0e 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): int|float + public static function pixelsToEMU(int $pixelValue): int|float { return $pixelValue * 9525; } @@ -46,7 +46,7 @@ public static function EMUToPixels($emuValue): int * * @return float|int Value in cell dimension */ - public static function pixelsToCellDimension($pixelValue, \PhpOffice\PhpSpreadsheet\Style\Font $defaultFont): int|float + public static function pixelsToCellDimension(int $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): int + public static function cellDimensionToPixels(float $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): float + public static function pixelsToPoints(int $pixelValue): float { return $pixelValue * 0.75; } @@ -130,7 +130,7 @@ public static function pointsToPixels($pointValue): int * * @return int Angle */ - public static function degreesToAngle($degrees): int + public static function degreesToAngle(int $degrees): int { return (int) round($degrees * 60000); } @@ -163,7 +163,7 @@ public static function angleToDegrees($angle): int * * @codeCoverageIgnore */ - public static function imagecreatefrombmp($bmpFilename): GdImage + public static function imagecreatefrombmp(string $bmpFilename): GdImage { $retVal = @imagecreatefrombmp($bmpFilename); if ($retVal === false) { diff --git a/src/PhpSpreadsheet/Shared/Escher.php b/src/PhpSpreadsheet/Shared/Escher.php index 33a9fad0a3..feb314bb58 100644 --- a/src/PhpSpreadsheet/Shared/Escher.php +++ b/src/PhpSpreadsheet/Shared/Escher.php @@ -30,10 +30,8 @@ public function getDggContainer(): ?Escher\DggContainer /** * Set Drawing Group Container. - * - * @param Escher\DggContainer $dggContainer */ - public function setDggContainer($dggContainer): Escher\DggContainer + public function setDggContainer(Escher\DggContainer $dggContainer): Escher\DggContainer { return $this->dggContainer = $dggContainer; } @@ -50,10 +48,8 @@ public function getDgContainer(): ?Escher\DgContainer /** * Set Drawing Container. - * - * @param Escher\DgContainer $dgContainer */ - public function setDgContainer($dgContainer): Escher\DgContainer + public function setDgContainer(Escher\DgContainer $dgContainer): Escher\DgContainer { return $this->dgContainer = $dgContainer; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php index 9cf5d43b5c..dd80109ca2 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer.php @@ -53,8 +53,7 @@ public function getSpgrContainerOrThrow(): DgContainer\SpgrContainer throw new SpreadsheetException('spgrContainer is unexpectedly null'); } - /** @param DgContainer\SpgrContainer $spgrContainer */ - public function setSpgrContainer($spgrContainer): DgContainer\SpgrContainer + public function setSpgrContainer(DgContainer\SpgrContainer $spgrContainer): DgContainer\SpgrContainer { return $this->spgrContainer = $spgrContainer; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php index 9faa02ebbb..c462d454cb 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DgContainer/SpgrContainer/SpContainer.php @@ -68,10 +68,8 @@ class SpContainer /** * Set parent Shape Group Container. - * - * @param SpgrContainer $parent */ - public function setParent($parent): void + public function setParent(SpgrContainer $parent): void { $this->parent = $parent; } @@ -86,10 +84,8 @@ public function getParent(): SpgrContainer /** * Set whether this is a group shape. - * - * @param bool $value */ - public function setSpgr($value): void + public function setSpgr(bool $value): void { $this->spgr = $value; } @@ -104,10 +100,8 @@ public function getSpgr(): bool /** * Set the shape type. - * - * @param int $value */ - public function setSpType($value): void + public function setSpType(int $value): void { $this->spType = $value; } @@ -122,10 +116,8 @@ public function getSpType(): int /** * Set the shape flag. - * - * @param int $value */ - public function setSpFlag($value): void + public function setSpFlag(int $value): void { $this->spFlag = $value; } @@ -140,10 +132,8 @@ public function getSpFlag(): int /** * Set the shape index. - * - * @param int $value */ - public function setSpId($value): void + public function setSpId(int $value): void { $this->spId = $value; } @@ -161,7 +151,7 @@ public function getSpId(): int * * @param int $property The number specifies the option */ - public function setOPT($property, mixed $value): void + public function setOPT(int $property, mixed $value): void { $this->OPT[$property] = $value; } @@ -171,7 +161,7 @@ public function setOPT($property, mixed $value): void * * @param int $property The number specifies the option */ - public function getOPT($property): mixed + public function getOPT(int $property): mixed { if (isset($this->OPT[$property])) { return $this->OPT[$property]; @@ -193,7 +183,7 @@ public function getOPTCollection(): array * * @param string $value eg: 'A1' */ - public function setStartCoordinates($value): void + public function setStartCoordinates(string $value): void { $this->startCoordinates = $value; } @@ -243,7 +233,7 @@ public function getStartOffsetY(): int|float * * @param string $value eg: 'A1' */ - public function setEndCoordinates($value): void + public function setEndCoordinates(string $value): void { $this->endCoordinates = $value; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php index 7857b78393..523bb41773 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php @@ -46,10 +46,8 @@ public function getSpIdMax(): int /** * Set maximum shape index of all shapes in all drawings (plus one). - * - * @param int $value */ - public function setSpIdMax($value): void + public function setSpIdMax(int $value): void { $this->spIdMax = $value; } @@ -64,10 +62,8 @@ public function getCDgSaved(): int /** * Set total number of drawings saved. - * - * @param int $value */ - public function setCDgSaved($value): void + public function setCDgSaved(int $value): void { $this->cDgSaved = $value; } @@ -82,10 +78,8 @@ public function getCSpSaved(): int /** * Set total number of shapes saved (including group shapes). - * - * @param int $value */ - public function setCSpSaved($value): void + public function setCSpSaved(int $value): void { $this->cSpSaved = $value; } @@ -102,10 +96,8 @@ public function getBstoreContainer(): ?DggContainer\BstoreContainer /** * Set BLIP Store Container. - * - * @param DggContainer\BstoreContainer $bstoreContainer */ - public function setBstoreContainer($bstoreContainer): void + public function setBstoreContainer(DggContainer\BstoreContainer $bstoreContainer): void { $this->bstoreContainer = $bstoreContainer; } @@ -115,7 +107,7 @@ public function setBstoreContainer($bstoreContainer): void * * @param int $property The number specifies the option */ - public function setOPT($property, mixed $value): void + public function setOPT(int $property, mixed $value): void { $this->OPT[$property] = $value; } @@ -125,7 +117,7 @@ public function setOPT($property, mixed $value): void * * @param int $property The number specifies the option */ - public function getOPT($property): mixed + public function getOPT(int $property): mixed { if (isset($this->OPT[$property])) { return $this->OPT[$property]; @@ -144,10 +136,8 @@ public function getIDCLs(): array /** * Set identifier clusters. [ => , ...]. - * - * @param array $IDCLs */ - public function setIDCLs($IDCLs): void + public function setIDCLs(array $IDCLs): void { $this->IDCLs = $IDCLs; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php index cfe13eaf85..ee2a5c2a75 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php @@ -72,10 +72,8 @@ public function getBlipType(): int /** * Set the BLIP type. - * - * @param int $blipType */ - public function setBlipType($blipType): void + public function setBlipType(int $blipType): void { $this->blipType = $blipType; } diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php index 767224c69e..763bfe5780 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE/Blip.php @@ -26,10 +26,8 @@ public function getData(): string /** * Set the raw image data. - * - * @param string $data */ - public function setData($data): void + public function setData(string $data): void { $this->data = $data; } diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index 95556df9d5..c8c9d75a2a 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -288,7 +288,7 @@ public static function getExtraFontArray(): array * * @return bool Success or failure */ - public static function setAutoSizeMethod($method): bool + public static function setAutoSizeMethod(string $method): bool { if (!in_array($method, self::AUTOSIZE_METHODS)) { return false; @@ -314,10 +314,8 @@ public static function getAutoSizeMethod(): string *
  • /usr/share/fonts/truetype/
  • *
  • ~/.fonts/
  • * . - * - * @param string $folderPath */ - public static function setTrueTypeFontPath($folderPath): void + public static function setTrueTypeFontPath(string $folderPath): void { self::$trueTypeFontPath = $folderPath; } @@ -369,7 +367,7 @@ public static function getPaddingAmountExact() public static function calculateColumnWidth( FontStyle $font, $cellText = '', - $rotation = 0, + int $rotation = 0, ?FontStyle $defaultFont = null, bool $filterAdjustment = false, int $indentAdjustment = 0 @@ -458,11 +456,9 @@ 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 int $rotation - * * @return int Text width in pixels (no padding added) */ - public static function getTextWidthPixelsApprox(string $columnText, FontStyle $font, $rotation = 0): int + public static function getTextWidthPixelsApprox(string $columnText, FontStyle $font, int $rotation = 0): int { $fontName = $font->getName(); $fontSize = $font->getSize(); @@ -515,7 +511,7 @@ public static function getTextWidthPixelsApprox(string $columnText, FontStyle $f * * @return int Font size (in pixels) */ - public static function fontSizeToPixels($fontSizeInPoints): int + public static function fontSizeToPixels(int $fontSizeInPoints): int { return (int) ((4 / 3) * $fontSizeInPoints); } @@ -523,11 +519,11 @@ public static function fontSizeToPixels($fontSizeInPoints): int /** * Calculate an (approximate) pixel size, based on inch size. * - * @param int $sizeInInch Font size (in inch) + * @param float|int $sizeInInch Font size (in inch) * - * @return int Size (in pixels) + * @return float|int Size (in pixels) */ - public static function inchSizeToPixels($sizeInInch): int|float + public static function inchSizeToPixels(int|float $sizeInInch): int|float { return $sizeInInch * 96; } @@ -535,11 +531,11 @@ public static function inchSizeToPixels($sizeInInch): int|float /** * Calculate an (approximate) pixel size, based on centimeter size. * - * @param int $sizeInCm Font size (in centimeters) + * @param float|int $sizeInCm Font size (in centimeters) * * @return float Size (in pixels) */ - public static function centimeterSizeToPixels($sizeInCm): float + public static function centimeterSizeToPixels(int|float $sizeInCm): float { return $sizeInCm * 37.795275591; } @@ -626,7 +622,7 @@ public static function getTrueTypeFontFileFromFont(FontStyle $font, bool $checkP * * @return int Character set code */ - public static function getCharsetFromFontName($fontName): int + public static function getCharsetFromFontName(string $fontName): int { return self::CHARSET_FROM_FONT_NAME[$fontName] ?? self::CHARSET_ANSI_LATIN; } diff --git a/src/PhpSpreadsheet/Shared/OLE.php b/src/PhpSpreadsheet/Shared/OLE.php index 345a6f861a..68eedb7be6 100644 --- a/src/PhpSpreadsheet/Shared/OLE.php +++ b/src/PhpSpreadsheet/Shared/OLE.php @@ -104,11 +104,9 @@ class OLE * * @acces public * - * @param string $filename - * * @return bool true on success, PEAR_Error on failure */ - public function read($filename): bool + public function read(string $filename): bool { $fh = @fopen($filename, 'rb'); if ($fh === false) { @@ -290,7 +288,7 @@ private static function readInt4($fileHandle): int * * @return bool true on success, PEAR_Error on failure */ - public function readPpsWks($blockId): bool + public function readPpsWks(int $blockId): bool { $fh = $this->getStream($blockId); for ($pos = 0; true; $pos += 128) { @@ -367,7 +365,7 @@ public function readPpsWks($blockId): bool * * @return bool Whether the PPS tree for the given PPS is complete */ - private function ppsTreeComplete($index): bool + private function ppsTreeComplete(int $index): bool { return isset($this->_list[$index]) && ($pps = $this->_list[$index]) @@ -387,7 +385,7 @@ private function ppsTreeComplete($index): bool * * @return bool true if it's a File PPS, false otherwise */ - public function isFile($index): bool + public function isFile(int $index): bool { if (isset($this->_list[$index])) { return $this->_list[$index]->Type == self::OLE_PPS_TYPE_FILE; @@ -404,7 +402,7 @@ public function isFile($index): bool * * @return bool true if it's a Root PPS, false otherwise */ - public function isRoot($index): bool + public function isRoot(int $index): bool { if (isset($this->_list[$index])) { return $this->_list[$index]->Type == self::OLE_PPS_TYPE_ROOT; @@ -436,7 +434,7 @@ public function ppsTotal(): int * * @see OLE_PPS_File::getStream() */ - public function getData($index, $position, $length): string + public function getData(int $index, int $position, int $length): string { // if position is not valid return empty string if (!isset($this->_list[$index]) || ($position >= $this->_list[$index]->Size) || ($position < 0)) { @@ -457,7 +455,7 @@ public function getData($index, $position, $length): string * * @return int The amount of bytes in data the PPS has */ - public function getDataLength($index): int + public function getDataLength(int $index): int { if (isset($this->_list[$index])) { return $this->_list[$index]->Size; @@ -473,7 +471,7 @@ public function getDataLength($index): int * * @return string The string in Unicode */ - public static function ascToUcs($ascii): string + public static function ascToUcs(string $ascii): string { $rawname = ''; $iMax = strlen($ascii); @@ -528,7 +526,7 @@ public static function localDateToOLE($date): string * * @return float|int The Unix timestamp corresponding to the string */ - public static function OLE2LocalDate($oleTimestamp) + public static function OLE2LocalDate(string $oleTimestamp) { if (strlen($oleTimestamp) != 8) { throw new ReaderException('Expecting 8 byte string'); diff --git a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php index 142cdd4b37..61bd6acb01 100644 --- a/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php +++ b/src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php @@ -39,11 +39,11 @@ class ChainedBlockStream * ole-chainedblockstream://oleInstanceId=1 * @param string $mode only "r" is supported * @param int $options mask of STREAM_REPORT_ERRORS and STREAM_USE_PATH - * @param string $openedPath absolute path of the opened stream (out parameter) + * @param ?string $openedPath absolute path of the opened stream (out parameter) * * @return bool true on success */ - public function stream_open($path, $mode, $options, &$openedPath): bool // @codingStandardsIgnoreLine + public function stream_open(string $path, string $mode, int $options, ?string &$openedPath): bool // @codingStandardsIgnoreLine { if ($mode[0] !== 'r') { if ($options & STREAM_REPORT_ERRORS) { @@ -111,7 +111,7 @@ public function stream_close(): void // @codingStandardsIgnoreLine * * @return false|string */ - public function stream_read($count): bool|string // @codingStandardsIgnoreLine + public function stream_read(int $count): bool|string // @codingStandardsIgnoreLine { if ($this->stream_eof()) { return false; @@ -147,7 +147,7 @@ public function stream_tell(): int // @codingStandardsIgnoreLine * @param int $offset byte offset * @param int $whence SEEK_SET, SEEK_CUR or SEEK_END */ - public function stream_seek($offset, $whence): bool // @codingStandardsIgnoreLine + public function stream_seek(int $offset, int $whence): bool // @codingStandardsIgnoreLine { if ($whence == SEEK_SET && $offset >= 0) { $this->pos = $offset; diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index 9e6e0c4782..d5f358ce8f 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -114,7 +114,7 @@ class PPS * @param ?string $data The (usually binary) source data of the PPS * @param array $children Array containing children PPS for this PPS */ - public function __construct($No, $name, $type, $prev, $next, $dir, $time_1st, $time_2nd, $data, $children) + public function __construct(?int $No, ?string $name, ?int $type, ?int $prev, ?int $next, ?int $dir, $time_1st, $time_2nd, ?string $data, array $children) { $this->No = (int) $No; $this->Name = (string) $name; diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php index 8a392817c5..0798e3b52f 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/File.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/File.php @@ -37,7 +37,7 @@ class File extends PPS * * @see OLE::ascToUcs() */ - public function __construct($name) + public function __construct(string $name) { parent::__construct(null, $name, OLE::OLE_PPS_TYPE_FILE, null, null, null, null, null, '', []); } diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index d25c535dbf..b554fa11ce 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -50,7 +50,7 @@ class Root extends PPS * @param null|float|int $time_2nd A timestamp * @param File[] $raChild */ - public function __construct($time_1st, $time_2nd, $raChild) + public function __construct($time_1st, $time_2nd, array $raChild) { parent::__construct(null, OLE::ascToUcs('Root Entry'), OLE::OLE_PPS_TYPE_ROOT, null, null, null, $time_1st, $time_2nd, null, $raChild); } @@ -143,7 +143,7 @@ private function calcSize(array &$raList): array * * @see save() */ - private static function adjust2($i2): float + private static function adjust2(int $i2): float { $iWk = log($i2) / log(2); diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index ac22a18485..6911e732c2 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -157,7 +157,7 @@ public function read(string $filename): void * * @param ?int $stream */ - public function getStream($stream): ?string + public function getStream(?int $stream): ?string { if ($stream === null) { return null; @@ -206,7 +206,7 @@ public function getStream($stream): ?string * * @return string Data for standard stream */ - private function readData($block): string + private function readData(int $block): string { $data = ''; @@ -280,10 +280,8 @@ private function readPropertySets(): void /** * Read 4 bytes of data at specified position. - * - * @param int $pos */ - private static function getInt4d(string $data, $pos): int + private static function getInt4d(string $data, int $pos): int { if ($pos < 0) { // Invalid position diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index 3089215325..f1c8ea3d3e 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -281,7 +281,7 @@ private static function buildCharacterSets(): void * * @param string $textValue Value to unescape */ - public static function controlCharacterOOXML2PHP($textValue): string + public static function controlCharacterOOXML2PHP(string $textValue): string { self::buildCharacterSets(); @@ -301,7 +301,7 @@ public static function controlCharacterOOXML2PHP($textValue): string * * @param string $textValue Value to escape */ - public static function controlCharacterPHP2OOXML($textValue): string + public static function controlCharacterPHP2OOXML(string $textValue): string { self::buildCharacterSets(); @@ -644,11 +644,9 @@ public static function SYLKtoUTF8(string $textValue): string * Retrieve any leading numeric part of a string, or return the full string if no leading numeric * (handles basic integer or float, but not exponent or non decimal). * - * @param string $textValue - * * @return mixed string or only the leading numeric part of the string */ - public static function testStringAsNumeric($textValue): mixed + public static function testStringAsNumeric(string $textValue): mixed { if (is_numeric($textValue)) { return $textValue; diff --git a/src/PhpSpreadsheet/Shared/Trend/BestFit.php b/src/PhpSpreadsheet/Shared/Trend/BestFit.php index 94f97bfde5..9fcbccde8f 100644 --- a/src/PhpSpreadsheet/Shared/Trend/BestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/BestFit.php @@ -90,7 +90,7 @@ public function getBestFitType(): string * * @return float Y-Value */ - abstract public function getValueOfYForX($xValue): float; + abstract public function getValueOfYForX(float $xValue): float; /** * Return the X-Value for a specified value of Y. @@ -99,7 +99,7 @@ abstract public function getValueOfYForX($xValue): float; * * @return float X-Value */ - abstract public function getValueOfXForY($yValue): float; + abstract public function getValueOfXForY(float $yValue): float; /** * Return the original set of X-Values. @@ -116,14 +116,14 @@ public function getXValues(): array * * @param int $dp Number of places of decimal precision to display */ - abstract public function getEquation($dp = 0): string; + abstract public function getEquation(int $dp = 0): string; /** * Return the Slope of the line. * * @param int $dp Number of places of decimal precision to display */ - public function getSlope($dp = 0): float + public function getSlope(int $dp = 0): float { if ($dp != 0) { return round($this->slope, $dp); @@ -137,7 +137,7 @@ public function getSlope($dp = 0): float * * @param int $dp Number of places of decimal precision to display */ - public function getSlopeSE($dp = 0): float + public function getSlopeSE(int $dp = 0): float { if ($dp != 0) { return round($this->slopeSE, $dp); @@ -151,7 +151,7 @@ public function getSlopeSE($dp = 0): float * * @param int $dp Number of places of decimal precision to display */ - public function getIntersect($dp = 0): float + public function getIntersect(int $dp = 0): float { if ($dp != 0) { return round($this->intersect, $dp); @@ -165,7 +165,7 @@ public function getIntersect($dp = 0): float * * @param int $dp Number of places of decimal precision to display */ - public function getIntersectSE($dp = 0): float + public function getIntersectSE(int $dp = 0): float { if ($dp != 0) { return round($this->intersectSE, $dp); @@ -179,7 +179,7 @@ public function getIntersectSE($dp = 0): float * * @param int $dp Number of places of decimal precision to return */ - public function getGoodnessOfFit($dp = 0): float + public function getGoodnessOfFit(int $dp = 0): float { if ($dp != 0) { return round($this->goodnessOfFit, $dp); @@ -193,7 +193,7 @@ public function getGoodnessOfFit($dp = 0): float * * @param int $dp Number of places of decimal precision to return */ - public function getGoodnessOfFitPercent($dp = 0): float + public function getGoodnessOfFitPercent(int $dp = 0): float { if ($dp != 0) { return round($this->goodnessOfFit * 100, $dp); @@ -207,7 +207,7 @@ public function getGoodnessOfFitPercent($dp = 0): float * * @param int $dp Number of places of decimal precision to return */ - public function getStdevOfResiduals($dp = 0): float + public function getStdevOfResiduals(int $dp = 0): float { if ($dp != 0) { return round($this->stdevOfResiduals, $dp); @@ -219,7 +219,7 @@ public function getStdevOfResiduals($dp = 0): float /** * @param int $dp Number of places of decimal precision to return */ - public function getSSRegression($dp = 0): float + public function getSSRegression(int $dp = 0): float { if ($dp != 0) { return round($this->SSRegression, $dp); @@ -231,7 +231,7 @@ public function getSSRegression($dp = 0): float /** * @param int $dp Number of places of decimal precision to return */ - public function getSSResiduals($dp = 0): float + public function getSSResiduals(int $dp = 0): float { if ($dp != 0) { return round($this->SSResiduals, $dp); @@ -243,7 +243,7 @@ public function getSSResiduals($dp = 0): float /** * @param int $dp Number of places of decimal precision to return */ - public function getDFResiduals($dp = 0): float + public function getDFResiduals(int $dp = 0): float { if ($dp != 0) { return round($this->DFResiduals, $dp); @@ -255,7 +255,7 @@ public function getDFResiduals($dp = 0): float /** * @param int $dp Number of places of decimal precision to return */ - public function getF($dp = 0): float + public function getF(int $dp = 0): float { if ($dp != 0) { return round($this->f, $dp); @@ -267,7 +267,7 @@ public function getF($dp = 0): float /** * @param int $dp Number of places of decimal precision to return */ - public function getCovariance($dp = 0): float + public function getCovariance(int $dp = 0): float { if ($dp != 0) { return round($this->covariance, $dp); @@ -279,7 +279,7 @@ public function getCovariance($dp = 0): float /** * @param int $dp Number of places of decimal precision to return */ - public function getCorrelation($dp = 0): float + public function getCorrelation(int $dp = 0): float { if ($dp != 0) { return round($this->correlation, $dp); @@ -297,16 +297,9 @@ public function getYBestFitValues(): array } /** - * @param float $sumX - * @param float $sumY - * @param float $sumX2 - * @param float $sumY2 - * @param float $sumXY - * @param float $meanX - * @param float $meanY * @param bool|int $const */ - protected function calculateGoodnessOfFit($sumX, $sumY, $sumX2, $sumY2, $sumXY, $meanX, $meanY, $const): void + protected function calculateGoodnessOfFit(float $sumX, float $sumY, float $sumX2, float $sumY2, float $sumXY, float $meanX, float $meanY, $const): void { $SSres = $SScov = $SStot = $SSsex = 0.0; foreach ($this->xValues as $xKey => $xValue) { @@ -414,7 +407,7 @@ protected function leastSquareFit(array $yValues, array $xValues, bool $const): * @param float[] $yValues The set of Y-values for this regression * @param float[] $xValues The set of X-values for this regression */ - public function __construct($yValues, $xValues = []) + public function __construct(array $yValues, array $xValues = []) { // Calculate number of points $yValueCount = count($yValues); diff --git a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php index 62a7f95d7e..ed2d8896aa 100644 --- a/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/ExponentialBestFit.php @@ -17,7 +17,7 @@ class ExponentialBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue): float + public function getValueOfYForX(float $xValue): float { return $this->getIntersect() * $this->getSlope() ** ($xValue - $this->xOffset); } @@ -29,7 +29,7 @@ public function getValueOfYForX($xValue): float * * @return float X-Value */ - public function getValueOfXForY($yValue): float + public function getValueOfXForY(float $yValue): float { return log(($yValue + $this->yOffset) / $this->getIntersect()) / log($this->getSlope()); } @@ -39,7 +39,7 @@ public function getValueOfXForY($yValue): float * * @param int $dp Number of places of decimal precision to display */ - public function getEquation($dp = 0): string + public function getEquation(int $dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -52,7 +52,7 @@ public function getEquation($dp = 0): string * * @param int $dp Number of places of decimal precision to display */ - public function getSlope($dp = 0): float + public function getSlope(int $dp = 0): float { if ($dp != 0) { return round(exp($this->slope), $dp); @@ -66,7 +66,7 @@ public function getSlope($dp = 0): float * * @param int $dp Number of places of decimal precision to display */ - public function getIntersect($dp = 0): float + public function getIntersect(int $dp = 0): float { if ($dp != 0) { return round(exp($this->intersect), $dp); @@ -96,9 +96,8 @@ private function exponentialRegression(array $yValues, array $xValues, bool $con * * @param float[] $yValues The set of Y-values for this regression * @param float[] $xValues The set of X-values for this regression - * @param bool $const */ - public function __construct($yValues, $xValues = [], $const = true) + public function __construct(array $yValues, array $xValues = [], bool $const = true) { parent::__construct($yValues, $xValues); diff --git a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php index 12009b6f0c..8a54080037 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LinearBestFit.php @@ -17,7 +17,7 @@ class LinearBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue): float + public function getValueOfYForX(float $xValue): float { return $this->getIntersect() + $this->getSlope() * $xValue; } @@ -29,7 +29,7 @@ public function getValueOfYForX($xValue): float * * @return float X-Value */ - public function getValueOfXForY($yValue): float + public function getValueOfXForY(float $yValue): float { return ($yValue - $this->getIntersect()) / $this->getSlope(); } @@ -39,7 +39,7 @@ public function getValueOfXForY($yValue): float * * @param int $dp Number of places of decimal precision to display */ - public function getEquation($dp = 0): string + public function getEquation(int $dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -63,9 +63,8 @@ private function linearRegression(array $yValues, array $xValues, bool $const): * * @param float[] $yValues The set of Y-values for this regression * @param float[] $xValues The set of X-values for this regression - * @param bool $const */ - public function __construct($yValues, $xValues = [], $const = true) + public function __construct(array $yValues, array $xValues = [], bool $const = true) { parent::__construct($yValues, $xValues); diff --git a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php index 27238e7d6c..3dec61b2df 100644 --- a/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/LogarithmicBestFit.php @@ -17,7 +17,7 @@ class LogarithmicBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue): float + public function getValueOfYForX(float $xValue): float { return $this->getIntersect() + $this->getSlope() * log($xValue - $this->xOffset); } @@ -29,7 +29,7 @@ public function getValueOfYForX($xValue): float * * @return float X-Value */ - public function getValueOfXForY($yValue): float + public function getValueOfXForY(float $yValue): float { return exp(($yValue - $this->getIntersect()) / $this->getSlope()); } @@ -39,7 +39,7 @@ public function getValueOfXForY($yValue): float * * @param int $dp Number of places of decimal precision to display */ - public function getEquation($dp = 0): string + public function getEquation(int $dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -68,9 +68,8 @@ private function logarithmicRegression(array $yValues, array $xValues, bool $con * * @param float[] $yValues The set of Y-values for this regression * @param float[] $xValues The set of X-values for this regression - * @param bool $const */ - public function __construct($yValues, $xValues = [], $const = true) + public function __construct(array $yValues, array $xValues = [], bool $const = true) { parent::__construct($yValues, $xValues); diff --git a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php index 2afaae7c43..3abe695fc8 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php @@ -36,7 +36,7 @@ public function getOrder(): int * * @return float Y-Value */ - public function getValueOfYForX($xValue): float + public function getValueOfYForX(float $xValue): float { $retVal = $this->getIntersect(); $slope = $this->getSlope(); @@ -58,7 +58,7 @@ public function getValueOfYForX($xValue): float * * @return float X-Value */ - public function getValueOfXForY($yValue): float + public function getValueOfXForY(float $yValue): float { return ($yValue - $this->getIntersect()) / $this->getSlope(); } @@ -68,7 +68,7 @@ public function getValueOfXForY($yValue): float * * @param int $dp Number of places of decimal precision to display */ - public function getEquation($dp = 0): string + public function getEquation(int $dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -93,7 +93,7 @@ public function getEquation($dp = 0): string * * @param int $dp Number of places of decimal precision to display */ - public function getSlope($dp = 0): float + public function getSlope(int $dp = 0): float { if ($dp != 0) { $coefficients = []; @@ -109,10 +109,7 @@ public function getSlope($dp = 0): float return $this->slope; } - /** - * @param int $dp - */ - public function getCoefficients($dp = 0): array + public function getCoefficients(int $dp = 0): array { // Phpstan and Scrutinizer are both correct - getSlope returns float, not array. // @phpstan-ignore-next-line @@ -126,7 +123,7 @@ public function getCoefficients($dp = 0): array * @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, array $yValues, array $xValues): void + private function polynomialRegression(int $order, array $yValues, array $xValues): void { // calculate sums $x_sum = array_sum($xValues); @@ -186,7 +183,7 @@ private function polynomialRegression($order, array $yValues, array $xValues): v * @param float[] $yValues The set of Y-values for this regression * @param float[] $xValues The set of X-values for this regression */ - public function __construct($order, $yValues, $xValues = []) + public function __construct(int $order, array $yValues, array $xValues = []) { parent::__construct($yValues, $xValues); diff --git a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php index 288e4bb6be..56b5a12b22 100644 --- a/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/PowerBestFit.php @@ -17,7 +17,7 @@ class PowerBestFit extends BestFit * * @return float Y-Value */ - public function getValueOfYForX($xValue): float + public function getValueOfYForX(float $xValue): float { return $this->getIntersect() * ($xValue - $this->xOffset) ** $this->getSlope(); } @@ -29,7 +29,7 @@ public function getValueOfYForX($xValue): float * * @return float X-Value */ - public function getValueOfXForY($yValue): float + public function getValueOfXForY(float $yValue): float { return (($yValue + $this->yOffset) / $this->getIntersect()) ** (1 / $this->getSlope()); } @@ -39,7 +39,7 @@ public function getValueOfXForY($yValue): float * * @param int $dp Number of places of decimal precision to display */ - public function getEquation($dp = 0): string + public function getEquation(int $dp = 0): string { $slope = $this->getSlope($dp); $intersect = $this->getIntersect($dp); @@ -52,7 +52,7 @@ public function getEquation($dp = 0): string * * @param int $dp Number of places of decimal precision to display */ - public function getIntersect($dp = 0): float + public function getIntersect(int $dp = 0): float { if ($dp != 0) { return round(exp($this->intersect), $dp); @@ -86,9 +86,8 @@ private function powerRegression(array $yValues, array $xValues, bool $const): v * * @param float[] $yValues The set of Y-values for this regression * @param float[] $xValues The set of X-values for this regression - * @param bool $const */ - public function __construct($yValues, $xValues = [], $const = true) + public function __construct(array $yValues, array $xValues = [], bool $const = true) { parent::__construct($yValues, $xValues); diff --git a/src/PhpSpreadsheet/Shared/Trend/Trend.php b/src/PhpSpreadsheet/Shared/Trend/Trend.php index a12f7f60b9..dc8794300d 100644 --- a/src/PhpSpreadsheet/Shared/Trend/Trend.php +++ b/src/PhpSpreadsheet/Shared/Trend/Trend.php @@ -48,12 +48,7 @@ class Trend */ private static array $trendCache = []; - /** - * @param array $yValues - * @param array $xValues - * @param bool $const - */ - public static function calculate(string $trendType = self::TREND_BEST_FIT, $yValues = [], $xValues = [], $const = true): mixed + public static function calculate(string $trendType = self::TREND_BEST_FIT, array $yValues = [], array $xValues = [], bool $const = true): mixed { // 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 978bd8b062..c5fd1d2d94 100644 --- a/src/PhpSpreadsheet/Shared/XMLWriter.php +++ b/src/PhpSpreadsheet/Shared/XMLWriter.php @@ -23,7 +23,7 @@ class XMLWriter extends \XMLWriter * @param int $temporaryStorage Temporary storage location * @param string $temporaryStorageFolder Temporary storage folder */ - public function __construct($temporaryStorage = self::STORAGE_MEMORY, $temporaryStorageFolder = null) + public function __construct(int $temporaryStorage = self::STORAGE_MEMORY, ?string $temporaryStorageFolder = null) { // Open temporary storage if ($temporaryStorage == self::STORAGE_MEMORY) { diff --git a/src/PhpSpreadsheet/Shared/Xls.php b/src/PhpSpreadsheet/Shared/Xls.php index 26626d0f39..cdb1bf243c 100644 --- a/src/PhpSpreadsheet/Shared/Xls.php +++ b/src/PhpSpreadsheet/Shared/Xls.php @@ -18,7 +18,7 @@ class Xls * * @return int The width in pixels */ - public static function sizeCol(Worksheet $worksheet, $col = 'A'): int + public static function sizeCol(Worksheet $worksheet, string $col = 'A'): int { // default font of the workbook $font = $worksheet->getParentOrThrow()->getDefaultStyle()->getFont(); @@ -61,7 +61,7 @@ public static function sizeCol(Worksheet $worksheet, $col = 'A'): int * * @return int The width in pixels */ - public static function sizeRow(Worksheet $worksheet, $row = 1): int + public static function sizeRow(Worksheet $worksheet, int $row = 1): int { // default font of the workbook $font = $worksheet->getParentOrThrow()->getDefaultStyle()->getFont(); @@ -98,14 +98,12 @@ public static function sizeRow(Worksheet $worksheet, $row = 1): int * Get the horizontal distance in pixels between two anchors * The distanceX is found as sum of all the spanning columns widths minus correction for the two offsets. * - * @param string $startColumn * @param float|int $startOffsetX Offset within start cell measured in 1/1024 of the cell width - * @param string $endColumn * @param float|int $endOffsetX Offset within end cell measured in 1/1024 of the cell width * * @return int Horizontal measured in pixels */ - public static function getDistanceX(Worksheet $worksheet, $startColumn = 'A', float|int $startOffsetX = 0, $endColumn = 'A', float|int $endOffsetX = 0): int + public static function getDistanceX(Worksheet $worksheet, string $startColumn = 'A', float|int $startOffsetX = 0, string $endColumn = 'A', float|int $endOffsetX = 0): int { $distanceX = 0; @@ -136,7 +134,7 @@ public static function getDistanceX(Worksheet $worksheet, $startColumn = 'A', fl * * @return int Vertical distance measured in pixels */ - public static function getDistanceY(Worksheet $worksheet, $startRow = 1, float|int $startOffsetY = 0, $endRow = 1, float|int $endOffsetY = 0): int + public static function getDistanceY(Worksheet $worksheet, int $startRow = 1, float|int $startOffsetY = 0, int $endRow = 1, float|int $endOffsetY = 0): int { $distanceY = 0; @@ -204,7 +202,7 @@ public static function getDistanceY(Worksheet $worksheet, $startRow = 1, float|i * @param int $width Width in pixels * @param int $height Height in pixels */ - public static function oneAnchor2twoAnchor(Worksheet $worksheet, string $coordinates, $offsetX, $offsetY, $width, $height): ?array + public static function oneAnchor2twoAnchor(Worksheet $worksheet, string $coordinates, int $offsetX, int $offsetY, int $width, int $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 d2f8c72c53..a708e6a77c 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -188,7 +188,7 @@ public function hasMacros(): bool * * @param bool $hasMacros true|false */ - public function setHasMacros($hasMacros): void + public function setHasMacros(bool $hasMacros): void { $this->hasMacros = (bool) $hasMacros; } @@ -198,7 +198,7 @@ public function setHasMacros($hasMacros): void * * @param string $macroCode string|null */ - public function setMacrosCode($macroCode): void + public function setMacrosCode(string $macroCode): void { $this->macrosCode = $macroCode; $this->setHasMacros($macroCode !== null); @@ -214,10 +214,8 @@ public function getMacrosCode(): ?string /** * Set the macros certificate. - * - * @param null|string $certificate */ - public function setMacrosCertificate($certificate): void + public function setMacrosCertificate(?string $certificate): void { $this->macrosCertificate = $certificate; } @@ -268,11 +266,9 @@ public function setRibbonXMLData($target, $xmlData): void /** * retrieve ribbon XML Data. * - * @param string $what - * * @return null|array|string */ - public function getRibbonXMLData($what = 'all') //we need some constants here... + public function getRibbonXMLData(string $what = 'all') //we need some constants here... { $returnData = null; $what = strtolower($what); @@ -342,10 +338,8 @@ private function getExtensionOnly(mixed $path): string /** * retrieve Binaries Ribbon Objects. - * - * @param string $what */ - public function getRibbonBinObjects($what = 'all'): ?array + public function getRibbonBinObjects(string $what = 'all'): ?array { $ReturnData = null; $what = strtolower($what); @@ -397,7 +391,7 @@ public function hasRibbonBinObjects(): bool * * @param string $codeName Name of the worksheet to check */ - public function sheetCodeNameExists($codeName): bool + public function sheetCodeNameExists(string $codeName): bool { return $this->getSheetByCodeName($codeName) !== null; } @@ -407,7 +401,7 @@ public function sheetCodeNameExists($codeName): bool * * @param string $codeName Sheet name */ - public function getSheetByCodeName($codeName): ?Worksheet + public function getSheetByCodeName(string $codeName): ?Worksheet { $worksheetCount = count($this->workSheetCollection); for ($i = 0; $i < $worksheetCount; ++$i) { @@ -529,7 +523,7 @@ public function getActiveSheet(): Worksheet * * @param null|int $sheetIndex Index where sheet should go (0,1,..., or null for last) */ - public function createSheet($sheetIndex = null): Worksheet + public function createSheet(?int $sheetIndex = null): Worksheet { $newSheet = new Worksheet($this); $this->addSheet($newSheet, $sheetIndex); @@ -542,7 +536,7 @@ public function createSheet($sheetIndex = null): Worksheet * * @param string $worksheetName Name of the worksheet to check */ - public function sheetNameExists($worksheetName): bool + public function sheetNameExists(string $worksheetName): bool { return $this->getSheetByName($worksheetName) !== null; } @@ -553,7 +547,7 @@ public function sheetNameExists($worksheetName): bool * @param Worksheet $worksheet The worksheet to add * @param null|int $sheetIndex Index where sheet should go (0,1,..., or null for last) */ - public function addSheet(Worksheet $worksheet, $sheetIndex = null): Worksheet + public function addSheet(Worksheet $worksheet, ?int $sheetIndex = null): Worksheet { if ($this->sheetNameExists($worksheet->getTitle())) { throw new Exception( @@ -593,7 +587,7 @@ public function addSheet(Worksheet $worksheet, $sheetIndex = null): Worksheet * * @param int $sheetIndex Index position of the worksheet to remove */ - public function removeSheetByIndex($sheetIndex): void + public function removeSheetByIndex(int $sheetIndex): void { $numSheets = count($this->workSheetCollection); if ($sheetIndex > $numSheets - 1) { @@ -617,7 +611,7 @@ public function removeSheetByIndex($sheetIndex): void * * @param int $sheetIndex Sheet index */ - public function getSheet($sheetIndex): Worksheet + public function getSheet(int $sheetIndex): Worksheet { if (!isset($this->workSheetCollection[$sheetIndex])) { $numSheets = $this->getSheetCount(); @@ -645,7 +639,7 @@ public function getAllSheets(): array * * @param string $worksheetName Sheet name */ - public function getSheetByName($worksheetName): ?Worksheet + public function getSheetByName(string $worksheetName): ?Worksheet { $worksheetCount = count($this->workSheetCollection); for ($i = 0; $i < $worksheetCount; ++$i) { @@ -694,7 +688,7 @@ public function getIndex(Worksheet $worksheet): int * * @return int New sheet index */ - public function setIndexByName(string $worksheetName, $newIndexPosition): int + public function setIndexByName(string $worksheetName, int $newIndexPosition): int { $oldIndex = $this->getIndex($this->getSheetByNameOrThrow($worksheetName)); $worksheet = array_splice( @@ -735,7 +729,7 @@ public function getActiveSheetIndex(): int * * @param int $worksheetIndex Active sheet index */ - public function setActiveSheetIndex($worksheetIndex): Worksheet + public function setActiveSheetIndex(int $worksheetIndex): Worksheet { $numSheets = count($this->workSheetCollection); @@ -787,7 +781,7 @@ public function getSheetNames(): array * @param Worksheet $worksheet External sheet to add * @param null|int $sheetIndex Index where sheet should go (0,1,..., or null for last) */ - public function addExternalSheet(Worksheet $worksheet, $sheetIndex = null): Worksheet + public function addExternalSheet(Worksheet $worksheet, ?int $sheetIndex = null): Worksheet { if ($this->sheetNameExists($worksheet->getTitle())) { throw new Exception("Workbook already contains a worksheet named '{$worksheet->getTitle()}'. Rename the external sheet first."); @@ -1085,10 +1079,8 @@ public function getCellXfCollection(): array /** * Get cellXf by index. - * - * @param int $cellStyleIndex */ - public function getCellXfByIndex($cellStyleIndex): Style + public function getCellXfByIndex(int $cellStyleIndex): Style { return $this->cellXfCollection[$cellStyleIndex]; } @@ -1096,11 +1088,9 @@ public function getCellXfByIndex($cellStyleIndex): Style /** * Get cellXf by hash code. * - * @param string $hashcode - * * @return false|Style */ - public function getCellXfByHashCode($hashcode) + public function getCellXfByHashCode(string $hashcode) { foreach ($this->cellXfCollection as $cellXf) { if ($cellXf->getHashCode() === $hashcode) { @@ -1145,7 +1135,7 @@ public function addCellXf(Style $style): void * * @param int $cellStyleIndex Index to cellXf */ - public function removeCellXfByIndex($cellStyleIndex): void + public function removeCellXfByIndex(int $cellStyleIndex): void { if ($cellStyleIndex > count($this->cellXfCollection) - 1) { throw new Exception('CellXf index is out of bounds.'); @@ -1193,7 +1183,7 @@ public function getCellStyleXfCollection(): array * * @param int $cellStyleIndex Index to cellXf */ - public function getCellStyleXfByIndex($cellStyleIndex): Style + public function getCellStyleXfByIndex(int $cellStyleIndex): Style { return $this->cellStyleXfCollection[$cellStyleIndex]; } @@ -1201,11 +1191,9 @@ public function getCellStyleXfByIndex($cellStyleIndex): Style /** * Get cellStyleXf by hash code. * - * @param string $hashcode - * * @return false|Style */ - public function getCellStyleXfByHashCode($hashcode) + public function getCellStyleXfByHashCode(string $hashcode) { foreach ($this->cellStyleXfCollection as $cellStyleXf) { if ($cellStyleXf->getHashCode() === $hashcode) { @@ -1230,7 +1218,7 @@ public function addCellStyleXf(Style $style): void * * @param int $cellStyleIndex Index to cellXf */ - public function removeCellStyleXfByIndex($cellStyleIndex): void + public function removeCellStyleXfByIndex(int $cellStyleIndex): void { if ($cellStyleIndex > count($this->cellStyleXfCollection) - 1) { throw new Exception('CellStyleXf index is out of bounds.'); @@ -1342,7 +1330,7 @@ public function getShowHorizontalScroll(): bool * * @param bool $showHorizontalScroll True if horizonal scroll bar is visible */ - public function setShowHorizontalScroll($showHorizontalScroll): void + public function setShowHorizontalScroll(bool $showHorizontalScroll): void { $this->showHorizontalScroll = (bool) $showHorizontalScroll; } @@ -1362,7 +1350,7 @@ public function getShowVerticalScroll(): bool * * @param bool $showVerticalScroll True if vertical scroll bar is visible */ - public function setShowVerticalScroll($showVerticalScroll): void + public function setShowVerticalScroll(bool $showVerticalScroll): void { $this->showVerticalScroll = (bool) $showVerticalScroll; } @@ -1382,7 +1370,7 @@ public function getShowSheetTabs(): bool * * @param bool $showSheetTabs True if sheet tabs are visible */ - public function setShowSheetTabs($showSheetTabs): void + public function setShowSheetTabs(bool $showSheetTabs): void { $this->showSheetTabs = (bool) $showSheetTabs; } @@ -1402,7 +1390,7 @@ public function getMinimized(): bool * * @param bool $minimized true if workbook window is minimized */ - public function setMinimized($minimized): void + public function setMinimized(bool $minimized): void { $this->minimized = (bool) $minimized; } @@ -1424,7 +1412,7 @@ public function getAutoFilterDateGrouping(): bool * * @param bool $autoFilterDateGrouping true if workbook window is minimized */ - public function setAutoFilterDateGrouping($autoFilterDateGrouping): void + public function setAutoFilterDateGrouping(bool $autoFilterDateGrouping): void { $this->autoFilterDateGrouping = (bool) $autoFilterDateGrouping; } @@ -1444,7 +1432,7 @@ public function getFirstSheetIndex(): int * * @param int $firstSheetIndex First sheet in book view */ - public function setFirstSheetIndex($firstSheetIndex): void + public function setFirstSheetIndex(int $firstSheetIndex): void { if ($firstSheetIndex >= 0) { $this->firstSheetIndex = (int) $firstSheetIndex; @@ -1481,7 +1469,7 @@ public function getVisibility(): string * * @param null|string $visibility visibility status of the workbook */ - public function setVisibility($visibility): void + public function setVisibility(?string $visibility): void { if ($visibility === null) { $visibility = self::VISIBILITY_VISIBLE; @@ -1511,7 +1499,7 @@ public function getTabRatio(): int * * @param int $tabRatio Ratio between the tabs bar and the horizontal scroll bar */ - public function setTabRatio($tabRatio): void + public function setTabRatio(int $tabRatio): void { if ($tabRatio >= 0 && $tabRatio <= 1000) { $this->tabRatio = (int) $tabRatio; diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 21bc447983..6f2af7b9cf 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -137,7 +137,7 @@ class Alignment extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct(bool $isSupervisor = false, bool $isConditional = false) { // Supervisor? parent::__construct($isSupervisor); @@ -163,10 +163,8 @@ public function getSharedComponent(): self /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { return ['alignment' => $array]; } @@ -276,7 +274,7 @@ public function getVertical(): null|string * * @return $this */ - public function setVertical($verticalAlignment): static + public function setVertical(string $verticalAlignment): static { $verticalAlignment = strtolower($verticalAlignment); @@ -305,11 +303,9 @@ public function getTextRotation(): null|int /** * Set TextRotation. * - * @param int $angleInDegrees - * * @return $this */ - public function setTextRotation($angleInDegrees): static + public function setTextRotation(int $angleInDegrees): static { // Excel2007 value 255 => PhpSpreadsheet value -165 if ($angleInDegrees == self::TEXTROTATION_STACK_EXCEL) { @@ -346,11 +342,9 @@ public function getWrapText(): bool /** * Set Wrap Text. * - * @param bool $wrapped - * * @return $this */ - public function setWrapText($wrapped): static + public function setWrapText(bool $wrapped): static { if ($wrapped == '') { $wrapped = false; @@ -380,11 +374,9 @@ public function getShrinkToFit(): bool /** * Set Shrink to fit. * - * @param bool $shrink - * * @return $this */ - public function setShrinkToFit($shrink): static + public function setShrinkToFit(bool $shrink): static { if ($shrink == '') { $shrink = false; @@ -414,11 +406,9 @@ public function getIndent(): int /** * Set indent. * - * @param int $indent - * * @return $this */ - public function setIndent($indent): static + public function setIndent(int $indent): static { if ($indent > 0) { if ( @@ -455,11 +445,9 @@ public function getReadOrder(): int /** * Set read order. * - * @param int $readOrder - * * @return $this */ - public function setReadOrder($readOrder): static + public function setReadOrder(int $readOrder): static { if ($readOrder < 0 || $readOrder > 2) { $readOrder = 0; diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index e665e86fb0..e8f4ac2ec8 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -42,7 +42,7 @@ class Border extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, bool $isConditional = false) + public function __construct(bool $isSupervisor = false, bool $isConditional = false) { // Supervisor? parent::__construct($isSupervisor); @@ -83,10 +83,8 @@ public function getSharedComponent(): self /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { /** @var Style */ $parent = $this->parent; diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index 344b218307..becb00d6b3 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -74,7 +74,7 @@ class Borders extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, bool $isConditional = false) + public function __construct(bool $isSupervisor = false, bool $isConditional = false) { // Supervisor? parent::__construct($isSupervisor); @@ -124,10 +124,8 @@ public function getSharedComponent(): self /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { return ['borders' => $array]; } @@ -324,7 +322,7 @@ public function getDiagonalDirection(): int * * @return $this */ - public function setDiagonalDirection($direction): static + public function setDiagonalDirection(int $direction): static { if ($direction == '') { $direction = self::DIAGONAL_NONE; diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index 6af05465c8..7abcc2f1df 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -122,7 +122,7 @@ class Color extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($colorValue = self::COLOR_BLACK, $isSupervisor = false, $isConditional = false) + public function __construct(string $colorValue = self::COLOR_BLACK, bool $isSupervisor = false, bool $isConditional = false) { // Supervisor? parent::__construct($isSupervisor); @@ -156,10 +156,8 @@ public function getSharedComponent(): self /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { /** @var Style */ $parent = $this->parent; @@ -284,7 +282,7 @@ public function setRGB(?string $colorValue = self::COLOR_BLACK): static * * @return int|string The extracted colour component */ - private static function getColourComponent($rgbValue, $offset, $hex = true): string|int + private static function getColourComponent(string $rgbValue, int $offset, bool $hex = true): string|int { $colour = substr($rgbValue, $offset, 2) ?: ''; if (preg_match('/^[0-9a-f]{2}$/i', $colour) !== 1) { @@ -303,7 +301,7 @@ private static function getColourComponent($rgbValue, $offset, $hex = true): str * * @return int|string The red colour component */ - public static function getRed($rgbValue, $hex = true) + public static function getRed(string $rgbValue, bool $hex = true) { return self::getColourComponent($rgbValue, strlen($rgbValue) - 6, $hex); } @@ -317,7 +315,7 @@ public static function getRed($rgbValue, $hex = true) * * @return int|string The green colour component */ - public static function getGreen($rgbValue, $hex = true) + public static function getGreen(string $rgbValue, bool $hex = true) { return self::getColourComponent($rgbValue, strlen($rgbValue) - 4, $hex); } @@ -331,7 +329,7 @@ public static function getGreen($rgbValue, $hex = true) * * @return int|string The blue colour component */ - public static function getBlue($rgbValue, $hex = true) + public static function getBlue(string $rgbValue, bool $hex = true) { return self::getColourComponent($rgbValue, strlen($rgbValue) - 2, $hex); } @@ -344,7 +342,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): string + public static function changeBrightness(string $hexColourValue, float $adjustPercentage): string { $rgba = (strlen($hexColourValue) === 8); $adjustPercentage = max(-1.0, min(1.0, $adjustPercentage)); @@ -366,7 +364,7 @@ public static function changeBrightness($hexColourValue, $adjustPercentage): str * @param bool $background Flag to indicate whether default background or foreground colour * should be returned if the indexed colour doesn't exist */ - public static function indexedColor($colorIndex, $background = false, ?array $palette = null): self + public static function indexedColor(int $colorIndex, bool $background = false, ?array $palette = null): self { // Clean parameter $colorIndex = (int) $colorIndex; diff --git a/src/PhpSpreadsheet/Style/Conditional.php b/src/PhpSpreadsheet/Style/Conditional.php index c16474dadb..a78dfa00c7 100644 --- a/src/PhpSpreadsheet/Style/Conditional.php +++ b/src/PhpSpreadsheet/Style/Conditional.php @@ -142,7 +142,7 @@ public function getConditionType(): string * * @return $this */ - public function setConditionType($type): static + public function setConditionType(string $type): static { $this->conditionType = $type; @@ -164,7 +164,7 @@ public function getOperatorType(): string * * @return $this */ - public function setOperatorType($type): static + public function setOperatorType(string $type): static { $this->operatorType = $type; @@ -182,11 +182,9 @@ public function getText(): string /** * Set text. * - * @param string $text - * * @return $this */ - public function setText($text): static + public function setText(string $text): static { $this->text = $text; @@ -204,11 +202,9 @@ public function getStopIfTrue(): bool /** * Set StopIfTrue. * - * @param bool $stopIfTrue - * * @return $this */ - public function setStopIfTrue($stopIfTrue): static + public function setStopIfTrue(bool $stopIfTrue): static { $this->stopIfTrue = $stopIfTrue; diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php index dae96c8733..5a8fe9b98a 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php @@ -80,10 +80,9 @@ public static function fromConditional(Conditional $conditional, string $cellRan } /** - * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, $arguments): self + public function __call(string $methodName, array $arguments): self { if (!array_key_exists($methodName, self::OPERATORS)) { throw new Exception('Invalid Operation for Blanks CF Rule Wizard'); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php index c58b0578d8..289647c4e2 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php @@ -155,10 +155,9 @@ public static function fromConditional(Conditional $conditional, string $cellRan } /** - * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, array $arguments): self + public function __call(string $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/DateValue.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php index be26466dcb..23477e9c9a 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php @@ -94,10 +94,9 @@ public static function fromConditional(Conditional $conditional, string $cellRan } /** - * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, $arguments): self + public function __call(string $methodName, array $arguments): self { if (!isset(self::MAGIC_OPERATIONS[$methodName])) { throw new Exception('Invalid Operation for Date Value CF Rule Wizard'); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php index 57f4b5c0e2..0fbeddbbea 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php @@ -59,10 +59,9 @@ public static function fromConditional(Conditional $conditional, string $cellRan } /** - * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, $arguments): self + public function __call(string $methodName, array $arguments): self { if (!array_key_exists($methodName, self::OPERATORS)) { throw new Exception('Invalid Operation for Errors CF Rule Wizard'); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php index 4170b40445..03a2381dc2 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php @@ -76,10 +76,9 @@ public static function fromConditional(Conditional $conditional, string $cellRan } /** - * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, $arguments): self + public function __call(string $methodName, array $arguments): self { if (!array_key_exists($methodName, self::OPERATORS)) { throw new Exception('Invalid Operation for Errors CF Rule Wizard'); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php index 38ab967d30..c30e19f190 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php @@ -54,10 +54,9 @@ public static function fromConditional(Conditional $conditional, string $cellRan } /** - * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, array $arguments): self + public function __call(string $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 1867f86eaa..b9eea2345a 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php @@ -137,10 +137,9 @@ public static function fromConditional(Conditional $conditional, string $cellRan } /** - * @param string $methodName * @param mixed[] $arguments */ - public function __call($methodName, array $arguments): self + public function __call(string $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/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index aaaa26b4d9..f45ba7b07d 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -63,7 +63,7 @@ class Fill extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct(bool $isSupervisor = false, bool $isConditional = false) { // Supervisor? parent::__construct($isSupervisor); @@ -96,10 +96,8 @@ public function getSharedComponent(): self /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { return ['fill' => $array]; } @@ -171,7 +169,7 @@ public function getFillType(): ?string * * @return $this */ - public function setFillType($fillType): static + public function setFillType(string $fillType): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['fillType' => $fillType]); @@ -198,11 +196,9 @@ public function getRotation(): float /** * Set Rotation. * - * @param float $angleInDegrees - * * @return $this */ - public function setRotation($angleInDegrees): static + public function setRotation(float $angleInDegrees): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['rotation' => $angleInDegrees]); diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index 915bede0f7..f64c8c9721 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -92,7 +92,7 @@ class Font extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct(bool $isSupervisor = false, bool $isConditional = false) { // Supervisor? parent::__construct($isSupervisor); @@ -131,10 +131,8 @@ public function getSharedComponent(): self /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { return ['font' => $array]; } @@ -254,10 +252,8 @@ public function getComplexScript(): string /** * Set Name and turn off Scheme. - * - * @param string $fontname */ - public function setName($fontname): self + public function setName(string $fontname): self { if ($fontname == '') { $fontname = 'Calibri'; @@ -384,11 +380,9 @@ public function getBold(): ?bool /** * Set Bold. * - * @param bool $bold - * * @return $this */ - public function setBold($bold): static + public function setBold(bool $bold): static { if ($bold == '') { $bold = false; @@ -418,11 +412,9 @@ public function getItalic(): ?bool /** * Set Italic. * - * @param bool $italic - * * @return $this */ - public function setItalic($italic): static + public function setItalic(bool $italic): static { if ($italic == '') { $italic = false; @@ -657,11 +649,9 @@ public function getStrikethrough(): ?bool /** * Set Strikethrough. * - * @param bool $strikethru - * * @return $this */ - public function setStrikethrough($strikethru): static + public function setStrikethrough(bool $strikethru): static { if ($strikethru == '') { $strikethru = false; diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index ebb8dbf9eb..bc9f770e4f 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -122,7 +122,7 @@ class NumberFormat extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct(bool $isSupervisor = false, bool $isConditional = false) { // Supervisor? parent::__construct($isSupervisor); @@ -147,10 +147,8 @@ public function getSharedComponent(): self /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { return ['numberFormat' => $array]; } @@ -360,10 +358,8 @@ private static function fillBuiltInFormatCodes(): void /** * Get built-in format code. - * - * @param int $index */ - public static function builtInFormatCode($index): string + public static function builtInFormatCode(int $index): string { // Clean parameter $index = (int) $index; @@ -382,11 +378,9 @@ public static function builtInFormatCode($index): string /** * Get built-in format code index. * - * @param string $formatCodeIndex - * * @return false|int */ - public static function builtInFormatCodeIndex($formatCodeIndex) + public static function builtInFormatCodeIndex(string $formatCodeIndex) { // Ensure built-in format codes are available self::fillBuiltInFormatCodes(); @@ -427,7 +421,7 @@ public function getHashCode(): string * * @return string Formatted string */ - public static function toFormattedString(mixed $value, $format, $callBack = null): string + public static function toFormattedString(mixed $value, string $format, ?array $callBack = null): string { return NumberFormat\Formatter::toFormattedString($value, $format, $callBack); } diff --git a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php index 2d0919d510..20c0fd4e58 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php @@ -114,7 +114,7 @@ private static function splitFormatForSectionSelection(array $sections, mixed $v * * @return string Formatted string */ - public static function toFormattedString($value, $format, $callBack = null): string + public static function toFormattedString($value, string $format, ?array $callBack = null): string { if (is_bool($value)) { return $value ? Calculation::getTRUE() : Calculation::getFALSE(); diff --git a/src/PhpSpreadsheet/Style/Protection.php b/src/PhpSpreadsheet/Style/Protection.php index 9255ba7fe1..a39a7ff222 100644 --- a/src/PhpSpreadsheet/Style/Protection.php +++ b/src/PhpSpreadsheet/Style/Protection.php @@ -29,7 +29,7 @@ class Protection extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct(bool $isSupervisor = false, bool $isConditional = false) { // Supervisor? parent::__construct($isSupervisor); @@ -55,10 +55,8 @@ public function getSharedComponent(): self /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { return ['protection' => $array]; } @@ -114,7 +112,7 @@ public function getLocked(): ?string * * @return $this */ - public function setLocked($lockType): static + public function setLocked(string $lockType): static { if ($this->isSupervisor) { $styleArray = $this->getStyleArray(['locked' => $lockType]); @@ -145,7 +143,7 @@ public function getHidden(): ?string * * @return $this */ - public function setHidden($hiddenType): static + public function setHidden(string $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 9c09587b32..07d0d77c9e 100644 --- a/src/PhpSpreadsheet/Style/RgbTint.php +++ b/src/PhpSpreadsheet/Style/RgbTint.php @@ -69,7 +69,7 @@ private static function rgbToHls(float $red, float $green, float $blue): array * * @return float[] */ - private static function hlsToRgb(float $hue, $luminance, $saturation): array + private static function hlsToRgb(float $hue, float $luminance, float $saturation): array { if ($saturation === 0.0) { return [$luminance, $luminance, $luminance]; diff --git a/src/PhpSpreadsheet/Style/Style.php b/src/PhpSpreadsheet/Style/Style.php index 23d7e66dfe..68ca39e06e 100644 --- a/src/PhpSpreadsheet/Style/Style.php +++ b/src/PhpSpreadsheet/Style/Style.php @@ -79,7 +79,7 @@ class Style extends Supervisor * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false, $isConditional = false) + public function __construct(bool $isSupervisor = false, bool $isConditional = false) { parent::__construct($isSupervisor); @@ -130,10 +130,8 @@ public function getParent(): Spreadsheet /** * Build style array from subcomponents. - * - * @param array $array */ - public function getStyleArray($array): array + public function getStyleArray(array $array): array { return ['quotePrefix' => $array]; } @@ -183,7 +181,7 @@ public function getStyleArray($array): array * * @return $this */ - public function applyFromArray(array $styleArray, $advancedBorders = true): static + public function applyFromArray(array $styleArray, bool $advancedBorders = true): static { if ($this->isSupervisor) { $pRange = $this->getSelectedCells(); @@ -639,11 +637,9 @@ public function getQuotePrefix(): bool /** * Set quote prefix. * - * @param bool $quotePrefix - * * @return $this */ - public function setQuotePrefix($quotePrefix): static + public function setQuotePrefix(bool $quotePrefix): static { if ($quotePrefix == '') { $quotePrefix = false; @@ -687,10 +683,8 @@ public function getIndex(): int /** * Set own index in style collection. - * - * @param int $index */ - public function setIndex($index): void + public function setIndex(int $index): void { $this->index = $index; } diff --git a/src/PhpSpreadsheet/Style/Supervisor.php b/src/PhpSpreadsheet/Style/Supervisor.php index bbae57ceee..4b796f46f5 100644 --- a/src/PhpSpreadsheet/Style/Supervisor.php +++ b/src/PhpSpreadsheet/Style/Supervisor.php @@ -32,7 +32,7 @@ abstract class Supervisor implements IComparable * Leave this value at default unless you understand exactly what * its ramifications are */ - public function __construct($isSupervisor = false) + public function __construct(bool $isSupervisor = false) { // Supervisor? $this->isSupervisor = $isSupervisor; @@ -42,11 +42,10 @@ public function __construct($isSupervisor = false) * Bind parent. Only used for supervisor. * * @param Spreadsheet|Supervisor $parent - * @param null|string $parentPropertyName * * @return $this */ - public function bindParent($parent, $parentPropertyName = null) + public function bindParent($parent, ?string $parentPropertyName = null) { $this->parent = $parent; $this->parentPropertyName = $parentPropertyName; @@ -154,8 +153,6 @@ abstract public function getSharedComponent(): mixed; /** * Build style array from subcomponents. - * - * @param array $array */ - abstract public function getStyleArray($array): array; + abstract public function getStyleArray(array $array): array; } diff --git a/src/PhpSpreadsheet/Theme.php b/src/PhpSpreadsheet/Theme.php index 081009708f..adeef80b39 100644 --- a/src/PhpSpreadsheet/Theme.php +++ b/src/PhpSpreadsheet/Theme.php @@ -187,8 +187,7 @@ public function getMajorFontSubstitutions(): array return $this->majorFontSubstitutions; } - /** @param null|array $substitutions */ - public function setMajorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, $substitutions): self + public function setMajorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, ?array $substitutions): self { if (!empty($latin)) { $this->majorFontLatin = $latin; @@ -226,8 +225,7 @@ public function getMinorFontSubstitutions(): array return $this->minorFontSubstitutions; } - /** @param null|array $substitutions */ - public function setMinorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, $substitutions): self + public function setMinorFontValues(?string $latin, ?string $eastAsian, ?string $complexScript, ?array $substitutions): self { if (!empty($latin)) { $this->minorFontLatin = $latin; diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index a0d9167726..3e53f51ba1 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -169,7 +169,7 @@ public function getColumns(): array * * @return int The column offset within the autofilter range */ - public function testColumnInRange($column): int + public function testColumnInRange(string $column): int { if (empty($this->range)) { throw new Exception('No autofilter range is defined.'); @@ -191,7 +191,7 @@ public function testColumnInRange($column): int * * @return int The offset of the specified column within the autofilter range */ - public function getColumnOffset($column): int + public function getColumnOffset(string $column): int { return $this->testColumnInRange($column); } @@ -201,7 +201,7 @@ public function getColumnOffset($column): int * * @param string $column Column name (e.g. A) */ - public function getColumn($column): AutoFilter\Column + public function getColumn(string $column): AutoFilter\Column { $this->testColumnInRange($column); @@ -217,7 +217,7 @@ public function getColumn($column): AutoFilter\Column * * @param int $columnOffset Column offset within range (starting from 0) */ - public function getColumnByOffset($columnOffset): AutoFilter\Column + public function getColumnByOffset(int $columnOffset): AutoFilter\Column { [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range); $pColumn = Coordinate::stringFromColumnIndex($rangeStart[0] + $columnOffset); @@ -263,7 +263,7 @@ public function setColumn($columnObjectOrString): static * * @return $this */ - public function clearColumn($column): static + public function clearColumn(string $column): static { $this->evaluated = false; $this->testColumnInRange($column); @@ -287,7 +287,7 @@ public function clearColumn($column): static * * @return $this */ - public function shiftColumn($fromColumn, $toColumn): static + public function shiftColumn(string $fromColumn, string $toColumn): static { $this->evaluated = false; $fromColumn = strtoupper($fromColumn); @@ -368,7 +368,7 @@ protected static function filterTestInDateGroupSet(mixed $cellValue, array $data * * @param mixed[] $ruleSet */ - protected static function filterTestInCustomDataSet(mixed $cellValue, $ruleSet): bool + protected static function filterTestInCustomDataSet(mixed $cellValue, array $ruleSet): bool { /** @var array[] */ $dataSet = $ruleSet['filterRules']; @@ -481,7 +481,7 @@ protected static function filterTestInCustomDataSet(mixed $cellValue, $ruleSet): * * @param mixed[] $monthSet */ - protected static function filterTestInPeriodDateSet(mixed $cellValue, $monthSet): bool + protected static function filterTestInPeriodDateSet(mixed $cellValue, array $monthSet): bool { // Blank cells are always ignored, so return a FALSE if (($cellValue == '') || ($cellValue === null)) { @@ -720,11 +720,9 @@ private static function dynamicYesterday(): array /** * Convert a dynamic rule daterange to a custom filter range expression for ease of calculation. * - * @param string $dynamicRuleType - * * @return mixed[] */ - private function dynamicFilterDateRange($dynamicRuleType, AutoFilter\Column &$filterColumn): array + private function dynamicFilterDateRange(string $dynamicRuleType, AutoFilter\Column &$filterColumn): array { $ruleValues = []; $callBack = [__CLASS__, self::DATE_FUNCTIONS[$dynamicRuleType]]; // What if not found? @@ -753,7 +751,7 @@ private function dynamicFilterDateRange($dynamicRuleType, AutoFilter\Column &$fi * * @param ?string $ruleType */ - private function calculateTopTenValue(string $columnID, int $startRow, int $endRow, $ruleType, mixed $ruleValue): mixed + private function calculateTopTenValue(string $columnID, int $startRow, int $endRow, ?string $ruleType, mixed $ruleValue): mixed { $range = $columnID . $startRow . ':' . $columnID . $endRow; $retVal = null; diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index 2e65105315..fa1bf202ae 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -86,7 +86,7 @@ class Column * @param string $column Column (e.g. A) * @param AutoFilter $parent Autofilter for this column */ - public function __construct($column, ?AutoFilter $parent = null) + public function __construct(string $column, ?AutoFilter $parent = null) { $this->columnIndex = $column; $this->parent = $parent; @@ -114,7 +114,7 @@ public function getColumnIndex(): string * * @return $this */ - public function setColumnIndex($column): static + public function setColumnIndex(string $column): static { $this->setEvaluatedFalse(); // Uppercase coordinate @@ -160,11 +160,9 @@ public function getFilterType(): string /** * Set AutoFilter Type. * - * @param string $filterType - * * @return $this */ - public function setFilterType($filterType): static + public function setFilterType(string $filterType): static { $this->setEvaluatedFalse(); if (!in_array($filterType, self::$filterTypes)) { @@ -194,7 +192,7 @@ public function getJoin(): string * * @return $this */ - public function setJoin($join): static + public function setJoin(string $join): static { $this->setEvaluatedFalse(); // Lowercase And/Or @@ -215,7 +213,7 @@ public function setJoin($join): static * * @return $this */ - public function setAttributes($attributes): static + public function setAttributes(array $attributes): static { $this->setEvaluatedFalse(); $this->attributes = $attributes; @@ -231,7 +229,7 @@ public function setAttributes($attributes): static * * @return $this */ - public function setAttribute($name, $value): static + public function setAttribute(string $name, $value): static { $this->setEvaluatedFalse(); $this->attributes[$name] = $value; @@ -256,7 +254,7 @@ public function getAttributes(): array * * @return null|int|string */ - public function getAttribute($name) + public function getAttribute(string $name) { if (isset($this->attributes[$name])) { return $this->attributes[$name]; @@ -285,7 +283,7 @@ public function getRules(): array * * @param int $index Rule index in the ruleset array */ - public function getRule($index): Column\Rule + public function getRule(int $index): Column\Rule { if (!isset($this->ruleset[$index])) { $this->ruleset[$index] = new Column\Rule($this); @@ -330,7 +328,7 @@ public function addRule(Column\Rule $rule): static * * @return $this */ - public function deleteRule($index): static + public function deleteRule(int $index): static { $this->setEvaluatedFalse(); if (isset($this->ruleset[$index])) { diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index 2edbc7874a..6be6ccbc61 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -226,7 +226,7 @@ public function getRuleType(): string * * @return $this */ - public function setRuleType($ruleType): static + public function setRuleType(string $ruleType): static { $this->setEvaluatedFalse(); if (!in_array($ruleType, self::RULE_TYPES)) { @@ -296,7 +296,7 @@ public function getOperator(): string * * @return $this */ - public function setOperator($operator): static + public function setOperator(string $operator): static { $this->setEvaluatedFalse(); if (empty($operator)) { @@ -324,11 +324,9 @@ public function getGrouping(): string /** * Set AutoFilter Rule Grouping. * - * @param string $grouping - * * @return $this */ - public function setGrouping($grouping): static + public function setGrouping(string $grouping): static { $this->setEvaluatedFalse(); if ( @@ -349,11 +347,10 @@ public function setGrouping($grouping): static * * @param string $operator see self::AUTOFILTER_COLUMN_RULE_* * @param int|int[]|string|string[] $value - * @param string $grouping * * @return $this */ - public function setRule($operator, $value, $grouping = null): static + public function setRule(string $operator, $value, ?string $grouping = null): static { $this->setEvaluatedFalse(); $this->setOperator($operator); diff --git a/src/PhpSpreadsheet/Worksheet/Column.php b/src/PhpSpreadsheet/Worksheet/Column.php index 47681425b5..926e293260 100644 --- a/src/PhpSpreadsheet/Worksheet/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Column.php @@ -13,10 +13,8 @@ class Column /** * Create a new column. - * - * @param string $columnIndex */ - public function __construct(Worksheet $worksheet, $columnIndex = 'A') + public function __construct(Worksheet $worksheet, string $columnIndex = 'A') { // Set parent and column index $this->worksheet = $worksheet; @@ -45,7 +43,7 @@ public function getColumnIndex(): string * @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 getCellIterator($startRow = 1, $endRow = null, bool $iterateOnlyExistingCells = false): ColumnCellIterator + public function getCellIterator(int $startRow = 1, ?int $endRow = null, bool $iterateOnlyExistingCells = false): ColumnCellIterator { return new ColumnCellIterator($this->worksheet, $this->columnIndex, $startRow, $endRow, $iterateOnlyExistingCells); } @@ -56,7 +54,7 @@ public function getCellIterator($startRow = 1, $endRow = null, bool $iterateOnly * @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 getRowIterator($startRow = 1, $endRow = null, bool $iterateOnlyExistingCells = false): ColumnCellIterator + public function getRowIterator(int $startRow = 1, ?int $endRow = null, bool $iterateOnlyExistingCells = false): ColumnCellIterator { return $this->getCellIterator($startRow, $endRow, $iterateOnlyExistingCells); } @@ -80,7 +78,7 @@ public function getRowIterator($startRow = 1, $endRow = null, bool $iterateOnlyE * @param int $startRow The row number at which to start checking if cells are empty * @param int $endRow Optionally, the row number at which to stop checking if cells are empty */ - public function isEmpty(int $definitionOfEmptyFlags = 0, $startRow = 1, $endRow = null): bool + public function isEmpty(int $definitionOfEmptyFlags = 0, int $startRow = 1, ?int $endRow = null): bool { $nullValueCellIsEmpty = (bool) ($definitionOfEmptyFlags & CellIterator::TREAT_NULL_VALUE_AS_EMPTY_CELL); $emptyStringCellIsEmpty = (bool) ($definitionOfEmptyFlags & CellIterator::TREAT_EMPTY_STRING_AS_EMPTY_CELL); diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index 2d77835e91..11575aae40 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -39,7 +39,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, bool $iterateOnlyExistingCells = false) + public function __construct(Worksheet $worksheet, string $columnIndex = 'A', int $startRow = 1, ?int $endRow = null, bool $iterateOnlyExistingCells = false) { // Set subject $this->worksheet = $worksheet; @@ -73,7 +73,7 @@ public function resetStart(int $startRow = 1): static * * @return $this */ - public function resetEnd($endRow = null): static + public function resetEnd(?int $endRow = null): static { $this->endRow = $endRow ?: $this->worksheet->getHighestRow(); $this->adjustForExistingOnlyRange(); diff --git a/src/PhpSpreadsheet/Worksheet/ColumnDimension.php b/src/PhpSpreadsheet/Worksheet/ColumnDimension.php index 5b76d1f44b..8ac405becf 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnDimension.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnDimension.php @@ -29,7 +29,7 @@ class ColumnDimension extends Dimension * * @param ?string $index Character column index */ - public function __construct($index = 'A') + public function __construct(?string $index = 'A') { // Initialise values $this->columnIndex = $index; diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index 5bd7b70234..f97c4fb9f8 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -39,7 +39,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, string $startColumn = 'A', $endColumn = null) + public function __construct(Worksheet $worksheet, string $startColumn = 'A', ?string $endColumn = null) { // Set subject $this->worksheet = $worksheet; @@ -87,7 +87,7 @@ public function resetStart(string $startColumn = 'A'): static * * @return $this */ - public function resetEnd($endColumn = null): static + public function resetEnd(?string $endColumn = null): static { $endColumn = $endColumn ?: $this->worksheet->getHighestColumn(); $this->endColumnIndex = Coordinate::columnIndexFromString($endColumn); diff --git a/src/PhpSpreadsheet/Worksheet/Dimension.php b/src/PhpSpreadsheet/Worksheet/Dimension.php index 76eeb1bfe0..e37538dd72 100644 --- a/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -31,7 +31,7 @@ abstract class Dimension * * @param int $initialValue Numeric row index */ - public function __construct($initialValue = null) + public function __construct(?int $initialValue = null) { // set dimension as unformatted by default $this->xfIndex = $initialValue; diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index f0dcc5e493..5cb1b3993c 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -92,7 +92,7 @@ public function getPath(): string * * @return $this */ - public function setPath($path, $verifyFile = true, $zip = null): static + public function setPath(string $path, bool $verifyFile = true, ?ZipArchive $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 diff --git a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php index 4b6c1aef62..e002d5f5a8 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php @@ -82,11 +82,9 @@ public function getVisible(): bool /** * Set Visible. * - * @param bool $visible - * * @return $this */ - public function setVisible($visible): static + public function setVisible(bool $visible): static { $this->visible = $visible; @@ -104,11 +102,9 @@ public function getBlurRadius(): int /** * Set Blur radius. * - * @param int $blurRadius - * * @return $this */ - public function setBlurRadius($blurRadius): static + public function setBlurRadius(int $blurRadius): static { $this->blurRadius = $blurRadius; @@ -126,11 +122,9 @@ public function getDistance(): int /** * Set Shadow distance. * - * @param int $distance - * * @return $this */ - public function setDistance($distance): static + public function setDistance(int $distance): static { $this->distance = $distance; @@ -148,11 +142,9 @@ public function getDirection(): int /** * Set Shadow direction (in degrees). * - * @param int $direction - * * @return $this */ - public function setDirection($direction): static + public function setDirection(int $direction): static { $this->direction = $direction; @@ -170,11 +162,9 @@ public function getAlignment(): string /** * Set Shadow alignment. * - * @param string $alignment - * * @return $this */ - public function setAlignment($alignment): static + public function setAlignment(string $alignment): static { $this->alignment = $alignment; @@ -212,11 +202,9 @@ public function getAlpha(): int /** * Set Alpha. * - * @param int $alpha - * * @return $this */ - public function setAlpha($alpha): static + public function setAlpha(int $alpha): static { $this->alpha = $alpha; diff --git a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php index 61f16feb0a..68716c060e 100644 --- a/src/PhpSpreadsheet/Worksheet/HeaderFooter.php +++ b/src/PhpSpreadsheet/Worksheet/HeaderFooter.php @@ -148,11 +148,9 @@ public function getOddHeader(): string /** * Set OddHeader. * - * @param string $oddHeader - * * @return $this */ - public function setOddHeader($oddHeader): static + public function setOddHeader(string $oddHeader): static { $this->oddHeader = $oddHeader; @@ -170,11 +168,9 @@ public function getOddFooter(): string /** * Set OddFooter. * - * @param string $oddFooter - * * @return $this */ - public function setOddFooter($oddFooter): static + public function setOddFooter(string $oddFooter): static { $this->oddFooter = $oddFooter; @@ -192,11 +188,9 @@ public function getEvenHeader(): string /** * Set EvenHeader. * - * @param string $eventHeader - * * @return $this */ - public function setEvenHeader($eventHeader): static + public function setEvenHeader(string $eventHeader): static { $this->evenHeader = $eventHeader; @@ -214,11 +208,9 @@ public function getEvenFooter(): string /** * Set EvenFooter. * - * @param string $evenFooter - * * @return $this */ - public function setEvenFooter($evenFooter): static + public function setEvenFooter(string $evenFooter): static { $this->evenFooter = $evenFooter; @@ -236,11 +228,9 @@ public function getFirstHeader(): string /** * Set FirstHeader. * - * @param string $firstHeader - * * @return $this */ - public function setFirstHeader($firstHeader): static + public function setFirstHeader(string $firstHeader): static { $this->firstHeader = $firstHeader; @@ -258,11 +248,9 @@ public function getFirstFooter(): string /** * Set FirstFooter. * - * @param string $firstFooter - * * @return $this */ - public function setFirstFooter($firstFooter): static + public function setFirstFooter(string $firstFooter): static { $this->firstFooter = $firstFooter; @@ -280,11 +268,9 @@ public function getDifferentOddEven(): bool /** * Set DifferentOddEven. * - * @param bool $differentOddEvent - * * @return $this */ - public function setDifferentOddEven($differentOddEvent): static + public function setDifferentOddEven(bool $differentOddEvent): static { $this->differentOddEven = $differentOddEvent; @@ -302,11 +288,9 @@ public function getDifferentFirst(): bool /** * Set DifferentFirst. * - * @param bool $differentFirst - * * @return $this */ - public function setDifferentFirst($differentFirst): static + public function setDifferentFirst(bool $differentFirst): static { $this->differentFirst = $differentFirst; @@ -324,11 +308,9 @@ public function getScaleWithDocument(): bool /** * Set ScaleWithDocument. * - * @param bool $scaleWithDocument - * * @return $this */ - public function setScaleWithDocument($scaleWithDocument): static + public function setScaleWithDocument(bool $scaleWithDocument): static { $this->scaleWithDocument = $scaleWithDocument; @@ -346,11 +328,9 @@ public function getAlignWithMargins(): bool /** * Set AlignWithMargins. * - * @param bool $alignWithMargins - * * @return $this */ - public function setAlignWithMargins($alignWithMargins): static + public function setAlignWithMargins(bool $alignWithMargins): static { $this->alignWithMargins = $alignWithMargins; @@ -360,11 +340,9 @@ public function setAlignWithMargins($alignWithMargins): static /** * Add header/footer image. * - * @param string $location - * * @return $this */ - public function addImage(HeaderFooterDrawing $image, $location = self::IMAGE_HEADER_LEFT): static + public function addImage(HeaderFooterDrawing $image, string $location = self::IMAGE_HEADER_LEFT): static { $this->headerFooterImages[$location] = $image; @@ -374,11 +352,9 @@ public function addImage(HeaderFooterDrawing $image, $location = self::IMAGE_HEA /** * Remove header/footer image. * - * @param string $location - * * @return $this */ - public function removeImage($location = self::IMAGE_HEADER_LEFT): static + public function removeImage(string $location = self::IMAGE_HEADER_LEFT): static { if (isset($this->headerFooterImages[$location])) { unset($this->headerFooterImages[$location]); diff --git a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php index f6f4c29784..3b7c36ba30 100644 --- a/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php +++ b/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php @@ -276,7 +276,7 @@ public function getRenderingFunction(): string * * @return $this */ - public function setRenderingFunction($value): static + public function setRenderingFunction(string $value): static { $this->renderingFunction = $value; @@ -298,7 +298,7 @@ public function getMimeType(): string * * @return $this */ - public function setMimeType($value): static + public function setMimeType(string $value): static { $this->mimeType = $value; diff --git a/src/PhpSpreadsheet/Worksheet/PageMargins.php b/src/PhpSpreadsheet/Worksheet/PageMargins.php index 6a13a6ebb1..1b3767a7ca 100644 --- a/src/PhpSpreadsheet/Worksheet/PageMargins.php +++ b/src/PhpSpreadsheet/Worksheet/PageMargins.php @@ -52,11 +52,9 @@ public function getLeft(): float /** * Set Left. * - * @param float $left - * * @return $this */ - public function setLeft($left): static + public function setLeft(float $left): static { $this->left = $left; @@ -74,11 +72,9 @@ public function getRight(): float /** * Set Right. * - * @param float $right - * * @return $this */ - public function setRight($right): static + public function setRight(float $right): static { $this->right = $right; @@ -96,11 +92,9 @@ public function getTop(): float /** * Set Top. * - * @param float $top - * * @return $this */ - public function setTop($top): static + public function setTop(float $top): static { $this->top = $top; @@ -118,11 +112,9 @@ public function getBottom(): float /** * Set Bottom. * - * @param float $bottom - * * @return $this */ - public function setBottom($bottom): static + public function setBottom(float $bottom): static { $this->bottom = $bottom; @@ -140,11 +132,9 @@ public function getHeader(): float /** * Set Header. * - * @param float $header - * * @return $this */ - public function setHeader($header): static + public function setHeader(float $header): static { $this->header = $header; @@ -162,11 +152,9 @@ public function getFooter(): float /** * Set Footer. * - * @param float $footer - * * @return $this */ - public function setFooter($footer): static + public function setFooter(float $footer): static { $this->footer = $footer; diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 1d6aee3d67..58ea06f1ef 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -268,7 +268,7 @@ public function getPaperSize(): int * * @return $this */ - public function setPaperSize($paperSize): static + public function setPaperSize(int $paperSize): static { $this->paperSize = $paperSize; @@ -306,7 +306,7 @@ public function getOrientation(): string * * @return $this */ - public function setOrientation($orientation): static + public function setOrientation(string $orientation): static { if ($orientation === self::ORIENTATION_LANDSCAPE || $orientation === self::ORIENTATION_PORTRAIT || $orientation === self::ORIENTATION_DEFAULT) { $this->orientation = $orientation; @@ -340,12 +340,11 @@ public function getScale(): ?int * Print scaling. Valid values range from 10 to 400 * This setting is overridden when fitToWidth and/or fitToHeight are in use. * - * @param null|int $scale * @param bool $update Update fitToPage so scaling applies rather than fitToHeight / fitToWidth * * @return $this */ - public function setScale($scale, $update = true): static + public function setScale(?int $scale, bool $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 @@ -372,11 +371,9 @@ public function getFitToPage(): bool /** * Set Fit To Page. * - * @param bool $fitToPage - * * @return $this */ - public function setFitToPage($fitToPage): static + public function setFitToPage(bool $fitToPage): static { $this->fitToPage = $fitToPage; @@ -394,12 +391,11 @@ public function getFitToHeight(): ?int /** * Set Fit To Height. * - * @param null|int $fitToHeight * @param bool $update Update fitToPage so it applies rather than scaling * * @return $this */ - public function setFitToHeight($fitToHeight, $update = true): static + public function setFitToHeight(?int $fitToHeight, bool $update = true): static { $this->fitToHeight = $fitToHeight; if ($update) { @@ -420,12 +416,11 @@ public function getFitToWidth(): ?int /** * Set Fit To Width. * - * @param null|int $value * @param bool $update Update fitToPage so it applies rather than scaling * * @return $this */ - public function setFitToWidth($value, $update = true): static + public function setFitToWidth(?int $value, bool $update = true): static { $this->fitToWidth = $value; if ($update) { @@ -481,7 +476,7 @@ public function setColumnsToRepeatAtLeft(array $columnsToRepeatAtLeft): static * * @return $this */ - public function setColumnsToRepeatAtLeftByStartAndEnd($start, $end): static + public function setColumnsToRepeatAtLeftByStartAndEnd(string $start, string $end): static { $this->columnsToRepeatAtLeft = [$start, $end]; @@ -534,7 +529,7 @@ public function setRowsToRepeatAtTop(array $rowsToRepeatAtTop): static * * @return $this */ - public function setRowsToRepeatAtTopByStartAndEnd($start, $end): static + public function setRowsToRepeatAtTopByStartAndEnd(int $start, int $end): static { $this->rowsToRepeatAtTop = [$start, $end]; @@ -552,11 +547,9 @@ public function getHorizontalCentered(): bool /** * Set center page horizontally. * - * @param bool $value - * * @return $this */ - public function setHorizontalCentered($value): static + public function setHorizontalCentered(bool $value): static { $this->horizontalCentered = $value; @@ -574,11 +567,9 @@ public function getVerticalCentered(): bool /** * Set center page vertically. * - * @param bool $value - * * @return $this */ - public function setVerticalCentered($value): static + public function setVerticalCentered(bool $value): static { $this->verticalCentered = $value; @@ -593,7 +584,7 @@ public function setVerticalCentered($value): static * Otherwise, the specific range identified by the value of $index will be returned * Print areas are numbered from 1 */ - public function getPrintArea($index = 0): string + public function getPrintArea(int $index = 0): string { if ($index == 0) { return (string) $this->printArea; @@ -614,7 +605,7 @@ public function getPrintArea($index = 0): string * Otherwise, existence of the range identified by the value of $index will be returned * Print areas are numbered from 1 */ - public function isPrintAreaSet($index = 0): bool + public function isPrintAreaSet(int $index = 0): bool { if ($index == 0) { return $this->printArea !== null; @@ -634,7 +625,7 @@ public function isPrintAreaSet($index = 0): bool * * @return $this */ - public function clearPrintArea($index = 0): static + public function clearPrintArea(int $index = 0): static { if ($index == 0) { $this->printArea = null; @@ -652,7 +643,6 @@ public function clearPrintArea($index = 0): static /** * Set print area. e.g. 'A1:D10' or 'A1:D10,G5:M20'. * - * @param string $value * @param int $index Identifier for a specific print area range allowing several ranges to be set * When the method is "O"verwrite, then a positive integer index will overwrite that indexed * entry in the print areas list; a negative index value will identify which entry to @@ -669,7 +659,7 @@ public function clearPrintArea($index = 0): static * * @return $this */ - public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE): static + public function setPrintArea(string $value, int $index = 0, string $method = self::SETPRINTRANGE_OVERWRITE): static { if (str_contains($value, '!')) { throw new PhpSpreadsheetException('Cell coordinate must not specify a worksheet.'); @@ -721,7 +711,6 @@ public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_O /** * Add a new print area (e.g. 'A1:D10' or 'A1:D10,G5:M20') to the list of print areas. * - * @param string $value * @param int $index Identifier for a specific print area range allowing several ranges to be set * A positive index will insert after that indexed entry in the print areas list, while a * negative index will insert before the indexed entry. @@ -731,7 +720,7 @@ public function setPrintArea($value, $index = 0, $method = self::SETPRINTRANGE_O * * @return $this */ - public function addPrintArea($value, $index = -1): static + public function addPrintArea(string $value, int $index = -1): static { return $this->setPrintArea($value, $index, self::SETPRINTRANGE_INSERT); } @@ -759,7 +748,7 @@ public function addPrintArea($value, $index = -1): static * * @return $this */ - public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = 0, $method = self::SETPRINTRANGE_OVERWRITE): static + public function setPrintAreaByColumnAndRow(int $column1, int $row1, int $column2, int $row2, int $index = 0, string $method = self::SETPRINTRANGE_OVERWRITE): static { return $this->setPrintArea( Coordinate::stringFromColumnIndex($column1) . $row1 . ':' . Coordinate::stringFromColumnIndex($column2) . $row2, @@ -784,7 +773,7 @@ public function setPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $in * * @return $this */ - public function addPrintAreaByColumnAndRow($column1, $row1, $column2, $row2, $index = -1): static + public function addPrintAreaByColumnAndRow(int $column1, int $row1, int $column2, int $row2, int $index = -1): static { return $this->setPrintArea( Coordinate::stringFromColumnIndex($column1) . $row1 . ':' . Coordinate::stringFromColumnIndex($column2) . $row2, @@ -810,7 +799,7 @@ public function getFirstPageNumber(): ?int * * @return $this */ - public function setFirstPageNumber($value): static + public function setFirstPageNumber(?int $value): static { $this->firstPageNumber = $value; diff --git a/src/PhpSpreadsheet/Worksheet/Protection.php b/src/PhpSpreadsheet/Worksheet/Protection.php index dda7df3948..520994dcf7 100644 --- a/src/PhpSpreadsheet/Worksheet/Protection.php +++ b/src/PhpSpreadsheet/Worksheet/Protection.php @@ -352,12 +352,11 @@ public function getPassword(): string /** * Set Password. * - * @param string $password * @param bool $alreadyHashed If the password has already been hashed, set this to true * * @return $this */ - public function setPassword($password, $alreadyHashed = false): static + public function setPassword(string $password, bool $alreadyHashed = false): static { if (!$alreadyHashed) { $salt = $this->generateSalt(); diff --git a/src/PhpSpreadsheet/Worksheet/Row.php b/src/PhpSpreadsheet/Worksheet/Row.php index 0f974271ba..e9656b1b02 100644 --- a/src/PhpSpreadsheet/Worksheet/Row.php +++ b/src/PhpSpreadsheet/Worksheet/Row.php @@ -13,10 +13,8 @@ class Row /** * Create a new row. - * - * @param int $rowIndex */ - public function __construct(Worksheet $worksheet, $rowIndex = 1) + public function __construct(Worksheet $worksheet, int $rowIndex = 1) { // Set parent and row index $this->worksheet = $worksheet; @@ -45,7 +43,7 @@ public function getRowIndex(): int * @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 getCellIterator($startColumn = 'A', $endColumn = null, bool $iterateOnlyExistingCells = false): RowCellIterator + public function getCellIterator(string $startColumn = 'A', ?string $endColumn = null, bool $iterateOnlyExistingCells = false): RowCellIterator { return new RowCellIterator($this->worksheet, $this->rowIndex, $startColumn, $endColumn, $iterateOnlyExistingCells); } @@ -56,7 +54,7 @@ public function getCellIterator($startColumn = 'A', $endColumn = null, bool $ite * @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 getColumnIterator($startColumn = 'A', $endColumn = null, bool $iterateOnlyExistingCells = false): RowCellIterator + public function getColumnIterator(string $startColumn = 'A', ?string $endColumn = null, bool $iterateOnlyExistingCells = false): RowCellIterator { return $this->getCellIterator($startColumn, $endColumn, $iterateOnlyExistingCells); } @@ -80,7 +78,7 @@ public function getColumnIterator($startColumn = 'A', $endColumn = null, bool $i * @param string $startColumn The column address at which to start checking if cells are empty * @param string $endColumn Optionally, the column address at which to stop checking if cells are empty */ - public function isEmpty(int $definitionOfEmptyFlags = 0, $startColumn = 'A', $endColumn = null): bool + public function isEmpty(int $definitionOfEmptyFlags = 0, string $startColumn = 'A', ?string $endColumn = null): bool { $nullValueCellIsEmpty = (bool) ($definitionOfEmptyFlags & CellIterator::TREAT_NULL_VALUE_AS_EMPTY_CELL); $emptyStringCellIsEmpty = (bool) ($definitionOfEmptyFlags & CellIterator::TREAT_EMPTY_STRING_AS_EMPTY_CELL); diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 4524e54168..fdcfcbfb85 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -39,7 +39,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, bool $iterateOnlyExistingCells = false) + public function __construct(Worksheet $worksheet, int $rowIndex = 1, string $startColumn = 'A', ?string $endColumn = null, bool $iterateOnlyExistingCells = false) { // Set subject and row index $this->worksheet = $worksheet; @@ -73,7 +73,7 @@ public function resetStart(string $startColumn = 'A'): static * * @return $this */ - public function resetEnd($endColumn = null): static + public function resetEnd(?string $endColumn = null): static { $endColumn = $endColumn ?: $this->worksheet->getHighestColumn(); $this->endColumnIndex = Coordinate::columnIndexFromString($endColumn); diff --git a/src/PhpSpreadsheet/Worksheet/RowDimension.php b/src/PhpSpreadsheet/Worksheet/RowDimension.php index b31eea96a7..e94a63b303 100644 --- a/src/PhpSpreadsheet/Worksheet/RowDimension.php +++ b/src/PhpSpreadsheet/Worksheet/RowDimension.php @@ -28,7 +28,7 @@ class RowDimension extends Dimension * * @param ?int $index Numeric row index */ - public function __construct($index = 0) + public function __construct(?int $index = 0) { // Initialise values $this->rowIndex = $index; @@ -79,7 +79,7 @@ public function getRowHeight(?string $unitOfMeasure = null): float * * @return $this */ - public function setRowHeight($height, ?string $unitOfMeasure = null): static + public function setRowHeight(float $height, ?string $unitOfMeasure = null): static { $this->height = ($unitOfMeasure === null || $height < 0) ? $height diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index 1a256879d2..4470526146 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -37,7 +37,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, int $startRow = 1, $endRow = null) + public function __construct(Worksheet $subject, int $startRow = 1, ?int $endRow = null) { // Set subject $this->subject = $subject; @@ -81,7 +81,7 @@ public function resetStart(int $startRow = 1): static * * @return $this */ - public function resetEnd($endRow = null): static + public function resetEnd(?int $endRow = null): static { $this->endRow = $endRow ?: $this->subject->getHighestRow(); diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index 1fdf7d1460..78459e3e29 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -75,7 +75,7 @@ public function getZoomScale(): ?int * * @return $this */ - public function setZoomScale($zoomScale): static + public function setZoomScale(?int $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 @@ -106,7 +106,7 @@ public function getZoomScaleNormal(): ?int * * @return $this */ - public function setZoomScaleNormal($zoomScaleNormal): static + public function setZoomScaleNormal(?int $zoomScaleNormal): static { if ($zoomScaleNormal === null || $zoomScaleNormal >= 1) { $this->zoomScaleNormal = $zoomScaleNormal; @@ -119,10 +119,8 @@ public function setZoomScaleNormal($zoomScaleNormal): static /** * Set ShowZeroes setting. - * - * @param bool $showZeros */ - public function setShowZeros($showZeros): void + public function setShowZeros(bool $showZeros): void { $this->showZeros = $showZeros; } @@ -152,7 +150,7 @@ public function getView(): string * * @return $this */ - public function setView($sheetViewType): static + public function setView(?string $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 c5699e4c82..2ffac1bc78 100644 --- a/src/PhpSpreadsheet/Worksheet/Table.php +++ b/src/PhpSpreadsheet/Worksheet/Table.php @@ -407,7 +407,7 @@ public function getColumnOffset(string $column): int * * @param string $column Column name (e.g. A) */ - public function getColumn($column): Table\Column + public function getColumn(string $column): Table\Column { $this->isColumnInRange($column); @@ -423,7 +423,7 @@ public function getColumn($column): Table\Column * * @param int $columnOffset Column offset within range (starting from 0) */ - public function getColumnByOffset($columnOffset): Table\Column + public function getColumnByOffset(int $columnOffset): Table\Column { [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($this->range); $pColumn = Coordinate::stringFromColumnIndex($rangeStart[0] + $columnOffset); @@ -464,7 +464,7 @@ public function setColumn($columnObjectOrString): self * * @param string $column Column name (e.g. A) */ - public function clearColumn($column): self + public function clearColumn(string $column): self { $this->isColumnInRange($column); @@ -485,7 +485,7 @@ public function clearColumn($column): self * @param string $fromColumn Column name (e.g. A) * @param string $toColumn Column name (e.g. B) */ - public function shiftColumn($fromColumn, $toColumn): self + public function shiftColumn(string $fromColumn, string $toColumn): self { $fromColumn = strtoupper($fromColumn); $toColumn = strtoupper($toColumn); diff --git a/src/PhpSpreadsheet/Worksheet/Table/Column.php b/src/PhpSpreadsheet/Worksheet/Table/Column.php index 65e6363643..56832b0c15 100644 --- a/src/PhpSpreadsheet/Worksheet/Table/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Table/Column.php @@ -51,7 +51,7 @@ class Column * @param string $column Column (e.g. A) * @param Table $table Table for this column */ - public function __construct($column, ?Table $table = null) + public function __construct(string $column, ?Table $table = null) { $this->columnIndex = $column; $this->table = $table; @@ -70,7 +70,7 @@ public function getColumnIndex(): string * * @param string $column Column (e.g. A) */ - public function setColumnIndex($column): self + public function setColumnIndex(string $column): self { // Uppercase coordinate $column = strtoupper($column); diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 963f534516..3eab4b624d 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -320,10 +320,8 @@ class Worksheet implements IComparable /** * Create a new worksheet. - * - * @param string $title */ - public function __construct(?Spreadsheet $parent = null, $title = 'Worksheet') + public function __construct(?Spreadsheet $parent = null, string $title = 'Worksheet') { // Set parent and title $this->parent = $parent; @@ -406,7 +404,7 @@ public static function getInvalidCharacters(): array * * @return string The valid string */ - private static function checkSheetCodeName($sheetCodeName): string + private static function checkSheetCodeName(string $sheetCodeName): string { $charCount = Shared\StringHelper::countCharacters($sheetCodeName); if ($charCount == 0) { @@ -436,7 +434,7 @@ private static function checkSheetCodeName($sheetCodeName): string * * @return string The valid string */ - private static function checkSheetTitle($sheetTitle): string + private static function checkSheetTitle(string $sheetTitle): string { // Some of the printable ASCII characters are invalid: * : / \ ? [ ] if (str_replace(self::$invalidCharacters, '', $sheetTitle) !== $sheetTitle) { @@ -458,7 +456,7 @@ private static function checkSheetTitle($sheetTitle): string * * @return string[] */ - public function getCoordinates($sorted = true): array + public function getCoordinates(bool $sorted = true): array { if ($this->cellCollection == null) { return []; @@ -561,7 +559,7 @@ public function getChartCount(): int * * @return Chart|false */ - public function getChartByIndex($index) + public function getChartByIndex(?string $index) { $chartCount = count($this->chartCollection); if ($chartCount == 0) { @@ -599,7 +597,7 @@ public function getChartNames(): array * * @return Chart|false */ - public function getChartByName($chartName) + public function getChartByName(string $chartName) { foreach ($this->chartCollection as $index => $chart) { if ($chart->getName() == $chartName) { @@ -836,7 +834,7 @@ public function getTitle(): string * * @return $this */ - public function setTitle($title, $updateFormulaCellReferences = true, $validate = true): static + public function setTitle(string $title, bool $updateFormulaCellReferences = true, bool $validate = true): static { // Is this a 'rename' or not? if ($this->getTitle() == $title) { @@ -911,7 +909,7 @@ public function getSheetState(): string * * @return $this */ - public function setSheetState($value): static + public function setSheetState(string $value): static { $this->sheetState = $value; @@ -1057,7 +1055,7 @@ public function getHighestDataColumn($row = null): string * * @return int Highest row number */ - public function getHighestRow($column = null): int + public function getHighestRow(?string $column = null): int { if ($column === null) { return $this->cachedHighestRow; @@ -1074,7 +1072,7 @@ public function getHighestRow($column = null): int * * @return int Highest row number that contains data */ - public function getHighestDataRow($column = null): int + public function getHighestDataRow(?string $column = null): int { return $this->getCellCollection()->getHighestRow($column); } @@ -1122,7 +1120,7 @@ public function setCellValue($coordinate, mixed $value, ?IValueBinder $binder = * * @return $this */ - public function setCellValueByColumnAndRow($columnIndex, $row, mixed $value, ?IValueBinder $binder = null): static + public function setCellValueByColumnAndRow(int $columnIndex, int $row, mixed $value, ?IValueBinder $binder = null): static { $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValue($value, $binder); @@ -1176,7 +1174,7 @@ public function setCellValueExplicit($coordinate, mixed $value, string $dataType * * @return $this */ - public function setCellValueExplicitByColumnAndRow($columnIndex, $row, mixed $value, string $dataType): static + public function setCellValueExplicitByColumnAndRow(int $columnIndex, int $row, mixed $value, string $dataType): static { $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValueExplicit($value, $dataType); @@ -1275,7 +1273,7 @@ private function getWorksheetAndCoordinate(string $coordinate): array * * @return null|Cell Cell that was found or null */ - private function getCellOrNull($coordinate): ?Cell + private function getCellOrNull(string $coordinate): ?Cell { // Check cell collection if ($this->getCellCollection()->has($coordinate)) { @@ -1303,7 +1301,7 @@ private function getCellOrNull($coordinate): ?Cell * the "active" cell, and any previous assignment becomes a disconnected reference because * the active cell has changed. */ - public function getCellByColumnAndRow($columnIndex, $row): Cell + public function getCellByColumnAndRow(int $columnIndex, int $row): Cell { return $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row); } @@ -1384,7 +1382,7 @@ public function cellExists($coordinate): bool * @param int $columnIndex Numeric column coordinate of the cell * @param int $row Numeric row coordinate of the cell */ - public function cellExistsByColumnAndRow($columnIndex, $row): bool + public function cellExistsByColumnAndRow(int $columnIndex, int $row): bool { return $this->cellExists(Coordinate::stringFromColumnIndex($columnIndex) . $row); } @@ -1494,7 +1492,7 @@ public function getStyle($cellCoordinate): Style * @param null|int $columnIndex2 Numeric column coordinate of the range cell * @param null|int $row2 Numeric row coordinate of the range cell */ - public function getStyleByColumnAndRow($columnIndex1, $row1, $columnIndex2 = null, $row2 = null): Style + public function getStyleByColumnAndRow(int $columnIndex1, int $row1, ?int $columnIndex2 = null, ?int $row2 = null): Style { if ($columnIndex2 !== null && $row2 !== null) { $cellRange = new CellRange( @@ -1558,7 +1556,7 @@ public function getConditionalRange(string $coordinate): ?string * If a range of cells is specified, then true will only be returned if the range matches the entire * range of the conditional. */ - public function conditionalStylesExists($coordinate): bool + public function conditionalStylesExists(string $coordinate): bool { $coordinate = strtoupper($coordinate); if (str_contains($coordinate, ':')) { @@ -1582,7 +1580,7 @@ public function conditionalStylesExists($coordinate): bool * * @return $this */ - public function removeConditionalStyles($coordinate): static + public function removeConditionalStyles(string $coordinate): static { unset($this->conditionalStylesCollection[strtoupper($coordinate)]); @@ -1605,7 +1603,7 @@ public function getConditionalStylesCollection(): array * * @return $this */ - public function setConditionalStyles($coordinate, $styles): static + public function setConditionalStyles(string $coordinate, array $styles): static { $this->conditionalStylesCollection[strtoupper($coordinate)] = $styles; @@ -1702,7 +1700,7 @@ public function duplicateConditionalStyle(array $styles, string $range = ''): st * * @return $this */ - public function setBreak($coordinate, $break, int $max = -1): static + public function setBreak($coordinate, int $break, int $max = -1): static { $cellAddress = Functions::trimSheetFromCellReference(Validations::validateCellAddress($coordinate)); @@ -1731,7 +1729,7 @@ public function setBreak($coordinate, $break, int $max = -1): static * * @return $this */ - public function setBreakByColumnAndRow($columnIndex, $row, $break): static + public function setBreakByColumnAndRow(int $columnIndex, int $row, int $break): static { return $this->setBreak(Coordinate::stringFromColumnIndex($columnIndex) . $row, $break); } @@ -1818,7 +1816,7 @@ public function getColumnBreaks(): array * * @return $this */ - public function mergeCells($range, $behaviour = self::MERGE_CELL_CONTENT_EMPTY): static + public function mergeCells($range, string $behaviour = self::MERGE_CELL_CONTENT_EMPTY): static { $range = Functions::trimSheetFromCellReference(Validations::validateCellRange($range)); @@ -1950,7 +1948,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): static + public function mergeCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2, string $behaviour = self::MERGE_CELL_CONTENT_EMPTY): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2002,7 +2000,7 @@ public function unmergeCells($range): static * * @return $this */ - public function unmergeCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2): static + public function unmergeCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2048,7 +2046,7 @@ public function setMergeCells(array $mergeCells): static * * @return $this */ - public function protectCells($range, $password, $alreadyHashed = false): static + public function protectCells($range, string $password, bool $alreadyHashed = false): static { $range = Functions::trimSheetFromCellReference(Validations::validateCellOrCellRange($range)); @@ -2078,7 +2076,7 @@ public function protectCells($range, $password, $alreadyHashed = false): static * * @return $this */ - public function protectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2, $password, $alreadyHashed = false): static + public function protectCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2, string $password, bool $alreadyHashed = false): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2126,7 +2124,7 @@ public function unprotectCells($range): static * * @return $this */ - public function unprotectCellsByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2): static + public function unprotectCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2193,7 +2191,7 @@ public function setAutoFilter($autoFilterOrRange): static * * @return $this */ - public function setAutoFilterByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2): static + public function setAutoFilterByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2): static { $cellRange = new CellRange( CellAddress::fromColumnAndRow($columnIndex1, $row1), @@ -2404,7 +2402,7 @@ public function setTopLeftCell(string $topLeftCell): self * * @return $this */ - public function freezePaneByColumnAndRow($columnIndex, $row): static + public function freezePaneByColumnAndRow(int $columnIndex, int $row): static { return $this->freezePane(Coordinate::stringFromColumnIndex($columnIndex) . $row); } @@ -2923,7 +2921,7 @@ public function getComment($cellCoordinate): Comment * @param int $columnIndex Numeric column coordinate of the cell * @param int $row Numeric row coordinate of the cell */ - public function getCommentByColumnAndRow($columnIndex, $row): Comment + public function getCommentByColumnAndRow(int $columnIndex, int $row): Comment { return $this->getComment(Coordinate::stringFromColumnIndex($columnIndex) . $row); } @@ -2953,7 +2951,7 @@ public function getSelectedCells(): string * * @return $this */ - public function setSelectedCell($coordinate): static + public function setSelectedCell(string $coordinate): static { return $this->setSelectedCells($coordinate); } @@ -3018,7 +3016,7 @@ private function setSelectedCellsActivePane(): void * * @return $this */ - public function setSelectedCellByColumnAndRow($columnIndex, $row): static + public function setSelectedCellByColumnAndRow(int $columnIndex, int $row): static { return $this->setSelectedCells(Coordinate::stringFromColumnIndex($columnIndex) . $row); } @@ -3038,7 +3036,7 @@ public function getRightToLeft(): bool * * @return $this */ - public function setRightToLeft($value): static + public function setRightToLeft(bool $value): static { $this->rightToLeft = $value; @@ -3055,7 +3053,7 @@ public function setRightToLeft($value): static * * @return $this */ - public function fromArray(array $source, mixed $nullValue = null, $startCell = 'A1', $strictNullComparison = false): static + public function fromArray(array $source, mixed $nullValue = null, string $startCell = 'A1', bool $strictNullComparison = false): static { // Convert a 1-D array to 2-D (for ease of looping) if (!is_array(end($source))) { @@ -3277,7 +3275,7 @@ 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 */ - public function getRowIterator($startRow = 1, $endRow = null): RowIterator + public function getRowIterator(int $startRow = 1, ?int $endRow = null): RowIterator { return new RowIterator($this, $startRow, $endRow); } @@ -3288,7 +3286,7 @@ public function getRowIterator($startRow = 1, $endRow = null): RowIterator * @param string $startColumn The column address at which to start iterating * @param string $endColumn The column address at which to stop iterating */ - public function getColumnIterator($startColumn = 'A', $endColumn = null): ColumnIterator + public function getColumnIterator(string $startColumn = 'A', ?string $endColumn = null): ColumnIterator { return new ColumnIterator($this, $startColumn, $endColumn); } @@ -3360,7 +3358,7 @@ public function getHashCode(): string * * @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): array|null|string + public static function extractSheetTitle(?string $range, bool $returnRange = false): array|null|string { if (empty($range)) { return $returnRange ? [null, null] : null; @@ -3383,7 +3381,7 @@ public static function extractSheetTitle($range, $returnRange = false): array|nu * * @param string $cellCoordinate Cell coordinate to get hyperlink for, eg: 'A1' */ - public function getHyperlink($cellCoordinate): Hyperlink + public function getHyperlink(string $cellCoordinate): Hyperlink { // return hyperlink if we already have one if (isset($this->hyperlinkCollection[$cellCoordinate])) { @@ -3403,7 +3401,7 @@ public function getHyperlink($cellCoordinate): Hyperlink * * @return $this */ - public function setHyperlink($cellCoordinate, ?Hyperlink $hyperlink = null): static + public function setHyperlink(string $cellCoordinate, ?Hyperlink $hyperlink = null): static { if ($hyperlink === null) { unset($this->hyperlinkCollection[$cellCoordinate]); @@ -3419,7 +3417,7 @@ public function setHyperlink($cellCoordinate, ?Hyperlink $hyperlink = null): sta * * @param string $coordinate eg: 'A1' */ - public function hyperlinkExists($coordinate): bool + public function hyperlinkExists(string $coordinate): bool { return isset($this->hyperlinkCollection[$coordinate]); } @@ -3439,7 +3437,7 @@ public function getHyperlinkCollection(): array * * @param string $cellCoordinate Cell coordinate to get data validation for, eg: 'A1' */ - public function getDataValidation($cellCoordinate): DataValidation + public function getDataValidation(string $cellCoordinate): DataValidation { // return data validation if we already have one if (isset($this->dataValidationCollection[$cellCoordinate])) { @@ -3459,7 +3457,7 @@ public function getDataValidation($cellCoordinate): DataValidation * * @return $this */ - public function setDataValidation($cellCoordinate, ?DataValidation $dataValidation = null): static + public function setDataValidation(string $cellCoordinate, ?DataValidation $dataValidation = null): static { if ($dataValidation === null) { unset($this->dataValidationCollection[$cellCoordinate]); @@ -3475,7 +3473,7 @@ public function setDataValidation($cellCoordinate, ?DataValidation $dataValidati * * @param string $coordinate eg: 'A1' */ - public function dataValidationExists($coordinate): bool + public function dataValidationExists(string $coordinate): bool { return isset($this->dataValidationCollection[$coordinate]); } @@ -3493,11 +3491,9 @@ public function getDataValidationCollection(): array /** * Accepts a range, returning it as a range that falls within the current highest row and column of the worksheet. * - * @param string $range - * * @return string Adjusted range value */ - public function shrinkRangeToFit($range): string + public function shrinkRangeToFit(string $range): string { $maxCol = $this->getHighestColumn(); $maxRow = $this->getHighestRow(); @@ -3671,7 +3667,7 @@ public function __clone() * * @return $this */ - public function setCodeName($codeName, $validate = true): static + public function setCodeName(string $codeName, bool $validate = true): static { // Is this a 'rename' or not? if ($this->getCodeName() == $codeName) { diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index c7ae9bf501..9056f17578 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -208,7 +208,7 @@ public function setEditHtmlCallback(?callable $callback): void * * @param string $vAlign Vertical alignment */ - private function mapVAlign($vAlign): string + private function mapVAlign(string $vAlign): string { return Alignment::VERTICAL_ALIGNMENT_FOR_HTML[$vAlign] ?? ''; } @@ -218,7 +218,7 @@ private function mapVAlign($vAlign): string * * @param string $hAlign Horizontal alignment */ - private function mapHAlign($hAlign): string + private function mapHAlign(string $hAlign): string { return Alignment::HORIZONTAL_ALIGNMENT_FOR_HTML[$hAlign] ?? ''; } @@ -263,7 +263,7 @@ public function getSheetIndex(): ?int * * @return $this */ - public function setSheetIndex($sheetIndex): static + public function setSheetIndex(int $sheetIndex): static { $this->sheetIndex = $sheetIndex; @@ -285,7 +285,7 @@ public function getGenerateSheetNavigationBlock(): bool * * @return $this */ - public function setGenerateSheetNavigationBlock($generateSheetNavigationBlock): static + public function setGenerateSheetNavigationBlock(bool $generateSheetNavigationBlock): static { $this->generateSheetNavigationBlock = (bool) $generateSheetNavigationBlock; @@ -326,7 +326,7 @@ private static function generateMeta(?string $val, string $desc): string * * @param bool $includeStyles Include styles? */ - public function generateHTMLHeader($includeStyles = false): string + public function generateHTMLHeader(bool $includeStyles = false): string { // Construct HTML $properties = $this->spreadsheet->getProperties(); @@ -610,7 +610,7 @@ private function extendRowsForChartsAndImages(Worksheet $worksheet, int $row): s * * @param string $filename file name on local system */ - public static function winFileToUrl($filename, bool $mpdf = false): string + public static function winFileToUrl(string $filename, bool $mpdf = false): string { // Windows filename if (substr($filename, 1, 2) === ':\\') { @@ -784,7 +784,7 @@ private function adjustRendererPositions(Chart $chart, Worksheet $sheet): void * * @param bool $generateSurroundingHTML Generate surrounding HTML tags? (<style> and </style>) */ - public function generateStyles($generateSurroundingHTML = true): string + public function generateStyles(bool $generateSurroundingHTML = true): string { // Build CSS $css = $this->buildCSS($generateSurroundingHTML); @@ -896,7 +896,7 @@ private function buildCssPerSheet(Worksheet $sheet, array &$css): void * * @param bool $generateSurroundingHTML Generate surrounding HTML style? (html { }) */ - public function buildCSS($generateSurroundingHTML = true): array + public function buildCSS(bool $generateSurroundingHTML = true): array { // Cached? if ($this->cssStyles !== null) { @@ -1208,7 +1208,7 @@ private function generateTableFooter(): string * @param int $sheetIndex Sheet index (0-based) * @param int $row row number */ - private function generateRowStart(Worksheet $worksheet, $sheetIndex, int $row): string + private function generateRowStart(Worksheet $worksheet, int $sheetIndex, int $row): string { $html = ''; if (count($worksheet->getBreaks()) > 0) { @@ -1544,11 +1544,9 @@ public function getImagesRoot(): string /** * Set images root. * - * @param string $imagesRoot - * * @return $this */ - public function setImagesRoot($imagesRoot): static + public function setImagesRoot(string $imagesRoot): static { $this->imagesRoot = $imagesRoot; @@ -1566,11 +1564,9 @@ public function getEmbedImages(): bool /** * Set embed images. * - * @param bool $embedImages - * * @return $this */ - public function setEmbedImages($embedImages): static + public function setEmbedImages(bool $embedImages): static { $this->embedImages = $embedImages; @@ -1588,11 +1584,9 @@ public function getUseInlineCss(): bool /** * Set use inline CSS? * - * @param bool $useInlineCss - * * @return $this */ - public function setUseInlineCss($useInlineCss): static + public function setUseInlineCss(bool $useInlineCss): static { $this->useInlineCss = $useInlineCss; @@ -1614,15 +1608,13 @@ public function getUseEmbeddedCSS(): bool /** * Set use embedded CSS? * - * @param bool $useEmbeddedCSS - * * @return $this * * @codeCoverageIgnore * * @deprecated no longer used */ - public function setUseEmbeddedCSS($useEmbeddedCSS): static + public function setUseEmbeddedCSS(bool $useEmbeddedCSS): static { $this->useEmbeddedCSS = $useEmbeddedCSS; @@ -1635,7 +1627,7 @@ public function setUseEmbeddedCSS($useEmbeddedCSS): static * @param string $value Plain formatted value without color * @param string $format Format code */ - public function formatColor($value, $format): string + public function formatColor(string $value, string $format): string { // Color information, e.g. [Red] is always at the beginning $color = null; // initialize diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index 6526890b88..0e93d9bb20 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -131,11 +131,9 @@ public function getFont(): string * 'arialunicid0-korean' * 'arialunicid0-japanese'. * - * @param string $fontName - * * @return $this */ - public function setFont($fontName) + public function setFont(string $fontName) { $this->font = $fontName; @@ -157,7 +155,7 @@ public function getPaperSize(): ?int * * @param int $paperSize Paper size see PageSetup::PAPERSIZE_* */ - public function setPaperSize($paperSize): self + public function setPaperSize(int $paperSize): self { $this->paperSize = $paperSize; @@ -177,7 +175,7 @@ public function getOrientation(): ?string * * @param string $orientation Page orientation see PageSetup::ORIENTATION_* */ - public function setOrientation($orientation): self + public function setOrientation(string $orientation): self { $this->orientation = $orientation; @@ -197,7 +195,7 @@ public function getTempDir(): string * * @param string $temporaryDirectory Temporary storage directory */ - public function setTempDir($temporaryDirectory): self + public function setTempDir(string $temporaryDirectory): self { if (is_dir($temporaryDirectory)) { $this->tempDir = $temporaryDirectory; @@ -211,7 +209,7 @@ public function setTempDir($temporaryDirectory): self /** * Save Spreadsheet to PDF file, pre-save. * - * @param string $filename Name of the file to save as + * @param resource|string $filename Name of the file to save as * * @return resource */ diff --git a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php index 45a55de54d..955cfba592 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Mpdf.php @@ -19,7 +19,7 @@ class Mpdf extends Pdf * * @return \Mpdf\Mpdf implementation */ - protected function createExternalWriterInstance($config): \Mpdf\Mpdf + protected function createExternalWriterInstance(array $config): \Mpdf\Mpdf { return new \Mpdf\Mpdf($config); } @@ -88,10 +88,8 @@ public function save($filename, int $flags = 0): void /** * Convert inches to mm. - * - * @param float $inches */ - private function inchesToMm($inches): float + private function inchesToMm(float $inches): float { return $inches * 25.4; } diff --git a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php index 972964c593..747ebbd50b 100644 --- a/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf/Tcpdf.php @@ -28,7 +28,7 @@ public function __construct(Spreadsheet $spreadsheet) * * @return \TCPDF implementation */ - protected function createExternalWriterInstance($orientation, $unit, $paperSize): \TCPDF + protected function createExternalWriterInstance(string $orientation, string $unit, $paperSize): \TCPDF { return new \TCPDF($orientation, $unit, $paperSize); } diff --git a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php index 5d8121ae23..dc269eff92 100644 --- a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php @@ -101,7 +101,7 @@ public static function getByteOrder(): int * * @param string $data binary data to append */ - protected function append($data): void + protected function append(string $data): void { if (strlen($data) - 4 > $this->limit) { $data = $this->addContinue($data); @@ -115,7 +115,7 @@ protected function append($data): void * * @param string $data binary data to write */ - public function writeData($data): string + public function writeData(string $data): string { if (strlen($data) - 4 > $this->limit) { $data = $this->addContinue($data); @@ -132,7 +132,7 @@ public function writeData($data): string * @param int $type type of BIFF file to write: 0x0005 Workbook, * 0x0010 Worksheet */ - protected function storeBof($type): void + protected function storeBof(int $type): void { $record = 0x0809; // Record identifier (BIFF5-BIFF8) $length = 0x0010; @@ -186,7 +186,7 @@ public function writeEof(): string * * @return string A very convenient string of continue blocks */ - private function addContinue($data): string + private function addContinue(string $data): string { $limit = $this->limit; $record = 0x003C; // Record identifier diff --git a/src/PhpSpreadsheet/Writer/Xls/Font.php b/src/PhpSpreadsheet/Writer/Xls/Font.php index 1a21b22912..9a1aa8a14a 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Font.php +++ b/src/PhpSpreadsheet/Writer/Xls/Font.php @@ -27,10 +27,8 @@ public function __construct(\PhpOffice\PhpSpreadsheet\Style\Font $font) /** * Set the color index. - * - * @param int $colorIndex */ - public function setColorIndex($colorIndex): void + public function setColorIndex(int $colorIndex): void { $this->colorIndex = $colorIndex; } @@ -123,10 +121,8 @@ private static function mapBold(?bool $bold): int /** * Map underline. - * - * @param string $underline */ - private static function mapUnderline($underline): int + private static function mapUnderline(string $underline): int { if (isset(self::$mapUnderline[$underline])) { return self::$mapUnderline[$underline]; diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index 0276e5800d..ca87f541bc 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -573,7 +573,7 @@ private function convertBool(int $num): string * * @return string the converted token */ - private function convertString($string): string + private function convertString(string $string): string { // chop away beggining and ending quotes $string = substr($string, 1, -1); @@ -593,7 +593,7 @@ private function convertString($string): string * * @return string The packed ptg for the function */ - private function convertFunction($token, $num_args): string + private function convertFunction(string $token, int $num_args): string { $args = $this->functions[$token][1]; @@ -610,9 +610,8 @@ private function convertFunction($token, $num_args): string * Convert an Excel range such as A1:D4 to a ptgRefV. * * @param string $range An Excel range in the A1:A2 - * @param int $class */ - private function convertRange2d($range, $class = 0): string + private function convertRange2d(string $range, int $class = 0): string { // TODO: possible class value 0,1,2 check Formula.pm // Split the range into 2 cell refs @@ -649,7 +648,7 @@ private function convertRange2d($range, $class = 0): string * * @return string the packed ptgArea3d token on success */ - private function convertRange3d($token): string + private function convertRange3d(string $token): string { // Split the ref at the ! symbol [$ext_ref, $range] = PhpspreadsheetWorksheet::extractSheetTitle($token, true); @@ -681,7 +680,7 @@ private function convertRange3d($token): string * * @return string The cell in packed() format with the corresponding ptg */ - private function convertRef2d($cell): string + private function convertRef2d(string $cell): string { // Convert the cell reference $cell_array = $this->cellToPackedRowcol($cell); @@ -701,7 +700,7 @@ private function convertRef2d($cell): string * * @return string the packed ptgRef3d token on success */ - private function convertRef3d($cell): string + private function convertRef3d(string $cell): string { // Split the ref at the ! symbol [$ext_ref, $cell] = PhpspreadsheetWorksheet::extractSheetTitle($cell, true); @@ -725,7 +724,7 @@ private function convertRef3d($cell): string * * @return string The error code ptgErr */ - private function convertError($errorCode): string + private function convertError(string $errorCode): string { return match ($errorCode) { '#NULL!' => pack('C', 0x00), @@ -775,7 +774,7 @@ private function convertDefinedName(string $name): string * * @return string The reference index in packed() format on success */ - private function getRefIndex($ext_ref): string + private function getRefIndex(string $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 ' @@ -854,7 +853,7 @@ private function getSheetIndex(string $sheet_name): int * * @see Workbook::addWorksheet */ - public function setExtSheet($name, $index): void + public function setExtSheet(string $name, int $index): void { $this->externalSheets[$name] = $index; } @@ -866,7 +865,7 @@ public function setExtSheet($name, $index): void * * @return array Array containing the row and column in packed() format */ - private function cellToPackedRowcol($cell): array + private function cellToPackedRowcol(string $cell): array { $cell = strtoupper($cell); [$row, $col, $row_rel, $col_rel] = $this->cellToRowcol($cell); @@ -1113,7 +1112,7 @@ private function match(string $token): string * * @return bool true on success */ - public function parse($formula): bool + public function parse(string $formula): bool { $this->currentCharacter = 0; $this->formula = (string) $formula; @@ -1460,7 +1459,7 @@ private function createTree(mixed $value, mixed $left, mixed $right): array * * @return string The tree in reverse polish notation */ - public function toReversePolish($tree = []): string + public function toReversePolish(array $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 c00d545438..2924454fae 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xls/Workbook.php @@ -153,7 +153,7 @@ class Workbook extends BIFFwriter * @param array $colors Colour Table * @param Parser $parser The formula parser created for the Workbook */ - public function __construct(Spreadsheet $spreadsheet, &$str_total, &$str_unique, &$str_table, &$colors, Parser $parser) + public function __construct(Spreadsheet $spreadsheet, int &$str_total, int &$str_unique, array &$str_table, array &$colors, Parser $parser) { // It needs to call its parent's constructor explicitly parent::__construct(); @@ -198,7 +198,7 @@ public function __construct(Spreadsheet $spreadsheet, &$str_total, &$str_unique, * * @return int Index to XF record */ - public function addXfWriter(Style $style, $isStyleXf = false): int + public function addXfWriter(Style $style, bool $isStyleXf = false): int { $xfWriter = new Xf($style); $xfWriter->setIsStyleXf($isStyleXf); @@ -272,7 +272,7 @@ public function addFont(\PhpOffice\PhpSpreadsheet\Style\Font $font): int * * @return int Color index */ - private function addColor($rgb): int + private function addColor(string $rgb): int { if (!isset($this->colors[$rgb])) { $color @@ -696,7 +696,7 @@ private function writeAllDefinedNamesBiff8(): string * * @return string Complete binary record data */ - private function writeDefinedNameBiff8($name, string $formulaData, int $sheetIndex = 0, bool $isBuiltIn = false): string + private function writeDefinedNameBiff8(string $name, string $formulaData, int $sheetIndex = 0, bool $isBuiltIn = false): string { $record = 0x0018; @@ -809,7 +809,7 @@ private function writeWindow1(): void * * @param int $offset Location of worksheet BOF */ - private function writeBoundSheet(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet, $offset): void + private function writeBoundSheet(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $sheet, int $offset): void { $sheetname = $sheet->getTitle(); $record = 0x0085; // Record identifier @@ -890,7 +890,7 @@ private function writeStyle(): void * @param string $format Custom format string * @param int $ifmt Format index code */ - private function writeNumberFormat(string $format, $ifmt): void + private function writeNumberFormat(string $format, int $ifmt): void { $record = 0x041E; // Record identifier diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index 1aa3ce1a5b..c6cb00c021 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -165,7 +165,7 @@ class Worksheet extends BIFFwriter * @param bool $preCalculateFormulas Flag indicating whether formulas should be calculated or just written * @param \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet The worksheet to write */ - public function __construct(&$str_total, &$str_unique, &$str_table, &$colors, Parser $parser, $preCalculateFormulas, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet) + public function __construct(int &$str_total, int &$str_unique, array &$str_table, array &$colors, Parser $parser, bool $preCalculateFormulas, \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $phpSheet) { // It needs to call its parent's constructor explicitly parent::__construct(); @@ -528,7 +528,7 @@ private function writeConditionalFormatting(): void * * @return string Binary data */ - private function writeBIFF8CellRangeAddressFixed($range): string + private function writeBIFF8CellRangeAddressFixed(string $range): string { $explodes = explode(':', $range); @@ -573,7 +573,7 @@ public function getData(): string * * @param int $print Whether to print the headers or not. Defaults to 1 (print). */ - public function printRowColHeaders($print = 1): void + public function printRowColHeaders(int $print = 1): void { $this->printHeaders = $print; } @@ -581,13 +581,8 @@ public function printRowColHeaders($print = 1): void /** * This method sets the properties for outlining and grouping. The defaults * correspond to Excel's defaults. - * - * @param bool $visible - * @param bool $symbols_below - * @param bool $symbols_right - * @param bool $auto_style */ - public function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false): void + public function setOutline(bool $visible = true, bool $symbols_below = true, bool $symbols_right = true, bool $auto_style = false): void { $this->outlineOn = $visible; $this->outlineBelow = $symbols_below; @@ -608,7 +603,7 @@ public function setOutline($visible = true, $symbols_below = true, $symbols_righ * @param float $num The number to write * @param int $xfIndex The optional XF format */ - private function writeNumber(int $row, int $col, $num, int $xfIndex): int + private function writeNumber(int $row, int $col, float $num, int $xfIndex): int { $record = 0x0203; // Record identifier $length = 0x000E; // Number of bytes to follow @@ -633,7 +628,7 @@ private function writeNumber(int $row, int $col, $num, int $xfIndex): int * @param string $str The string * @param int $xfIndex Index to XF record */ - private function writeString(int $row, int $col, $str, int $xfIndex): void + private function writeString(int $row, int $col, string $str, int $xfIndex): void { $this->writeLabelSst($row, $col, $str, $xfIndex); } @@ -675,7 +670,7 @@ private function writeRichTextString(int $row, int $col, string $str, int $xfInd * @param string $str The string to write * @param int $xfIndex The XF format index for the cell */ - private function writeLabelSst(int $row, int $col, $str, int $xfIndex): void + private function writeLabelSst(int $row, int $col, string $str, int $xfIndex): void { $record = 0x00FD; // Record identifier $length = 0x000A; // Bytes to follow @@ -709,7 +704,7 @@ private function writeLabelSst(int $row, int $col, $str, int $xfIndex): void * @param int $col Zero indexed column * @param int $xfIndex The XF format index */ - public function writeBlank($row, $col, $xfIndex): int + public function writeBlank(int $row, int $col, int $xfIndex): int { $record = 0x0201; // Record identifier $length = 0x0006; // Number of bytes to follow @@ -726,10 +721,9 @@ public function writeBlank($row, $col, $xfIndex): int * * @param int $row Row index (0-based) * @param int $col Column index (0-based) - * @param int $value * @param int $isError Error or Boolean? */ - private function writeBoolErr(int $row, int $col, $value, int $isError, int $xfIndex): int + private function writeBoolErr(int $row, int $col, int $value, int $isError, int $xfIndex): int { $record = 0x0205; $length = 8; @@ -883,7 +877,7 @@ private function writeStringRecord(string $stringValue): void * @param int $col Column * @param string $url URL string */ - private function writeUrl(int $row, int $col, $url): void + private function writeUrl(int $row, int $col, string $url): void { // Add start row and col to arg list $this->writeUrlRange($row, $col, $row, $col, $url); @@ -903,7 +897,7 @@ private function writeUrl(int $row, int $col, $url): void * * @see writeUrl() */ - private function writeUrlRange(int $row1, int $col1, int $row2, int $col2, $url): void + private function writeUrlRange(int $row1, int $col1, int $row2, int $col2, string $url): void { // Check for internal/external sheet links or default to web link if (preg_match('[^internal:]', $url)) { @@ -929,7 +923,7 @@ private function writeUrlRange(int $row1, int $col1, int $row2, int $col2, $url) * * @see writeUrl() */ - public function writeUrlWeb($row1, $col1, $row2, $col2, $url): void + public function writeUrlWeb(int $row1, int $col1, int $row2, int $col2, string $url): void { $record = 0x01B8; // Record identifier @@ -971,7 +965,7 @@ public function writeUrlWeb($row1, $col1, $row2, $col2, $url): void * * @see writeUrl() */ - private function writeUrlInternal(int $row1, int $col1, int $row2, int $col2, $url): void + private function writeUrlInternal(int $row1, int $col1, int $row2, int $col2, string $url): void { $record = 0x01B8; // Record identifier @@ -1019,7 +1013,7 @@ private function writeUrlInternal(int $row1, int $col1, int $row2, int $col2, $u * * @see writeUrl() */ - private function writeUrlExternal(int $row1, int $col1, int $row2, int $col2, $url): void + private function writeUrlExternal(int $row1, int $col1, int $row2, int $col2, string $url): void { // Network drives are different. We will handle them separately // MS/Novell network drives and shares start with \\ @@ -1110,7 +1104,7 @@ private function writeUrlExternal(int $row1, int $col1, int $row2, int $col2, $u * @param bool $hidden The optional hidden attribute * @param int $level The optional outline level for row, in range [0,7] */ - private function writeRow(int $row, int $height, int $xfIndex, bool $hidden = false, $level = 0): void + private function writeRow(int $row, int $height, int $xfIndex, bool $hidden = false, int $level = 0): void { $record = 0x0208; // Record identifier $length = 0x0010; // Number of bytes to follow @@ -1272,7 +1266,7 @@ private function writeDefcol(): void * 4 => Option flags. * 5 => Optional outline level */ - private function writeColinfo($col_array): void + private function writeColinfo(array $col_array): void { $colFirst = $col_array[0] ?? null; $colLast = $col_array[1] ?? null; @@ -2122,7 +2116,7 @@ private function writePassword(): void * @param float $scale_x The horizontal scale * @param float $scale_y The vertical scale */ - public function insertBitmap($row, $col, GdImage|string $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1): void + public function insertBitmap(int $row, int $col, GdImage|string $bitmap, int $x = 0, int $y = 0, float $scale_x = 1, float $scale_y = 1): void { $bitmap_array = $bitmap instanceof GdImage ? $this->processBitmapGd($bitmap) @@ -2197,7 +2191,7 @@ public function insertBitmap($row, $col, GdImage|string $bitmap, $x = 0, $y = 0, * @param int $width Width of image frame * @param int $height Height of image frame */ - public function positionImage($col_start, $row_start, $x1, $y1, $width, $height): void + public function positionImage(int $col_start, int $row_start, int $x1, int $y1, int $width, int $height): void { // Initialise end cell to the same as the start cell $col_end = $col_start; // Col containing lower right corner of object @@ -2370,7 +2364,7 @@ public function processBitmapGd(GdImage $image): array * * @return array Array with data and properties of the bitmap */ - public function processBitmap($bitmap): array + public function processBitmap(string $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 5524e8ffec..c3ea4dceec 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -232,10 +232,8 @@ public function writeXf(): string /** * Is this a style XF ? - * - * @param bool $value */ - public function setIsStyleXf($value): void + public function setIsStyleXf(bool $value): void { $this->isStyleXf = $value; } @@ -245,7 +243,7 @@ public function setIsStyleXf($value): void * * @param int $colorIndex Color index */ - public function setBottomColor($colorIndex): void + public function setBottomColor(int $colorIndex): void { $this->bottomBorderColor = $colorIndex; } @@ -255,7 +253,7 @@ public function setBottomColor($colorIndex): void * * @param int $colorIndex Color index */ - public function setTopColor($colorIndex): void + public function setTopColor(int $colorIndex): void { $this->topBorderColor = $colorIndex; } @@ -265,7 +263,7 @@ public function setTopColor($colorIndex): void * * @param int $colorIndex Color index */ - public function setLeftColor($colorIndex): void + public function setLeftColor(int $colorIndex): void { $this->leftBorderColor = $colorIndex; } @@ -275,7 +273,7 @@ public function setLeftColor($colorIndex): void * * @param int $colorIndex Color index */ - public function setRightColor($colorIndex): void + public function setRightColor(int $colorIndex): void { $this->rightBorderColor = $colorIndex; } @@ -285,7 +283,7 @@ public function setRightColor($colorIndex): void * * @param int $colorIndex Color index */ - public function setDiagColor($colorIndex): void + public function setDiagColor(int $colorIndex): void { $this->diagColor = $colorIndex; } @@ -295,7 +293,7 @@ public function setDiagColor($colorIndex): void * * @param int $colorIndex Color index */ - public function setFgColor($colorIndex): void + public function setFgColor(int $colorIndex): void { $this->foregroundColor = $colorIndex; } @@ -305,7 +303,7 @@ public function setFgColor($colorIndex): void * * @param int $colorIndex Color index */ - public function setBgColor($colorIndex): void + public function setBgColor(int $colorIndex): void { $this->backgroundColor = $colorIndex; } @@ -316,7 +314,7 @@ public function setBgColor($colorIndex): void * * @param int $numberFormatIndex Index to format record */ - public function setNumberFormatIndex($numberFormatIndex): void + public function setNumberFormatIndex(int $numberFormatIndex): void { $this->numberFormatIndex = $numberFormatIndex; } @@ -326,17 +324,15 @@ public function setNumberFormatIndex($numberFormatIndex): void * * @param int $value Font index, note that value 4 does not exist */ - public function setFontIndex($value): void + public function setFontIndex(int $value): void { $this->fontIndex = $value; } /** * Map to BIFF8 codes for text rotation angle. - * - * @param int $textRotation */ - private static function mapTextRotation($textRotation): int + private static function mapTextRotation(int $textRotation): int { if ($textRotation >= 0) { return $textRotation; @@ -359,7 +355,7 @@ private static function mapTextRotation($textRotation): int * * @param ?string $locked */ - private static function mapLocked($locked): int + private static function mapLocked(?string $locked): int { return $locked !== null && array_key_exists($locked, self::LOCK_ARRAY) ? self::LOCK_ARRAY[$locked] : 1; } @@ -375,7 +371,7 @@ private static function mapLocked($locked): int * * @param ?string $hidden */ - private static function mapHidden($hidden): int + private static function mapHidden(?string $hidden): int { 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 0cbda2d825..23a24862ff 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -631,7 +631,7 @@ public function getOffice2003Compatibility(): bool * * @return $this */ - public function setOffice2003Compatibility($office2003compatibility): static + public function setOffice2003Compatibility(bool $office2003compatibility): static { $this->office2003compatibility = $office2003compatibility; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 51311d2e1c..6e50f23c23 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -500,10 +500,8 @@ private function writeDataLabels(XMLWriter $objWriter, ?Layout $chartLayout = nu /** * Write Category Axis. - * - * @param bool $isMultiLevelSeries */ - private function writeCategoryAxis(XMLWriter $objWriter, ?Title $xAxisLabel, string $id1, string $id2, $isMultiLevelSeries, Axis $yAxis): void + private function writeCategoryAxis(XMLWriter $objWriter, ?Title $xAxisLabel, string $id1, string $id2, bool $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). @@ -719,9 +717,8 @@ private function writeCategoryAxis(XMLWriter $objWriter, ?Title $xAxisLabel, str * Write Value Axis. * * @param null|string $groupType Chart type - * @param bool $isMultiLevelSeries */ - private function writeValueAxis(XMLWriter $objWriter, ?Title $yAxisLabel, $groupType, string $id1, string $id2, $isMultiLevelSeries, Axis $xAxis): void + private function writeValueAxis(XMLWriter $objWriter, ?Title $yAxisLabel, ?string $groupType, string $id1, string $id2, bool $isMultiLevelSeries, Axis $xAxis): void { $objWriter->startElement('c:' . Axis::AXIS_TYPE_VALUE); $majorGridlines = $xAxis->getMajorGridlines(); @@ -1014,7 +1011,7 @@ private function writePlotSeriesValuesElement(XMLWriter $objWriter, int $val, ?C * @param bool $valIsMultiLevelSeries Is value set a multi-series set * @param string $plotGroupingType Type of grouping for multi-series values */ - private function writePlotGroup(?DataSeries $plotGroup, string $groupType, XMLWriter $objWriter, &$catIsMultiLevelSeries, &$valIsMultiLevelSeries, &$plotGroupingType): void + private function writePlotGroup(?DataSeries $plotGroup, string $groupType, XMLWriter $objWriter, bool &$catIsMultiLevelSeries, bool &$valIsMultiLevelSeries, string &$plotGroupingType): void { if ($plotGroup === null) { return; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php index 84141231bb..767da83a4a 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Comments.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Comments.php @@ -70,7 +70,7 @@ public function writeComments(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $wor * @param Comment $comment Comment * @param array $authors Array of authors */ - private function writeComment(XMLWriter $objWriter, $cellReference, Comment $comment, array $authors): void + private function writeComment(XMLWriter $objWriter, string $cellReference, Comment $comment, array $authors): void { // comment $objWriter->startElement('comment'); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php index 999a35e77c..be48d77082 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/ContentTypes.php @@ -18,7 +18,7 @@ class ContentTypes extends WriterPart * * @return string XML Output */ - public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = false): string + public function writeContentTypes(Spreadsheet $spreadsheet, bool $includeCharts = false): string { // Create XML writer $objWriter = null; @@ -217,7 +217,7 @@ public function writeContentTypes(Spreadsheet $spreadsheet, $includeCharts = fal * * @return string Mime Type */ - private function getImageMimeType($filename): string + private function getImageMimeType(string $filename): string { if (File::fileExists($filename)) { $image = getimagesize($filename); @@ -234,7 +234,7 @@ private function getImageMimeType($filename): string * @param string $partName Part name * @param string $contentType Content type */ - private function writeDefaultContentType(XMLWriter $objWriter, $partName, $contentType): void + private function writeDefaultContentType(XMLWriter $objWriter, string $partName, string $contentType): void { if ($partName != '' && $contentType != '') { // Write content type @@ -253,7 +253,7 @@ private function writeDefaultContentType(XMLWriter $objWriter, $partName, $conte * @param string $partName Part name * @param string $contentType Content type */ - private function writeOverrideContentType(XMLWriter $objWriter, $partName, $contentType): void + private function writeOverrideContentType(XMLWriter $objWriter, string $partName, string $contentType): void { if ($partName != '' && $contentType != '') { // Write content type diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php index d90034d65a..37761be4c0 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Drawing.php @@ -20,7 +20,7 @@ class Drawing extends WriterPart * * @return string XML Output */ - public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, $includeCharts = false): string + public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, bool $includeCharts = false): string { // Create XML writer $objWriter = null; @@ -82,10 +82,8 @@ public function writeDrawings(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $wor /** * Write drawings to XML format. - * - * @param int $relationId */ - public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart\Chart $chart, $relationId = -1): void + public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart\Chart $chart, int $relationId = -1): void { $tl = $chart->getTopLeftPosition(); $tlColRow = Coordinate::indexesFromString($tl['cell']); @@ -178,11 +176,8 @@ public function writeChart(XMLWriter $objWriter, \PhpOffice\PhpSpreadsheet\Chart /** * Write drawings to XML format. - * - * @param int $relationId - * @param null|int $hlinkClickId */ - public function writeDrawing(XMLWriter $objWriter, BaseDrawing $drawing, $relationId = -1, $hlinkClickId = null): void + public function writeDrawing(XMLWriter $objWriter, BaseDrawing $drawing, int $relationId = -1, ?int $hlinkClickId = null): void { if ($relationId >= 0) { $isTwoCellAnchor = $drawing->getCoordinates2() !== ''; @@ -560,10 +555,7 @@ public function allDrawings(Spreadsheet $spreadsheet): array return $aDrawings; } - /** - * @param null|int $hlinkClickId - */ - private function writeHyperLinkDrawing(XMLWriter $objWriter, $hlinkClickId): void + private function writeHyperLinkDrawing(XMLWriter $objWriter, ?int $hlinkClickId): void { if ($hlinkClickId === null) { return; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php index c29394fa31..7d5f3a5dc7 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Rels.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Rels.php @@ -163,13 +163,12 @@ public function writeWorkbookRelationships(Spreadsheet $spreadsheet): string * rId1 - Drawings * rId_hyperlink_x - Hyperlinks * - * @param int $worksheetId * @param bool $includeCharts Flag indicating if we should write charts * @param int $tableRef Table ID * * @return string XML Output */ - public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, $worksheetId = 1, $includeCharts = false, $tableRef = 1): string + public function writeWorksheetRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, int $worksheetId = 1, bool $includeCharts = false, int $tableRef = 1): string { // Create XML writer $objWriter = null; @@ -315,7 +314,7 @@ private function writeUnparsedRelationship(\PhpOffice\PhpSpreadsheet\Worksheet\W * * @return string XML Output */ - public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, &$chartRef, $includeCharts = false): string + public function writeDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet\Worksheet $worksheet, int &$chartRef, bool $includeCharts = false): string { // Create XML writer $objWriter = null; @@ -459,7 +458,7 @@ public function writeVMLDrawingRelationships(\PhpOffice\PhpSpreadsheet\Worksheet * @param string $target Relationship target * @param string $targetMode Relationship target mode */ - private function writeRelationship(XMLWriter $objWriter, $id, string $type, $target, string $targetMode = ''): void + private function writeRelationship(XMLWriter $objWriter, $id, string $type, string $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 0200f0d9e8..c431d46c6c 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): array + public function createStringTable(ActualWorksheet $worksheet, ?array $existingTable = null): array { // Create string lookup table $aStringTable = []; @@ -115,7 +115,7 @@ public function writeStringTable(array $stringTable): string * * @param string $prefix Optional Namespace prefix */ - public function writeRichText(XMLWriter $objWriter, RichText $richText, $prefix = null): void + public function writeRichText(XMLWriter $objWriter, RichText $richText, ?string $prefix = null): void { if ($prefix !== null) { $prefix .= ':'; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Table.php b/src/PhpSpreadsheet/Writer/Xlsx/Table.php index 2c1468be8e..5b0b22bca0 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Table.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Table.php @@ -16,7 +16,7 @@ class Table extends WriterPart * * @return string XML Output */ - public function writeTable(WorksheetTable $table, $tableRef): string + public function writeTable(WorksheetTable $table, int $tableRef): string { // Create XML writer $objWriter = null; diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php index 7f46c4b026..5604be5443 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Workbook.php @@ -18,7 +18,7 @@ class Workbook extends WriterPart * * @return string XML Output */ - public function writeWorkbook(Spreadsheet $spreadsheet, $recalcRequired = false): string + public function writeWorkbook(Spreadsheet $spreadsheet, bool $recalcRequired = false): string { // Create XML writer if ($this->getParentWriter()->getUseDiskCaching()) { @@ -148,7 +148,7 @@ private function writeWorkbookProtection(XMLWriter $objWriter, Spreadsheet $spre * * @param bool $recalcRequired Indicate whether formulas should be recalculated before writing */ - private function writeCalcPr(XMLWriter $objWriter, $recalcRequired = true): void + private function writeCalcPr(XMLWriter $objWriter, bool $recalcRequired = true): void { $objWriter->startElement('calcPr'); @@ -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, string $worksheetName, int $worksheetId = 1, $relId = 1, $sheetState = 'visible'): void + private function writeSheet(XMLWriter $objWriter, string $worksheetName, int $worksheetId = 1, int $relId = 1, string $sheetState = 'visible'): void { if ($worksheetName != '') { // Write sheet diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 08a8290032..20c5e18561 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -36,7 +36,7 @@ class Worksheet extends WriterPart * * @return string XML Output */ - public function writeWorksheet(PhpspreadsheetWorksheet $worksheet, array $stringTable = [], $includeCharts = false): string + public function writeWorksheet(PhpspreadsheetWorksheet $worksheet, array $stringTable = [], bool $includeCharts = false): string { $this->numberStoredAsText = ''; $this->formula = ''; @@ -1433,7 +1433,7 @@ private function writeCell(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksh * * @param bool $includeCharts Flag indicating if we should include drawing details for charts */ - private function writeDrawings(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksheet, $includeCharts = false): void + private function writeDrawings(XMLWriter $objWriter, PhpspreadsheetWorksheet $worksheet, bool $includeCharts = false): void { $unparsedLoadedData = $worksheet->getParentOrThrow()->getUnparsedLoadedData(); $hasUnparsedDrawing = isset($unparsedLoadedData['sheets'][$worksheet->getCodeName()]['drawingOriginalIds']); diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php index 5777a8f2d0..6f2a5ae465 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/RankTest.php @@ -11,7 +11,7 @@ class RankTest extends AllSetupTeardown * * @param mixed[] $valueSet */ - public function testRANK(mixed $expectedResult, mixed $value, $valueSet, mixed $order = null): void + public function testRANK(mixed $expectedResult, mixed $value, array $valueSet, mixed $order = null): void { if ($order === null) { $this->runTestCaseReference('RANK', $expectedResult, $value, $valueSet); diff --git a/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php b/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php index 3da40cef74..db20ef42c9 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadFilterFilter.php @@ -15,7 +15,7 @@ class ReadFilterFilter implements IReadFilter * * @see \PhpOffice\PhpSpreadsheet\Reader\IReadFilter::readCell() */ - public function readCell($column, $row, $worksheetName = ''): bool + public function readCell(string $column, int $row, string $worksheetName = ''): bool { // define filter range $rowMin = 2; From 2e48f15371feb67144945b51651fd92d36fa0679 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 10 Dec 2023 11:13:14 +0100 Subject: [PATCH 08/25] More typing --- .../Calculation/Calculation.php | 17 ++--------- src/PhpSpreadsheet/Calculation/Database.php | 4 +-- .../Calculation/Engineering/BitWise.php | 15 ++++------ .../Calculation/MathTrig/Helpers.php | 10 ++----- .../Calculation/MathTrig/Operations.php | 3 +- .../Calculation/MathTrig/Subtotal.php | 4 +-- .../Calculation/MathTrig/Sum.php | 8 ++---- .../Calculation/MathTrig/SumSquares.php | 8 ------ .../Calculation/Statistical/AggregateBase.php | 2 -- .../Calculation/Statistical/Averages/Mean.php | 8 +----- .../Calculation/Statistical/Conditional.php | 28 +++++-------------- .../Calculation/Statistical/Deviations.php | 2 -- .../Statistical/Distributions/Binomial.php | 3 +- .../Statistical/Distributions/ChiSquared.php | 4 +-- .../Statistical/StandardDeviations.php | 12 ++------ .../Calculation/Statistical/Trends.php | 19 ++++--------- .../Calculation/TextData/Extract.php | 7 +---- .../Calculation/TextData/Text.php | 3 +- src/PhpSpreadsheet/Chart/Axis.php | 2 -- src/PhpSpreadsheet/Chart/ChartColor.php | 4 +-- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 6 +--- src/PhpSpreadsheet/Chart/Layout.php | 12 +------- src/PhpSpreadsheet/Chart/PlotArea.php | 2 -- src/PhpSpreadsheet/Chart/Properties.php | 16 ++--------- src/PhpSpreadsheet/Document/Properties.php | 12 ++------ src/PhpSpreadsheet/Reader/Xls.php | 5 ---- src/PhpSpreadsheet/Shared/Date.php | 4 +-- src/PhpSpreadsheet/Shared/Font.php | 4 +-- src/PhpSpreadsheet/Shared/IntOrFloat.php | 6 +--- src/PhpSpreadsheet/Spreadsheet.php | 4 +-- .../ConditionalFormatting/CellMatcher.php | 15 ++-------- .../Wizard/CellValue.php | 5 +--- .../Worksheet/AutoFilter/Column.php | 4 +-- src/PhpSpreadsheet/Worksheet/PageSetup.php | 2 -- src/PhpSpreadsheet/Worksheet/SheetView.php | 4 --- src/PhpSpreadsheet/Writer/Pdf.php | 2 -- 36 files changed, 53 insertions(+), 213 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 8d2e2e290e..5f8aa754f0 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3519,10 +3519,8 @@ public function calculateCellValue(?Cell $cell = null, bool $resetLog = true): m * Validate and parse a formula string. * * @param string $formula Formula to parse - * - * @return array|bool */ - public function parseFormula(string $formula) + public function parseFormula(string $formula): array|bool { // Basic validation that this is indeed a formula // We return an empty array if not @@ -5193,10 +5191,7 @@ private function executeBinaryComparisonOperation(mixed $operand1, mixed $operan return $result; } - /** - * @return bool|mixed - */ - private function executeNumericBinaryOperation(mixed $operand1, mixed $operand2, string $operation, Stack &$stack) + private function executeNumericBinaryOperation(mixed $operand1, mixed $operand2, string $operation, Stack &$stack): mixed { // Validate the two operands if ( @@ -5516,9 +5511,6 @@ private function addDefaultArgumentValues(array $functionCall, array $args, arra return $args; } - /** - * @return null|mixed - */ private function getArgumentDefaultValue(ReflectionParameter $methodArgument): mixed { $defaultValue = null; @@ -5567,10 +5559,7 @@ private function addCellReference(array $args, bool $passCellReference, $functio return $args; } - /** - * @return mixed|string - */ - private function evaluateDefinedName(Cell $cell, DefinedName $namedRange, Worksheet $cellWorksheet, Stack $stack) + private function evaluateDefinedName(Cell $cell, DefinedName $namedRange, Worksheet $cellWorksheet, Stack $stack): mixed { $definedNameScope = $namedRange->getScope(); if ($definedNameScope !== null && $definedNameScope !== $cellWorksheet) { diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php index 90dabcd824..adb0f720fe 100644 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ b/src/PhpSpreadsheet/Calculation/Database.php @@ -35,10 +35,8 @@ class Database * 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 DAVERAGE(array $database, $field, array $criteria) + public static function DAVERAGE(array $database, $field, array $criteria): float|string|int { return Database\DAverage::evaluate($database, $field, $criteria); } diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php index 2cbc8ffc03..f443c83be2 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php @@ -37,8 +37,7 @@ private static function splitNumber($number): array * @param array|int $number2 * Or can be an array of values * - * @return array|int|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|int|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 BITAND($number1, $number2): array|string|int @@ -72,8 +71,7 @@ public static function BITAND($number1, $number2): array|string|int * @param array|int $number2 * Or can be an array of values * - * @return array|int|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|int|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 BITOR($number1, $number2): array|string|int @@ -108,8 +106,7 @@ public static function BITOR($number1, $number2): array|string|int * @param array|int $number2 * Or can be an array of values * - * @return array|int|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|int|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 BITXOR($number1, $number2): array|string|int @@ -144,8 +141,7 @@ public static function BITXOR($number1, $number2): array|string|int * @param array|int $shiftAmount * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string|float @@ -182,8 +178,7 @@ public static function BITLSHIFT($number, $shiftAmount): array|string|float * @param array|int $shiftAmount * Or can be an array of values * - * @return array|float|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @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): array|string|float diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php b/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php index d2e680bc4c..fd8b2ea9da 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php @@ -41,10 +41,8 @@ public static function validateNumericNullBool(mixed $number): int|float * Validate numeric, but allow substitute for null. * * @param null|float|int $substitute - * - * @return float|int */ - public static function validateNumericNullSubstitution(mixed $number, $substitute) + public static function validateNumericNullSubstitution(mixed $number, $substitute): float|int { $number = Functions::flattenSingleValue($number); if ($number === null && $substitute !== null) { @@ -113,12 +111,8 @@ public static function getEven(float $number): float /** * Return NAN or value depending on argument. - * - * @param float $result Number - * - * @return float|string */ - public static function numberOrNan(float $result) + public static function numberOrNan(float $result): float|string { return is_nan($result) ? ExcelError::NAN() : $result; } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php b/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php index 5a90731c65..2c224430be 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php @@ -135,8 +135,7 @@ public static function product(mixed ...$args): string|float * @param mixed $denominator Expect float|int * Or can be an array of values * - * @return array|int|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|int|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 quotient(mixed $numerator, mixed $denominator): array|string|int diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php b/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php index 20a1080446..c30a42f8dc 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php @@ -79,10 +79,8 @@ function ($index) use ($cellReference): bool { * but ignore any values in the range that are * in hidden rows * @param mixed[] $args A mixed data series of values - * - * @return float|string */ - public static function evaluate(mixed $functionType, ...$args) + public static function evaluate(mixed $functionType, ...$args): float|int|string { $cellReference = array_pop($args); $bArgs = Functions::flattenArrayIndexed($args); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php b/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php index 7fc60903ad..f939d9e747 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Sum.php @@ -17,10 +17,8 @@ class Sum * SUM(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|int|string */ - public static function sumIgnoringStrings(mixed ...$args) + public static function sumIgnoringStrings(mixed ...$args): float|int|string { $returnValue = 0; @@ -46,10 +44,8 @@ public static function sumIgnoringStrings(mixed ...$args) * SUM(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|int|string */ - public static function sumErroringStrings(mixed ...$args) + public static function sumErroringStrings(mixed ...$args): float|int|string|array { $returnValue = 0; // Loop through the arguments diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php b/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php index 4c931a7044..b2e9cea2b4 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/SumSquares.php @@ -17,8 +17,6 @@ class SumSquares * SUMSQ(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|string */ public static function sumSquare(mixed ...$args): string|int|float { @@ -60,8 +58,6 @@ private static function numericNotString(mixed $item): bool * * @param mixed[] $matrixData1 Matrix #1 * @param mixed[] $matrixData2 Matrix #2 - * - * @return float|string */ public static function sumXSquaredMinusYSquared(array $matrixData1, array $matrixData2): string|int|float { @@ -88,8 +84,6 @@ public static function sumXSquaredMinusYSquared(array $matrixData1, array $matri * * @param mixed[] $matrixData1 Matrix #1 * @param mixed[] $matrixData2 Matrix #2 - * - * @return float|string */ public static function sumXSquaredPlusYSquared(array $matrixData1, array $matrixData2): string|int|float { @@ -116,8 +110,6 @@ public static function sumXSquaredPlusYSquared(array $matrixData1, array $matrix * * @param mixed[] $matrixData1 Matrix #1 * @param mixed[] $matrixData2 Matrix #2 - * - * @return float|string */ public static function sumXMinusYSquared(array $matrixData1, array $matrixData2): string|int|float { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php b/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php index f8b2eddf53..a10b278092 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/AggregateBase.php @@ -10,8 +10,6 @@ abstract class AggregateBase * MS Excel does not count Booleans if passed as cell values, but they are counted if passed as literals. * OpenOffice Calc always counts Booleans. * Gnumeric never counts Booleans. - * - * @return int|mixed */ protected static function testAcceptedBoolean(mixed $arg, mixed $k): mixed { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php b/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php index a05d7c7c4e..2051675c34 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Averages/Mean.php @@ -22,8 +22,6 @@ class Mean * GEOMEAN(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|string */ public static function geometric(mixed ...$args): float|int|string { @@ -50,8 +48,6 @@ public static function geometric(mixed ...$args): float|int|string * HARMEAN(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|string */ public static function harmonic(mixed ...$args): string|float|int { @@ -93,10 +89,8 @@ public static function harmonic(mixed ...$args): string|float|int * TRIMEAN(value1[,value2[, ...]], $discard) * * @param mixed $args Data values - * - * @return float|string */ - public static function trim(mixed ...$args) + public static function trim(mixed ...$args): float|string { $aArgs = Functions::flattenArray($args); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php index 3f15c9b1b2..ae98c60802 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Conditional.php @@ -27,10 +27,8 @@ class Conditional * @param mixed $range Data values * @param null|array|string $condition the criteria that defines which cells will be checked * @param mixed $averageRange Data values - * - * @return null|float|string */ - public static function AVERAGEIF(mixed $range, null|array|string $condition, mixed $averageRange = []) + public static function AVERAGEIF(mixed $range, null|array|string $condition, mixed $averageRange = []): null|int|float|string { if (!is_array($range) || !is_array($averageRange) || array_key_exists(0, $range) || array_key_exists(0, $averageRange)) { throw new CalcException('Must specify range of cells, not any kind of literal'); @@ -50,10 +48,8 @@ public static function AVERAGEIF(mixed $range, null|array|string $condition, mix * AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2, criteria2]…) * * @param mixed $args Pairs of Ranges and Criteria - * - * @return null|float|string */ - public static function AVERAGEIFS(mixed ...$args) + public static function AVERAGEIFS(mixed ...$args): null|int|float|string { if (empty($args)) { return 0.0; @@ -106,10 +102,8 @@ public static function COUNTIF(array $range, null|array|string $condition): stri * COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2]…) * * @param mixed $args Pairs of Ranges and Criteria - * - * @return int|string */ - public static function COUNTIFS(mixed ...$args) + public static function COUNTIFS(mixed ...$args): int|string { if (empty($args)) { return 0; @@ -132,10 +126,8 @@ public static function COUNTIFS(mixed ...$args) * MAXIFS(max_range, criteria_range1, criteria1, [criteria_range2, criteria2]…) * * @param mixed $args Pairs of Ranges and Criteria - * - * @return null|float|string */ - public static function MAXIFS(mixed ...$args) + public static function MAXIFS(mixed ...$args): null|float|string { if (empty($args)) { return 0.0; @@ -156,10 +148,8 @@ public static function MAXIFS(mixed ...$args) * MINIFS(min_range, criteria_range1, criteria1, [criteria_range2, criteria2]…) * * @param mixed $args Pairs of Ranges and Criteria - * - * @return null|float|string */ - public static function MINIFS(mixed ...$args) + public static function MINIFS(mixed ...$args): null|float|string { if (empty($args)) { return 0.0; @@ -180,10 +170,8 @@ public static function MINIFS(mixed ...$args) * SUMIF(range, criteria, [sum_range]) * * @param array $range Data values - * - * @return null|float|string */ - public static function SUMIF(array $range, mixed $condition, array $sumRange = []) + public static function SUMIF(array $range, mixed $condition, array $sumRange = []): null|float|string { $database = self::databaseFromRangeAndValue($range, $sumRange); $condition = [[self::CONDITION_COLUMN_NAME, self::VALUE_COLUMN_NAME], [$condition, null]]; @@ -200,10 +188,8 @@ public static function SUMIF(array $range, mixed $condition, array $sumRange = [ * SUMIFS(average_range, criteria_range1, criteria1, [criteria_range2, criteria2]…) * * @param mixed $args Pairs of Ranges and Criteria - * - * @return null|float|string */ - public static function SUMIFS(mixed ...$args) + public static function SUMIFS(mixed ...$args): null|float|string { if (empty($args)) { return 0.0; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php b/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php index bc6b19c5c2..77c0d38f60 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Deviations.php @@ -56,8 +56,6 @@ public static function sumSquares(mixed ...$args): string|float * relatively flat distribution. * * @param array ...$args Data Series - * - * @return float|string */ public static function kurtosis(...$args): string|int|float { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php index 68fa8821b9..66077d255d 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php @@ -181,8 +181,7 @@ public static function negative(mixed $failures, mixed $successes, mixed $probab * @param mixed $alpha criterion value as a float * Or can be an array of values * - * @return array|int|string - * If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|int|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 inverse(mixed $trials, mixed $probability, mixed $alpha): array|string|int diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php index 67edbccede..3dc0b33f13 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php @@ -185,10 +185,8 @@ public static function inverseLeftTail(mixed $probability, mixed $degrees): arra * * @param mixed $actual an array of observed frequencies * @param mixed $expected an array of expected frequencies - * - * @return float|string */ - public static function test(mixed $actual, mixed $expected) + public static function test(mixed $actual, mixed $expected): float|string { $rows = count($actual); $actual = Functions::flattenArray($actual); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php b/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php index 095e9cff24..3d4ea30523 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/StandardDeviations.php @@ -36,10 +36,8 @@ public static function STDEV(mixed ...$args) * STDEVA(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|string */ - public static function STDEVA(mixed ...$args) + public static function STDEVA(mixed ...$args): float|string { $result = Variances::VARA(...$args); if (!is_numeric($result)) { @@ -58,10 +56,8 @@ public static function STDEVA(mixed ...$args) * STDEVP(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|string */ - public static function STDEVP(mixed ...$args) + public static function STDEVP(mixed ...$args): float|string { $result = Variances::VARP(...$args); if (!is_numeric($result)) { @@ -80,10 +76,8 @@ public static function STDEVP(mixed ...$args) * STDEVPA(value1[,value2[, ...]]) * * @param mixed ...$args Data values - * - * @return float|string */ - public static function STDEVPA(mixed ...$args) + public static function STDEVPA(mixed ...$args): float|string { $result = Variances::VARPA(...$args); if (!is_numeric($result)) { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php index dcc55d72e5..d503e8e054 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Trends.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Trends.php @@ -64,10 +64,8 @@ protected static function validateTrendArrays(array $yValues, array $xValues): v * * @param mixed $yValues array of mixed Data Series Y * @param null|mixed $xValues array of mixed Data Series X - * - * @return float|string */ - public static function CORREL(mixed $yValues, $xValues = null) + public static function CORREL(mixed $yValues, $xValues = null): float|string { if (($xValues === null) || (!is_array($yValues)) || (!is_array($xValues))) { return ExcelError::VALUE(); @@ -92,10 +90,8 @@ public static function CORREL(mixed $yValues, $xValues = null) * * @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(array $yValues, array $xValues) + public static function COVAR(array $yValues, array $xValues): float|string { try { self::checkTrendArrays($yValues, $xValues); @@ -120,8 +116,7 @@ public static function COVAR(array $yValues, array $xValues) * @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 + * @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(mixed $xValue, array $yValues, array $xValues) @@ -182,10 +177,8 @@ public static function GROWTH(array $yValues, array $xValues = [], array $newVal * * @param mixed[] $yValues Data Series Y * @param mixed[] $xValues Data Series X - * - * @return float|string */ - public static function INTERCEPT(array $yValues, array $xValues) + public static function INTERCEPT(array $yValues, array $xValues): float|string { try { self::checkTrendArrays($yValues, $xValues); @@ -383,10 +376,8 @@ public static function SLOPE(array $yValues, array $xValues) * * @param mixed[] $yValues Data Series Y * @param mixed[] $xValues Data Series X - * - * @return float|string */ - public static function STEYX(array $yValues, array $xValues) + public static function STEYX(array $yValues, array $xValues): float|string { try { self::checkTrendArrays($yValues, $xValues); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Extract.php b/src/PhpSpreadsheet/Calculation/TextData/Extract.php index 5b99b919ec..32e5b967a3 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Extract.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Extract.php @@ -216,12 +216,7 @@ public static function after(mixed $text, $delimiter, mixed $instance = 1, mixed return implode('', $split); } - /** - * @param null|array|string $delimiter - * - * @return array|string - */ - private static function validateTextBeforeAfter(string $text, $delimiter, int $instance, int $matchMode, int $matchEnd, mixed $ifNotFound) + private static function validateTextBeforeAfter(string $text, null|array|string $delimiter, int $instance, int $matchMode, int $matchEnd, mixed $ifNotFound): array|string { $flags = self::matchFlags($matchMode); $delimiter = self::buildDelimiter($delimiter); diff --git a/src/PhpSpreadsheet/Calculation/TextData/Text.php b/src/PhpSpreadsheet/Calculation/TextData/Text.php index 162bfff680..44e0cd4021 100644 --- a/src/PhpSpreadsheet/Calculation/TextData/Text.php +++ b/src/PhpSpreadsheet/Calculation/TextData/Text.php @@ -17,8 +17,7 @@ class Text * @param mixed $value String Value * Or can be an array of values * - * @return array|int - * If an array of values is passed for the argument, then the returned result + * @return array|int 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(mixed $value = ''): array|int diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index af1642e9fe..db714163d1 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -167,8 +167,6 @@ public function setAxisOptionsProperties( /** * Get Axis Options Property. - * - * @return ?string */ public function getAxisOptionsProperty(string $property): ?string { diff --git a/src/PhpSpreadsheet/Chart/ChartColor.php b/src/PhpSpreadsheet/Chart/ChartColor.php index e36e042e46..a73c3fdbf7 100644 --- a/src/PhpSpreadsheet/Chart/ChartColor.php +++ b/src/PhpSpreadsheet/Chart/ChartColor.php @@ -137,10 +137,8 @@ public function isUsable(): bool /** * Get Color Property. - * - * @return null|int|string */ - public function getColorProperty(string $propertyName) + public function getColorProperty(string $propertyName): null|int|string { $retVal = null; if ($propertyName === 'value') { diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index 4b1c5a60dc..f2e913d400 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -138,8 +138,6 @@ public function setDataType(string $dataType): static /** * Get Series Data Source (formula). - * - * @return ?string */ public function getDataSource(): ?string { @@ -350,10 +348,8 @@ private function validateColor(string $color): bool /** * Get line width for series. - * - * @return null|float|int */ - public function getLineWidth() + public function getLineWidth(): null|float|int { return $this->lineStyleProperties['width']; } diff --git a/src/PhpSpreadsheet/Chart/Layout.php b/src/PhpSpreadsheet/Chart/Layout.php index b91e9f2dbe..c572a1b3f1 100644 --- a/src/PhpSpreadsheet/Chart/Layout.php +++ b/src/PhpSpreadsheet/Chart/Layout.php @@ -171,8 +171,6 @@ private function initColor(array $layout, string $name): void /** * Get Layout Target. - * - * @return ?string */ public function getLayoutTarget(): ?string { @@ -193,8 +191,6 @@ public function setLayoutTarget(?string $target): static /** * Get X-Mode. - * - * @return ?string */ public function getXMode(): ?string { @@ -217,8 +213,6 @@ public function setXMode(?string $mode): static /** * Get Y-Mode. - * - * @return ?string */ public function getYMode(): ?string { @@ -241,10 +235,8 @@ public function setYMode(?string $mode): static /** * Get X-Position. - * - * @return null|float|int */ - public function getXPosition() + public function getXPosition(): null|float|int { return $this->xPos; } @@ -283,8 +275,6 @@ public function setYPosition(float $position): static /** * Get Width. - * - * @return ?float */ public function getWidth(): ?float { diff --git a/src/PhpSpreadsheet/Chart/PlotArea.php b/src/PhpSpreadsheet/Chart/PlotArea.php index a703e533eb..7368d98c99 100644 --- a/src/PhpSpreadsheet/Chart/PlotArea.php +++ b/src/PhpSpreadsheet/Chart/PlotArea.php @@ -64,8 +64,6 @@ public function getPlotGroupCount(): int /** * Get Number of Plot Series. - * - * @return int */ public function getPlotSeriesCount(): int|float { diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index 21ffa48101..6fcfc33621 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -452,12 +452,8 @@ public function setGlowProperties(float $size, ?string $colorValue = null, ?int /** * Get Glow Property. - * - * @param array|string $property - * - * @return null|array|float|int|string */ - public function getGlowProperty($property) + public function getGlowProperty(array|string $property): null|array|float|int|string { $retVal = null; if ($property === 'size') { @@ -492,8 +488,6 @@ public function getGlowColorObject(): ChartColor /** * Get Glow Size. - * - * @return ?float */ public function getGlowSize(): ?float { @@ -673,10 +667,8 @@ public function getShadowColorObject(): ChartColor * Get Shadow Property. * * @param string|string[] $elements - * - * @return array|string */ - public function getShadowProperty($elements) + public function getShadowProperty($elements): array|string|null { if ($elements === 'color') { return [ @@ -757,10 +749,8 @@ public function setLineColorProperties(?string $value, ?int $alpha = null, ?stri /** * Get Line Color Property. - * - * @return null|int|string */ - public function getLineColorProperty(string $propertyName) + public function getLineColorProperty(string $propertyName): null|int|string { return $this->lineColor->getColorProperty($propertyName); } diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index 246ebd3324..1212a258bb 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -142,10 +142,8 @@ public function setLastModifiedBy(string $modifiedBy): self /** * @param null|float|int|string $timestamp - * - * @return float|int */ - private static function intOrFloatTimestamp($timestamp) + private static function intOrFloatTimestamp($timestamp): float|int { if ($timestamp === null) { $timestamp = (float) (new DateTime())->format('U'); @@ -165,10 +163,8 @@ private static function intOrFloatTimestamp($timestamp) /** * Get Created. - * - * @return float|int */ - public function getCreated() + public function getCreated(): float|int { return $this->created; } @@ -189,10 +185,8 @@ public function setCreated($timestamp): self /** * Get Modified. - * - * @return float|int */ - public function getModified() + public function getModified(): float|int { return $this->modified; } diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index ece024f687..c91ed8c3f8 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -7192,8 +7192,6 @@ private static function UTF8toExcelDoubleQuoted(string $value): string * Reads first 8 bytes of a string and return IEEE 754 float. * * @param string $data Binary string that is at least 8 bytes long - * - * @return float */ private static function extractNumber(string $data): int|float { @@ -7218,9 +7216,6 @@ private static function extractNumber(string $data): int|float return $value; } - /** - * @return float - */ private static function getIEEE754(int $rknum): float|int { if (($rknum & 0x02) != 0) { diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index 98952b223d..eabe6ae817 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -159,10 +159,8 @@ private static function validateTimeZone($timeZone): ?DateTimeZone * @param mixed $value Converts a date/time in ISO-8601 standard format date string to an Excel * serialized timestamp. * See https://en.wikipedia.org/wiki/ISO_8601 for details of the ISO-8601 standard format. - * - * @return float|int */ - public static function convertIsoDate(mixed $value) + public static function convertIsoDate(mixed $value): float|int { if (!is_string($value)) { throw new Exception('Non-string value supplied for Iso Date conversion'); diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index c8c9d75a2a..4c534fdaac 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -347,10 +347,8 @@ public static function setPaddingAmountExact($paddingAmountExact): void /** * Get pad amount for exact in pixels; or null if using best guess. - * - * @return null|float|int */ - public static function getPaddingAmountExact() + public static function getPaddingAmountExact(): null|float|int { return self::$paddingAmountExact; } diff --git a/src/PhpSpreadsheet/Shared/IntOrFloat.php b/src/PhpSpreadsheet/Shared/IntOrFloat.php index 060f09c883..2e20c9c301 100644 --- a/src/PhpSpreadsheet/Shared/IntOrFloat.php +++ b/src/PhpSpreadsheet/Shared/IntOrFloat.php @@ -7,12 +7,8 @@ class IntOrFloat /** * Help some functions with large results operate correctly on 32-bit, * by returning result as int when possible, float otherwise. - * - * @param float|int $value - * - * @return float|int */ - public static function evaluate($value) + public static function evaluate(float|int $value): float|int { $iValue = (int) $value; diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index a708e6a77c..eb3c6bf7b3 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -265,10 +265,8 @@ public function setRibbonXMLData($target, $xmlData): void /** * retrieve ribbon XML Data. - * - * @return null|array|string */ - public function getRibbonXMLData(string $what = 'all') //we need some constants here... + public function getRibbonXMLData(string $what = 'all'): null|array|string //we need some constants here... { $returnData = null; $what = strtolower($what); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php index d5cee1d24a..bc0c9c0d9e 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php @@ -114,10 +114,7 @@ public function evaluateConditional(Conditional $conditional): bool }; } - /** - * @return float|int|string - */ - protected function wrapValue(mixed $value) + protected function wrapValue(mixed $value): float|int|string { if (!is_numeric($value)) { if (is_bool($value)) { @@ -132,18 +129,12 @@ protected function wrapValue(mixed $value) return $value; } - /** - * @return float|int|string - */ - protected function wrapCellValue() + protected function wrapCellValue(): float|int|string { return $this->wrapValue($this->cell->getCalculatedValue()); } - /** - * @return float|int|string - */ - protected function conditionCellAdjustment(array $matches) + protected function conditionCellAdjustment(array $matches): float|int|string { $column = $matches[6]; $row = $matches[7]; diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php index 289647c4e2..0c84e8b15c 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php @@ -69,10 +69,7 @@ protected function operand(int $index, mixed $operand, string $operandValueType $this->operandValueType[$index] = $operandValueType; } - /** - * @return float|int|string - */ - protected function wrapValue(mixed $value, string $operandValueType) + protected function wrapValue(mixed $value, string $operandValueType): float|int|string { if (!is_numeric($value) && !is_bool($value) && null !== $value) { if ($operandValueType === Wizard::VALUE_TYPE_LITERAL) { diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index fa1bf202ae..121fb2f9b8 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -251,10 +251,8 @@ public function getAttributes(): array * Get specific AutoFilter Column Attribute. * * @param string $name Attribute Name - * - * @return null|int|string */ - public function getAttribute(string $name) + public function getAttribute(string $name): null|int|string { if (isset($this->attributes[$name])) { return $this->attributes[$name]; diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 58ea06f1ef..7b3fe83afe 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -784,8 +784,6 @@ public function addPrintAreaByColumnAndRow(int $column1, int $row1, int $column2 /** * Get first page number. - * - * @return ?int */ public function getFirstPageNumber(): ?int { diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index 78459e3e29..b6054fa279 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -59,8 +59,6 @@ public function __construct() /** * Get ZoomScale. - * - * @return ?int */ public function getZoomScale(): ?int { @@ -90,8 +88,6 @@ public function setZoomScale(?int $zoomScale): static /** * Get ZoomScaleNormal. - * - * @return ?int */ public function getZoomScaleNormal(): ?int { diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index 0e93d9bb20..16a0ac0400 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -142,8 +142,6 @@ public function setFont(string $fontName) /** * Get Paper Size. - * - * @return ?int */ public function getPaperSize(): ?int { From 816b91d0b4a0c7285a9e3fc88c58f7730d922044 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 10 Dec 2023 19:04:19 +0100 Subject: [PATCH 09/25] BREAKING Drop all deprecated things --- .../Calculation/Calculation.php | 14 +- src/PhpSpreadsheet/Calculation/Database.php | 422 ----- src/PhpSpreadsheet/Calculation/DateTime.php | 886 --------- .../Calculation/Engineering.php | 1385 -------------- src/PhpSpreadsheet/Calculation/Financial.php | 1372 -------------- src/PhpSpreadsheet/Calculation/Functions.php | 333 ---- .../Calculation/Information/ExcelError.php | 11 - src/PhpSpreadsheet/Calculation/Logical.php | 303 --- src/PhpSpreadsheet/Calculation/LookupRef.php | 396 ---- src/PhpSpreadsheet/Calculation/MathTrig.php | 1430 -------------- .../Calculation/Statistical.php | 1676 ----------------- src/PhpSpreadsheet/Calculation/TextData.php | 417 ---- src/PhpSpreadsheet/Calculation/Web.php | 30 - src/PhpSpreadsheet/Chart/Axis.php | 12 - src/PhpSpreadsheet/Chart/Chart.php | 26 - src/PhpSpreadsheet/Chart/ChartColor.php | 4 +- src/PhpSpreadsheet/Chart/Properties.php | 9 - src/PhpSpreadsheet/Reader/Html.php | 30 - .../Reader/Security/XmlScanner.php | 10 - src/PhpSpreadsheet/Reader/Slk.php | 35 - src/PhpSpreadsheet/Settings.php | 26 - src/PhpSpreadsheet/Shared/Drawing.php | 43 +- src/PhpSpreadsheet/Shared/Font.php | 9 - src/PhpSpreadsheet/Style/NumberFormat.php | 6 - src/PhpSpreadsheet/Worksheet/Worksheet.php | 327 ---- src/PhpSpreadsheet/Writer/Html.php | 33 - .../Functions/DateTime/MovedFunctionsTest.php | 62 - .../Functions/DeprecatedExcelErrorTest.php | 55 - .../Engineering/MovedBitwiseTest.php | 24 - .../Engineering/MovedFunctionsTest.php | 88 - .../Financial/MovedFunctionsTest.php | 67 - .../Information/DeprecatedFunctionsTest.php | 51 - .../Logical/DeprecatedFunctionsTest.php | 30 - .../Functions/LookupRef/IndirectTest.php | 2 +- .../LookupRef/MovedFunctionsTest.php | 103 - .../Functions/MathTrig/MovedFunctionsTest.php | 110 -- .../Statistical/MovedFunctionsTest.php | 116 -- .../Functions/TextData/DeprecatedTest.php | 45 - .../Calculation/FunctionsTest.php | 3 +- .../Chart/GridlinesLineStyleTest.php | 8 +- .../DocumentGeneratorTest.php | 10 +- .../Worksheet/ByColumnAndRowTest.php | 30 +- 42 files changed, 40 insertions(+), 10009 deletions(-) delete mode 100644 src/PhpSpreadsheet/Calculation/Database.php delete mode 100644 src/PhpSpreadsheet/Calculation/DateTime.php delete mode 100644 src/PhpSpreadsheet/Calculation/Engineering.php delete mode 100644 src/PhpSpreadsheet/Calculation/Financial.php delete mode 100644 src/PhpSpreadsheet/Calculation/Logical.php delete mode 100644 src/PhpSpreadsheet/Calculation/LookupRef.php delete mode 100644 src/PhpSpreadsheet/Calculation/MathTrig.php delete mode 100644 src/PhpSpreadsheet/Calculation/Statistical.php delete mode 100644 src/PhpSpreadsheet/Calculation/TextData.php delete mode 100644 src/PhpSpreadsheet/Calculation/Web.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MovedFunctionsTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/DeprecatedExcelErrorTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/MovedBitwiseTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/MovedFunctionsTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MovedFunctionsTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Information/DeprecatedFunctionsTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Logical/DeprecatedFunctionsTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MovedFunctionsTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/MovedFunctionsTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MovedFunctionsTest.php delete mode 100644 tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 5f8aa754f0..88caeefe71 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -6,6 +6,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Engine\CyclicReferenceStack; use PhpOffice\PhpSpreadsheet\Calculation\Engine\Logger; use PhpOffice\PhpSpreadsheet\Calculation\Engine\Operands; +use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Calculation\Token\Stack; use PhpOffice\PhpSpreadsheet\Cell\AddressRange; use PhpOffice\PhpSpreadsheet\Cell\Cell; @@ -117,17 +118,6 @@ class Calculation */ private Logger $debugLog; - /** - * Flag to determine how formula errors should be handled - * If true, then a user error will be triggered - * If false, then an exception will be thrown. - * - * @var ?bool - * - * @deprecated 1.25.2 use setSuppressFormulaErrors() instead - */ - public ?bool $suppressFormulaErrors = null; - private bool $suppressFormulaErrorsNew = false; /** @@ -2874,7 +2864,7 @@ public static function getExcelConstants(string $key): mixed ], 'NAME.ERROR' => [ 'argumentCount' => '*', - 'functionCall' => [Functions::class, 'NAME'], + 'functionCall' => [ExcelError::class, 'NAME'], ], 'WILDCARDMATCH' => [ 'argumentCount' => '2', diff --git a/src/PhpSpreadsheet/Calculation/Database.php b/src/PhpSpreadsheet/Calculation/Database.php deleted file mode 100644 index adb0f720fe..0000000000 --- a/src/PhpSpreadsheet/Calculation/Database.php +++ /dev/null @@ -1,422 +0,0 @@ -getMessage(); - } - } - - /** - * DATETIMENOW. - * - * Returns the current date and time. - * The NOW function is useful when you need to display the current date and time on a worksheet or - * calculate a value based on the current date and time, and have that value updated each time you - * open the worksheet. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date - * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * NOW() - * - * @deprecated 1.18.0 - * Use the now method in the DateTimeExcel\Current class instead - * @see DateTimeExcel\Current::now() - * - * @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 - */ - public static function DATETIMENOW(): mixed - { - return DateTimeExcel\Current::now(); - } - - /** - * DATENOW. - * - * Returns the current date. - * The NOW function is useful when you need to display the current date and time on a worksheet or - * calculate a value based on the current date and time, and have that value updated each time you - * open the worksheet. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date - * and time format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * TODAY() - * - * @deprecated 1.18.0 - * Use the today method in the DateTimeExcel\Current class instead - * @see DateTimeExcel\Current::today() - * - * @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 - */ - public static function DATENOW(): mixed - { - return DateTimeExcel\Current::today(); - } - - /** - * DATE. - * - * The DATE function returns a value that represents a particular date. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date - * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * - * Excel Function: - * DATE(year,month,day) - * - * @deprecated 1.18.0 - * Use the fromYMD method in the DateTimeExcel\Date class instead - * @see DateTimeExcel\Date::fromYMD() - * - * PhpSpreadsheet is a lot more forgiving than MS Excel when passing non numeric values to this function. - * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, - * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. - * - * @param int $year The value of the year argument can include one to four digits. - * Excel interprets the year argument according to the configured - * date system: 1900 or 1904. - * If year is between 0 (zero) and 1899 (inclusive), Excel adds that - * value to 1900 to calculate the year. For example, DATE(108,1,2) - * returns January 2, 2008 (1900+108). - * If year is between 1900 and 9999 (inclusive), Excel uses that - * value as the year. For example, DATE(2008,1,2) returns January 2, - * 2008. - * If year is less than 0 or is 10000 or greater, Excel returns the - * #NUM! error value. - * @param int $month A positive or negative integer representing the month of the year - * from 1 to 12 (January to December). - * If month is greater than 12, month adds that number of months to - * the first month in the year specified. For example, DATE(2008,14,2) - * returns the serial number representing February 2, 2009. - * If month is less than 1, month subtracts the magnitude of that - * number of months, plus 1, from the first month in the year - * specified. For example, DATE(2008,-3,2) returns the serial number - * representing September 2, 2007. - * @param int $day A positive or negative integer representing the day of the month - * from 1 to 31. - * If day is greater than the number of days in the month specified, - * day adds that number of days to the first day in the month. For - * example, DATE(2008,1,35) returns the serial number representing - * February 4, 2008. - * If day is less than 1, day subtracts the magnitude that number of - * days, plus one, from the first day of the month specified. For - * example, DATE(2008,1,-15) returns the serial number representing - * December 16, 2007. - * - * @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 - */ - public static function DATE(int $year = 0, int $month = 1, int $day = 1): mixed - { - return DateTimeExcel\Date::fromYMD($year, $month, $day); - } - - /** - * TIME. - * - * The TIME function returns a value that represents a particular time. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time - * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * TIME(hour,minute,second) - * - * @deprecated 1.18.0 - * Use the fromHMS method in the DateTimeExcel\Time class instead - * @see DateTimeExcel\Time::fromHMS() - * - * @param int $hour A number from 0 (zero) to 32767 representing the hour. - * Any value greater than 23 will be divided by 24 and the remainder - * will be treated as the hour value. For example, TIME(27,0,0) = - * TIME(3,0,0) = .125 or 3:00 AM. - * @param int $minute A number from 0 to 32767 representing the minute. - * Any value greater than 59 will be converted to hours and minutes. - * For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM. - * @param int $second A number from 0 to 32767 representing the second. - * Any value greater than 59 will be converted to hours, minutes, - * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 - * or 12:33:20 AM - * - * @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(int $hour = 0, int $minute = 0, int $second = 0): string|float|int|\DateTime|array - { - return DateTimeExcel\Time::fromHMS($hour, $minute, $second); - } - - /** - * DATEVALUE. - * - * Returns a value that represents a particular date. - * Use DATEVALUE to convert a date represented by a text string to an Excel or PHP date/time stamp - * value. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the date - * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * DATEVALUE(dateValue) - * - * @deprecated 1.18.0 - * Use the fromString method in the DateTimeExcel\DateValue class instead - * @see DateTimeExcel\DateValue::fromString() - * - * @param string $dateValue Text that represents a date in a Microsoft Excel date format. - * For example, "1/30/2008" or "30-Jan-2008" are text strings within - * quotation marks that represent dates. Using the default date - * system in Excel for Windows, date_text must represent a date from - * January 1, 1900, to December 31, 9999. Using the default date - * system in Excel for the Macintosh, date_text must represent a date - * from January 1, 1904, to December 31, 9999. DATEVALUE returns the - * #VALUE! error value if date_text is out of this range. - * - * @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 - */ - public static function DATEVALUE(string $dateValue): mixed - { - return DateTimeExcel\DateValue::fromString($dateValue); - } - - /** - * TIMEVALUE. - * - * Returns a value that represents a particular time. - * Use TIMEVALUE to convert a time represented by a text string to an Excel or PHP date/time stamp - * value. - * - * NOTE: When used in a Cell Formula, MS Excel changes the cell format so that it matches the time - * format of your regional settings. PhpSpreadsheet does not change cell formatting in this way. - * - * Excel Function: - * TIMEVALUE(timeValue) - * - * @deprecated 1.18.0 - * Use the fromString method in the DateTimeExcel\TimeValue class instead - * @see DateTimeExcel\TimeValue::fromString() - * - * @param string $timeValue A text string that represents a time in any one of the Microsoft - * Excel time formats; for example, "6:45 PM" and "18:45" text strings - * within quotation marks that represent time. - * Date information in time_text is ignored. - * - * @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(string $timeValue): string|\Datetime|int|float|array - { - return DateTimeExcel\TimeValue::fromString($timeValue); - } - - /** - * DATEDIF. - * - * Excel Function: - * DATEDIF(startdate, enddate, unit) - * - * @deprecated 1.18.0 - * Use the interval method in the DateTimeExcel\Difference class instead - * @see DateTimeExcel\Difference::interval() - * - * @param mixed $startDate Excel date serial value, PHP date/time stamp, PHP DateTime object - * or a standard date string - * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object - * or a standard date string - * @param array|string $unit - * - * @return array|int|string Interval between the dates - */ - public static function DATEDIF(mixed $startDate = 0, mixed $endDate = 0, $unit = 'D') - { - return DateTimeExcel\Difference::interval($startDate, $endDate, $unit); - } - - /** - * DAYS. - * - * Returns the number of days between two dates - * - * Excel Function: - * DAYS(endDate, startDate) - * - * @deprecated 1.18.0 - * Use the between method in the DateTimeExcel\Days class instead - * @see DateTimeExcel\Days::between() - * - * @param array|DateTimeInterface|float|int|string $endDate Excel date serial value (float), - * PHP date timestamp (integer), PHP DateTime object, or a standard date string - * @param array|DateTimeInterface|float|int|string $startDate Excel date serial value (float), - * PHP date timestamp (integer), PHP DateTime object, or a standard date string - * - * @return array|int|string Number of days between start date and end date or an error - */ - public static function DAYS($endDate = 0, $startDate = 0) - { - return DateTimeExcel\Days::between($endDate, $startDate); - } - - /** - * DAYS360. - * - * Returns the number of days between two dates based on a 360-day year (twelve 30-day months), - * which is used in some accounting calculations. Use this function to help compute payments if - * your accounting system is based on twelve 30-day months. - * - * Excel Function: - * DAYS360(startDate,endDate[,method]) - * - * @deprecated 1.18.0 - * Use the between method in the DateTimeExcel\Days360 class instead - * @see DateTimeExcel\Days360::between() - * - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param array|bool $method US or European Method - * FALSE or omitted: U.S. (NASD) method. If the starting date is - * the last day of a month, it becomes equal to the 30th of the - * same month. If the ending date is the last day of a month and - * the starting date is earlier than the 30th of a month, the - * ending date becomes equal to the 1st of the next month; - * otherwise the ending date becomes equal to the 30th of the - * same month. - * TRUE: European method. Starting dates and ending dates that - * occur on the 31st of a month become equal to the 30th of the - * same month. - * - * @return array|int|string Number of days between start date and end date - */ - public static function DAYS360(mixed $startDate = 0, mixed $endDate = 0, $method = false): string|int|array - { - return DateTimeExcel\Days360::between($startDate, $endDate, $method); - } - - /** - * YEARFRAC. - * - * Calculates the fraction of the year represented by the number of whole days between two dates - * (the start_date and the end_date). - * Use the YEARFRAC worksheet function to identify the proportion of a whole year's benefits or - * obligations to assign to a specific term. - * - * Excel Function: - * YEARFRAC(startDate,endDate[,method]) - * - * @deprecated 1.18.0 - * Use the fraction method in the DateTimeExcel\YearFrac class instead - * @see DateTimeExcel\YearFrac::fraction() - * - * See https://lists.oasis-open.org/archives/office-formula/200806/msg00039.html - * for description of algorithm used in Excel - * - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param array|int $method Method used for the calculation - * 0 or omitted US (NASD) 30/360 - * 1 Actual/actual - * 2 Actual/360 - * 3 Actual/365 - * 4 European 30/360 - * - * @return array|float|string fraction of the year, or a string containing an error - */ - public static function YEARFRAC(mixed $startDate = 0, mixed $endDate = 0, $method = 0): string|int|float|array - { - return DateTimeExcel\YearFrac::fraction($startDate, $endDate, $method); - } - - /** - * NETWORKDAYS. - * - * Returns the number of whole working days between start_date and end_date. Working days - * exclude weekends and any dates identified in holidays. - * Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days - * worked during a specific term. - * - * Excel Function: - * NETWORKDAYS(startDate,endDate[,holidays[,holiday[,...]]]) - * - * @deprecated 1.18.0 - * Use the count method in the DateTimeExcel\NetworkDays class instead - * @see DateTimeExcel\NetworkDays::count() - * - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param mixed $endDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Interval between the dates - */ - public static function NETWORKDAYS(mixed $startDate, mixed $endDate, mixed ...$dateArgs): string|int|array - { - return DateTimeExcel\NetworkDays::count($startDate, $endDate, ...$dateArgs); - } - - /** - * WORKDAY. - * - * Returns the date that is the indicated number of working days before or after a date (the - * starting date). Working days exclude weekends and any dates identified as holidays. - * Use WORKDAY to exclude weekends or holidays when you calculate invoice due dates, expected - * delivery times, or the number of days of work performed. - * - * Excel Function: - * WORKDAY(startDate,endDays[,holidays[,holiday[,...]]]) - * - * @deprecated 1.18.0 - * Use the date method in the DateTimeExcel\WorkDay class instead - * @see DateTimeExcel\WorkDay::date() - * - * @param mixed $startDate Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $endDays The number of nonweekend and nonholiday days before or after - * startDate. A positive value for days yields a future date; a - * negative value yields a past date. - * - * @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 - */ - public static function WORKDAY(mixed $startDate, int $endDays, mixed ...$dateArgs): mixed - { - return DateTimeExcel\WorkDay::date($startDate, $endDays, ...$dateArgs); - } - - /** - * DAYOFMONTH. - * - * Returns the day of the month, for a specified date. The day is given as an integer - * ranging from 1 to 31. - * - * Excel Function: - * DAY(dateValue) - * - * @deprecated 1.18.0 - * Use the day method in the DateTimeExcel\DateParts class instead - * @see DateTimeExcel\DateParts::day() - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Day of the month - */ - public static function DAYOFMONTH(mixed $dateValue = 1): int|string|array - { - return DateTimeExcel\DateParts::day($dateValue); - } - - /** - * WEEKDAY. - * - * Returns the day of the week for a specified date. The day is given as an integer - * ranging from 0 to 7 (dependent on the requested style). - * - * Excel Function: - * WEEKDAY(dateValue[,style]) - * - * @deprecated 1.18.0 - * Use the day method in the DateTimeExcel\Week class instead - * @see DateTimeExcel\Week::day() - * - * @param float|int|string $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $style A number that determines the type of return value - * 1 or omitted Numbers 1 (Sunday) through 7 (Saturday). - * 2 Numbers 1 (Monday) through 7 (Sunday). - * 3 Numbers 0 (Monday) through 6 (Sunday). - * - * @return array|int|string Day of the week value - */ - public static function WEEKDAY($dateValue = 1, int $style = 1): string|int|array - { - return DateTimeExcel\Week::day($dateValue, $style); - } - - /** - * STARTWEEK_SUNDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_SUNDAY - * @see DateTimeExcel\Constants::STARTWEEK_SUNDAY - */ - const STARTWEEK_SUNDAY = 1; - - /** - * STARTWEEK_MONDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_MONDAY - * @see DateTimeExcel\Constants::STARTWEEK_MONDAY - */ - const STARTWEEK_MONDAY = 2; - - /** - * STARTWEEK_MONDAY_ALT. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_MONDAY_ALT - * @see DateTimeExcel\Constants::STARTWEEK_MONDAY_ALT - */ - const STARTWEEK_MONDAY_ALT = 11; - - /** - * STARTWEEK_TUESDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_TUESDAY - * @see DateTimeExcel\Constants::STARTWEEK_TUESDAY - */ - const STARTWEEK_TUESDAY = 12; - - /** - * STARTWEEK_WEDNESDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_WEDNESDAY - * @see DateTimeExcel\Constants::STARTWEEK_WEDNESDAY - */ - const STARTWEEK_WEDNESDAY = 13; - - /** - * STARTWEEK_THURSDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_THURSDAY - * @see DateTimeExcel\Constants::STARTWEEK_THURSDAY - */ - const STARTWEEK_THURSDAY = 14; - - /** - * STARTWEEK_FRIDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_FRIDAY - * @see DateTimeExcel\Constants::STARTWEEK_FRIDAY - */ - const STARTWEEK_FRIDAY = 15; - - /** - * STARTWEEK_SATURDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_SATURDAY - * @see DateTimeExcel\Constants::STARTWEEK_SATURDAY - */ - const STARTWEEK_SATURDAY = 16; - - /** - * STARTWEEK_SUNDAY_ALT. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_SUNDAY_ALT - * @see DateTimeExcel\Constants::STARTWEEK_SUNDAY_ALT - */ - const STARTWEEK_SUNDAY_ALT = 17; - - /** - * DOW_SUNDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::DOW_SUNDAY - * @see DateTimeExcel\Constants::DOW_SUNDAY - */ - const DOW_SUNDAY = 1; - - /** - * DOW_MONDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::DOW_MONDAY - * @see DateTimeExcel\Constants::DOW_MONDAY - */ - const DOW_MONDAY = 2; - - /** - * DOW_TUESDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::DOW_TUESDAY - * @see DateTimeExcel\Constants::DOW_TUESDAY - */ - const DOW_TUESDAY = 3; - - /** - * DOW_WEDNESDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::DOW_WEDNESDAY - * @see DateTimeExcel\Constants::DOW_WEDNESDAY - */ - const DOW_WEDNESDAY = 4; - - /** - * DOW_THURSDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::DOW_THURSDAY - * @see DateTimeExcel\Constants::DOW_THURSDAY - */ - const DOW_THURSDAY = 5; - - /** - * DOW_FRIDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::DOW_FRIDAY - * @see DateTimeExcel\Constants::DOW_FRIDAY - */ - const DOW_FRIDAY = 6; - - /** - * DOW_SATURDAY. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::DOW_SATURDAY - * @see DateTimeExcel\Constants::DOW_SATURDAY - */ - const DOW_SATURDAY = 7; - - /** - * STARTWEEK_MONDAY_ISO. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::STARTWEEK_MONDAY_ISO - * @see DateTimeExcel\Constants::STARTWEEK_MONDAY_ISO - */ - const STARTWEEK_MONDAY_ISO = 21; - - /** - * METHODARR. - * - * @deprecated 1.18.0 - * Use DateTimeExcel\Constants::METHODARR - * @see DateTimeExcel\Constants::METHODARR - */ - const METHODARR = [ - self::STARTWEEK_SUNDAY => self::DOW_SUNDAY, - self::DOW_MONDAY, - self::STARTWEEK_MONDAY_ALT => self::DOW_MONDAY, - self::DOW_TUESDAY, - self::DOW_WEDNESDAY, - self::DOW_THURSDAY, - self::DOW_FRIDAY, - self::DOW_SATURDAY, - self::DOW_SUNDAY, - self::STARTWEEK_MONDAY_ISO => self::STARTWEEK_MONDAY_ISO, - ]; - - /** - * WEEKNUM. - * - * Returns the week of the year for a specified date. - * The WEEKNUM function considers the week containing January 1 to be the first week of the year. - * However, there is a European standard that defines the first week as the one with the majority - * of days (four or more) falling in the new year. This means that for years in which there are - * three days or less in the first week of January, the WEEKNUM function returns week numbers - * that are incorrect according to the European standard. - * - * Excel Function: - * WEEKNUM(dateValue[,style]) - * - * @deprecated 1.18.0 - * Use the number method in the DateTimeExcel\Week class instead - * @see DateTimeExcel\Week::number() - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $method Week begins on Sunday or Monday - * 1 or omitted Week begins on Sunday. - * 2 Week begins on Monday. - * 11 Week begins on Monday. - * 12 Week begins on Tuesday. - * 13 Week begins on Wednesday. - * 14 Week begins on Thursday. - * 15 Week begins on Friday. - * 16 Week begins on Saturday. - * 17 Week begins on Sunday. - * 21 ISO (Jan. 4 is week 1, begins on Monday). - * - * @return array|int|string Week Number - */ - public static function WEEKNUM(mixed $dateValue = 1, int $method = self::STARTWEEK_SUNDAY): int|string|array - { - return DateTimeExcel\Week::number($dateValue, $method); - } - - /** - * ISOWEEKNUM. - * - * Returns the ISO 8601 week number of the year for a specified date. - * - * Excel Function: - * ISOWEEKNUM(dateValue) - * - * @deprecated 1.18.0 - * Use the isoWeekNumber method in the DateTimeExcel\Week class instead - * @see DateTimeExcel\Week::isoWeekNumber() - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Week Number - */ - public static function ISOWEEKNUM(mixed $dateValue = 1): int|string|array - { - return DateTimeExcel\Week::isoWeekNumber($dateValue); - } - - /** - * MONTHOFYEAR. - * - * Returns the month of a date represented by a serial number. - * The month is given as an integer, ranging from 1 (January) to 12 (December). - * - * Excel Function: - * MONTH(dateValue) - * - * @deprecated 1.18.0 - * Use the month method in the DateTimeExcel\DateParts class instead - * @see DateTimeExcel\DateParts::month() - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Month of the year - */ - public static function MONTHOFYEAR(mixed $dateValue = 1): string|int|array - { - return DateTimeExcel\DateParts::month($dateValue); - } - - /** - * YEAR. - * - * Returns the year corresponding to a date. - * The year is returned as an integer in the range 1900-9999. - * - * Excel Function: - * YEAR(dateValue) - * - * @deprecated 1.18.0 - * Use the ear method in the DateTimeExcel\DateParts class instead - * @see DateTimeExcel\DateParts::year() - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * - * @return array|int|string Year - */ - public static function YEAR(mixed $dateValue = 1): string|int|array - { - return DateTimeExcel\DateParts::year($dateValue); - } - - /** - * HOUROFDAY. - * - * Returns the hour of a time value. - * The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.). - * - * Excel Function: - * HOUR(timeValue) - * - * @deprecated 1.18.0 - * Use the hour method in the DateTimeExcel\TimeParts class instead - * @see DateTimeExcel\TimeParts::hour() - * - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard time string - * - * @return array|int|string Hour - */ - public static function HOUROFDAY(mixed $timeValue = 0): string|int|array - { - return DateTimeExcel\TimeParts::hour($timeValue); - } - - /** - * MINUTE. - * - * Returns the minutes of a time value. - * The minute is given as an integer, ranging from 0 to 59. - * - * Excel Function: - * MINUTE(timeValue) - * - * @deprecated 1.18.0 - * Use the minute method in the DateTimeExcel\TimeParts class instead - * @see DateTimeExcel\TimeParts::minute() - * - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard time string - * - * @return array|int|string Minute - */ - public static function MINUTE(mixed $timeValue = 0): string|int|array - { - return DateTimeExcel\TimeParts::minute($timeValue); - } - - /** - * SECOND. - * - * Returns the seconds of a time value. - * The second is given as an integer in the range 0 (zero) to 59. - * - * Excel Function: - * SECOND(timeValue) - * - * @deprecated 1.18.0 - * Use the second method in the DateTimeExcel\TimeParts class instead - * @see DateTimeExcel\TimeParts::second() - * - * @param mixed $timeValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard time string - * - * @return array|int|string Second - */ - public static function SECOND(mixed $timeValue = 0): string|int|array - { - return DateTimeExcel\TimeParts::second($timeValue); - } - - /** - * EDATE. - * - * Returns the serial number that represents the date that is the indicated number of months - * before or after a specified date (the start_date). - * Use EDATE to calculate maturity dates or due dates that fall on the same day of the month - * as the date of issue. - * - * Excel Function: - * EDATE(dateValue,adjustmentMonths) - * - * @deprecated 1.18.0 - * Use the adjust method in the DateTimeExcel\Edate class instead - * @see DateTimeExcel\Month::adjust() - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $adjustmentMonths The number of months before or after start_date. - * A positive value for months yields a future date; - * a negative value yields a past date. - * - * @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 - */ - public static function EDATE(mixed $dateValue = 1, int $adjustmentMonths = 0): mixed - { - return DateTimeExcel\Month::adjust($dateValue, $adjustmentMonths); - } - - /** - * EOMONTH. - * - * Returns the date value for the last day of the month that is the indicated number of months - * before or after start_date. - * Use EOMONTH to calculate maturity dates or due dates that fall on the last day of the month. - * - * Excel Function: - * EOMONTH(dateValue,adjustmentMonths) - * - * @deprecated 1.18.0 - * Use the lastDay method in the DateTimeExcel\EoMonth class instead - * @see DateTimeExcel\Month::lastDay() - * - * @param mixed $dateValue Excel date serial value (float), PHP date timestamp (integer), - * PHP DateTime object, or a standard date string - * @param int $adjustmentMonths The number of months before or after start_date. - * A positive value for months yields a future date; - * a negative value yields a past date. - * - * @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 - */ - public static function EOMONTH(mixed $dateValue = 1, int $adjustmentMonths = 0): mixed - { - return DateTimeExcel\Month::lastDay($dateValue, $adjustmentMonths); - } -} diff --git a/src/PhpSpreadsheet/Calculation/Engineering.php b/src/PhpSpreadsheet/Calculation/Engineering.php deleted file mode 100644 index 81cc891ef1..0000000000 --- a/src/PhpSpreadsheet/Calculation/Engineering.php +++ /dev/null @@ -1,1385 +0,0 @@ - 511, DEC2BIN returns the #NUM! error - * value. - * If number is nonnumeric, DEC2BIN returns the #VALUE! error value. - * If DEC2BIN requires more than places characters, it returns the #NUM! - * error value. - * @param mixed $places The number of characters to use. If places is omitted, DEC2BIN uses - * the minimum number of characters necessary. Places is useful for - * padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, DEC2BIN returns the #VALUE! error value. - * If places is zero or negative, DEC2BIN returns the #NUM! error value. - */ - public static function DECTOBIN(mixed $x, mixed $places = null): string|array - { - return Engineering\ConvertDecimal::toBinary($x, $places); - } - - /** - * DECTOHEX. - * - * Return a decimal value as hex. - * - * Excel Function: - * DEC2HEX(x[,places]) - * - * @deprecated 1.17.0 - * Use the toHex() method in the Engineering\ConvertDecimal class instead - * @see Engineering\ConvertDecimal::toHex() - * - * @param mixed $x The decimal integer you want to convert. If number is negative, - * places is ignored and DEC2HEX returns a 10-character (40-bit) - * hexadecimal number in which the most significant bit is the sign - * bit. The remaining 39 bits are magnitude bits. Negative numbers - * are represented using two's-complement notation. - * If number < -549,755,813,888 or if number > 549,755,813,887, - * DEC2HEX returns the #NUM! error value. - * If number is nonnumeric, DEC2HEX returns the #VALUE! error value. - * If DEC2HEX requires more than places characters, it returns the - * #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, DEC2HEX uses - * the minimum number of characters necessary. Places is useful for - * padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, DEC2HEX returns the #VALUE! error value. - * If places is zero or negative, DEC2HEX returns the #NUM! error value. - */ - public static function DECTOHEX(mixed $x, mixed $places = null): string|array - { - return Engineering\ConvertDecimal::toHex($x, $places); - } - - /** - * DECTOOCT. - * - * Return an decimal value as octal. - * - * Excel Function: - * DEC2OCT(x[,places]) - * - * @deprecated 1.17.0 - * Use the toOctal() method in the Engineering\ConvertDecimal class instead - * @see Engineering\ConvertDecimal::toOctal() - * - * @param mixed $x The decimal integer you want to convert. If number is negative, - * places is ignored and DEC2OCT returns a 10-character (30-bit) - * octal number in which the most significant bit is the sign bit. - * The remaining 29 bits are magnitude bits. Negative numbers are - * represented using two's-complement notation. - * If number < -536,870,912 or if number > 536,870,911, DEC2OCT - * returns the #NUM! error value. - * If number is nonnumeric, DEC2OCT returns the #VALUE! error value. - * If DEC2OCT requires more than places characters, it returns the - * #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, DEC2OCT uses - * the minimum number of characters necessary. Places is useful for - * padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, DEC2OCT returns the #VALUE! error value. - * If places is zero or negative, DEC2OCT returns the #NUM! error value. - */ - public static function DECTOOCT(mixed $x, mixed $places = null): string|array - { - return Engineering\ConvertDecimal::toOctal($x, $places); - } - - /** - * HEXTOBIN. - * - * Return a hex value as binary. - * - * Excel Function: - * HEX2BIN(x[,places]) - * - * @deprecated 1.17.0 - * Use the toBinary() method in the Engineering\ConvertHex class instead - * @see Engineering\ConvertHex::toBinary() - * - * @param mixed $x the hexadecimal number (as a string) that you want to convert. - * Number cannot contain more than 10 characters. - * The most significant bit of number is the sign bit (40th bit from the right). - * The remaining 9 bits are magnitude bits. - * Negative numbers are represented using two's-complement notation. - * If number is negative, HEX2BIN ignores places and returns a 10-character binary number. - * If number is negative, it cannot be less than FFFFFFFE00, - * and if number is positive, it cannot be greater than 1FF. - * If number is not a valid hexadecimal number, HEX2BIN returns the #NUM! error value. - * If HEX2BIN requires more than places characters, it returns the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, - * HEX2BIN uses the minimum number of characters necessary. Places - * is useful for padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, HEX2BIN returns the #VALUE! error value. - * If places is negative, HEX2BIN returns the #NUM! error value. - * - * @return array|string - */ - public static function HEXTOBIN(mixed $x, mixed $places = null) - { - return Engineering\ConvertHex::toBinary($x, $places); - } - - /** - * HEXTODEC. - * - * Return a hex value as decimal. - * - * Excel Function: - * HEX2DEC(x) - * - * @deprecated 1.17.0 - * Use the toDecimal() method in the Engineering\ConvertHex class instead - * @see Engineering\ConvertHex::toDecimal() - * - * @param mixed $x The hexadecimal number (as a string) that you want to convert. This number cannot - * contain more than 10 characters (40 bits). The most significant - * bit of number is the sign bit. The remaining 39 bits are magnitude - * bits. Negative numbers are represented using two's-complement - * notation. - * If number is not a valid hexadecimal number, HEX2DEC returns the - * #NUM! error value. - * - * @return array|string - */ - public static function HEXTODEC(mixed $x) - { - return Engineering\ConvertHex::toDecimal($x); - } - - /** - * HEXTOOCT. - * - * Return a hex value as octal. - * - * Excel Function: - * HEX2OCT(x[,places]) - * - * @deprecated 1.17.0 - * Use the toOctal() method in the Engineering\ConvertHex class instead - * @see Engineering\ConvertHex::toOctal() - * - * @param mixed $x The hexadecimal number (as a string) that you want to convert. Number cannot - * contain more than 10 characters. The most significant bit of - * number is the sign bit. The remaining 39 bits are magnitude - * bits. Negative numbers are represented using two's-complement - * notation. - * If number is negative, HEX2OCT ignores places and returns a - * 10-character octal number. - * If number is negative, it cannot be less than FFE0000000, and - * if number is positive, it cannot be greater than 1FFFFFFF. - * If number is not a valid hexadecimal number, HEX2OCT returns - * the #NUM! error value. - * If HEX2OCT requires more than places characters, it returns - * the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, HEX2OCT - * uses the minimum number of characters necessary. Places is - * useful for padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, HEX2OCT returns the #VALUE! error - * value. - * If places is negative, HEX2OCT returns the #NUM! error value. - * - * @return array|string - */ - public static function HEXTOOCT(mixed $x, mixed $places = null) - { - return Engineering\ConvertHex::toOctal($x, $places); - } - - /** - * OCTTOBIN. - * - * Return an octal value as binary. - * - * Excel Function: - * OCT2BIN(x[,places]) - * - * @deprecated 1.17.0 - * Use the toBinary() method in the Engineering\ConvertOctal class instead - * @see Engineering\ConvertOctal::toBinary() - * - * @param mixed $x The octal number you want to convert. Number may not - * contain more than 10 characters. The most significant - * bit of number is the sign bit. The remaining 29 bits - * are magnitude bits. Negative numbers are represented - * using two's-complement notation. - * If number is negative, OCT2BIN ignores places and returns - * a 10-character binary number. - * If number is negative, it cannot be less than 7777777000, - * and if number is positive, it cannot be greater than 777. - * If number is not a valid octal number, OCT2BIN returns - * the #NUM! error value. - * If OCT2BIN requires more than places characters, it - * returns the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, - * OCT2BIN uses the minimum number of characters necessary. - * Places is useful for padding the return value with - * leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, OCT2BIN returns the #VALUE! - * error value. - * If places is negative, OCT2BIN returns the #NUM! error - * value. - * - * @return array|string - */ - public static function OCTTOBIN(mixed $x, mixed $places = null) - { - return Engineering\ConvertOctal::toBinary($x, $places); - } - - /** - * OCTTODEC. - * - * Return an octal value as decimal. - * - * Excel Function: - * OCT2DEC(x) - * - * @deprecated 1.17.0 - * Use the toDecimal() method in the Engineering\ConvertOctal class instead - * @see Engineering\ConvertOctal::toDecimal() - * - * @param mixed $x The octal number you want to convert. Number may not contain - * more than 10 octal characters (30 bits). The most significant - * bit of number is the sign bit. The remaining 29 bits are - * magnitude bits. Negative numbers are represented using - * two's-complement notation. - * If number is not a valid octal number, OCT2DEC returns the - * #NUM! error value. - * - * @return array|string - */ - public static function OCTTODEC(mixed $x) - { - return Engineering\ConvertOctal::toDecimal($x); - } - - /** - * OCTTOHEX. - * - * Return an octal value as hex. - * - * Excel Function: - * OCT2HEX(x[,places]) - * - * @deprecated 1.17.0 - * Use the toHex() method in the Engineering\ConvertOctal class instead - * @see Engineering\ConvertOctal::toHex() - * - * @param mixed $x The octal number you want to convert. Number may not contain - * more than 10 octal characters (30 bits). The most significant - * bit of number is the sign bit. The remaining 29 bits are - * magnitude bits. Negative numbers are represented using - * two's-complement notation. - * If number is negative, OCT2HEX ignores places and returns a - * 10-character hexadecimal number. - * If number is not a valid octal number, OCT2HEX returns the - * #NUM! error value. - * If OCT2HEX requires more than places characters, it returns - * the #NUM! error value. - * @param mixed $places The number of characters to use. If places is omitted, OCT2HEX - * uses the minimum number of characters necessary. Places is useful - * for padding the return value with leading 0s (zeros). - * If places is not an integer, it is truncated. - * If places is nonnumeric, OCT2HEX returns the #VALUE! error value. - * If places is negative, OCT2HEX returns the #NUM! error value. - */ - public static function OCTTOHEX(mixed $x, mixed $places = null): string|array - { - return Engineering\ConvertOctal::toHex($x, $places); - } - - /** - * COMPLEX. - * - * Converts real and imaginary coefficients into a complex number of the form x +/- yi or x +/- yj. - * - * Excel Function: - * COMPLEX(realNumber,imaginary[,suffix]) - * - * @deprecated 1.18.0 - * Use the COMPLEX() method in the Engineering\Complex class instead - * @see Engineering\Complex::COMPLEX() - * - * @param array|float $realNumber the real coefficient of the complex number - * @param array|float $imaginary the imaginary coefficient of the complex number - * @param array|string $suffix The suffix for the imaginary component of the complex number. - * If omitted, the suffix is assumed to be "i". - * - * @return array|string - */ - public static function COMPLEX($realNumber = 0.0, $imaginary = 0.0, $suffix = 'i') - { - return Engineering\Complex::COMPLEX($realNumber, $imaginary, $suffix); - } - - /** - * IMAGINARY. - * - * Returns the imaginary coefficient of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMAGINARY(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMAGINARY() method in the Engineering\Complex class instead - * @see Engineering\Complex::IMAGINARY() - * - * @param string $complexNumber the complex number for which you want the imaginary - * coefficient - */ - public static function IMAGINARY(string $complexNumber): string|float|array - { - return Engineering\Complex::IMAGINARY($complexNumber); - } - - /** - * IMREAL. - * - * Returns the real coefficient of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMREAL(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMREAL() method in the Engineering\Complex class instead - * @see Engineering\Complex::IMREAL() - * - * @param string $complexNumber the complex number for which you want the real coefficient - */ - public static function IMREAL(string $complexNumber): string|float|array - { - return Engineering\Complex::IMREAL($complexNumber); - } - - /** - * IMABS. - * - * Returns the absolute value (modulus) of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMABS(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMABS() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMABS() - * - * @param string $complexNumber the complex number for which you want the absolute value - * - * @return array|float|string - */ - public static function IMABS(string $complexNumber) - { - return ComplexFunctions::IMABS($complexNumber); - } - - /** - * IMARGUMENT. - * - * Returns the argument theta of a complex number, i.e. the angle in radians from the real - * axis to the representation of the number in polar coordinates. - * - * Excel Function: - * IMARGUMENT(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMARGUMENT() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMARGUMENT() - * - * @param array|string $complexNumber the complex number for which you want the argument theta - * - * @return array|float|string - */ - public static function IMARGUMENT($complexNumber) - { - return ComplexFunctions::IMARGUMENT($complexNumber); - } - - /** - * IMCONJUGATE. - * - * Returns the complex conjugate of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCONJUGATE(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMCONJUGATE() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMCONJUGATE() - * - * @param array|string $complexNumber the complex number for which you want the conjugate - * - * @return array|string - */ - public static function IMCONJUGATE($complexNumber) - { - return ComplexFunctions::IMCONJUGATE($complexNumber); - } - - /** - * IMCOS. - * - * Returns the cosine of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCOS(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMCOS() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMCOS() - * - * @param array|string $complexNumber the complex number for which you want the cosine - * - * @return array|float|string - */ - public static function IMCOS($complexNumber) - { - return ComplexFunctions::IMCOS($complexNumber); - } - - /** - * IMCOSH. - * - * Returns the hyperbolic cosine of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCOSH(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMCOSH() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMCOSH() - * - * @param array|string $complexNumber the complex number for which you want the hyperbolic cosine - * - * @return array|float|string - */ - public static function IMCOSH($complexNumber) - { - return ComplexFunctions::IMCOSH($complexNumber); - } - - /** - * IMCOT. - * - * Returns the cotangent of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCOT(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMCOT() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMCOT() - * - * @param array|string $complexNumber the complex number for which you want the cotangent - * - * @return array|float|string - */ - public static function IMCOT($complexNumber) - { - return ComplexFunctions::IMCOT($complexNumber); - } - - /** - * IMCSC. - * - * Returns the cosecant of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCSC(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMCSC() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMCSC() - * - * @param array|string $complexNumber the complex number for which you want the cosecant - * - * @return array|float|string - */ - public static function IMCSC($complexNumber) - { - return ComplexFunctions::IMCSC($complexNumber); - } - - /** - * IMCSCH. - * - * Returns the hyperbolic cosecant of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMCSCH(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMCSCH() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMCSCH() - * - * @param array|string $complexNumber the complex number for which you want the hyperbolic cosecant - * - * @return array|float|string - */ - public static function IMCSCH($complexNumber) - { - return ComplexFunctions::IMCSCH($complexNumber); - } - - /** - * IMSIN. - * - * Returns the sine of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSIN(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMSIN() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMSIN() - * - * @param string $complexNumber the complex number for which you want the sine - * - * @return array|float|string - */ - public static function IMSIN(string $complexNumber) - { - return ComplexFunctions::IMSIN($complexNumber); - } - - /** - * IMSINH. - * - * Returns the hyperbolic sine of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSINH(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMSINH() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMSINH() - * - * @param string $complexNumber the complex number for which you want the hyperbolic sine - * - * @return array|float|string - */ - public static function IMSINH(string $complexNumber) - { - return ComplexFunctions::IMSINH($complexNumber); - } - - /** - * IMSEC. - * - * Returns the secant of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSEC(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMSEC() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMSEC() - * - * @param string $complexNumber the complex number for which you want the secant - * - * @return array|float|string - */ - public static function IMSEC(string $complexNumber) - { - return ComplexFunctions::IMSEC($complexNumber); - } - - /** - * IMSECH. - * - * Returns the hyperbolic secant of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSECH(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMSECH() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMSECH() - * - * @param string $complexNumber the complex number for which you want the hyperbolic secant - * - * @return array|float|string - */ - public static function IMSECH(string $complexNumber) - { - return ComplexFunctions::IMSECH($complexNumber); - } - - /** - * IMTAN. - * - * Returns the tangent of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMTAN(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMTAN() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMTAN() - * - * @param string $complexNumber the complex number for which you want the tangent - * - * @return array|float|string - */ - public static function IMTAN(string $complexNumber) - { - return ComplexFunctions::IMTAN($complexNumber); - } - - /** - * IMSQRT. - * - * Returns the square root of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMSQRT(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMSQRT() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMSQRT() - * - * @param string $complexNumber the complex number for which you want the square root - * - * @return array|string - */ - public static function IMSQRT(string $complexNumber) - { - return ComplexFunctions::IMSQRT($complexNumber); - } - - /** - * IMLN. - * - * Returns the natural logarithm of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMLN(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMLN() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMLN() - * - * @param string $complexNumber the complex number for which you want the natural logarithm - * - * @return array|string - */ - public static function IMLN(string $complexNumber) - { - return ComplexFunctions::IMLN($complexNumber); - } - - /** - * IMLOG10. - * - * Returns the common logarithm (base 10) of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMLOG10(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMLOG10() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMLOG10() - * - * @param string $complexNumber the complex number for which you want the common logarithm - * - * @return array|string - */ - public static function IMLOG10(string $complexNumber) - { - return ComplexFunctions::IMLOG10($complexNumber); - } - - /** - * IMLOG2. - * - * Returns the base-2 logarithm of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMLOG2(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMLOG2() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMLOG2() - * - * @param string $complexNumber the complex number for which you want the base-2 logarithm - * - * @return array|string - */ - public static function IMLOG2(string $complexNumber) - { - return ComplexFunctions::IMLOG2($complexNumber); - } - - /** - * IMEXP. - * - * Returns the exponential of a complex number in x + yi or x + yj text format. - * - * Excel Function: - * IMEXP(complexNumber) - * - * @deprecated 1.18.0 - * Use the IMEXP() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMEXP() - * - * @param string $complexNumber the complex number for which you want the exponential - * - * @return array|string - */ - public static function IMEXP(string $complexNumber) - { - return ComplexFunctions::IMEXP($complexNumber); - } - - /** - * IMPOWER. - * - * Returns a complex number in x + yi or x + yj text format raised to a power. - * - * Excel Function: - * IMPOWER(complexNumber,realNumber) - * - * @deprecated 1.18.0 - * Use the IMPOWER() method in the Engineering\ComplexFunctions class instead - * @see ComplexFunctions::IMPOWER() - * - * @param string $complexNumber the complex number you want to raise to a power - * @param float $realNumber the power to which you want to raise the complex number - * - * @return array|string - */ - public static function IMPOWER(string $complexNumber, float $realNumber) - { - return ComplexFunctions::IMPOWER($complexNumber, $realNumber); - } - - /** - * IMDIV. - * - * Returns the quotient of two complex numbers in x + yi or x + yj text format. - * - * Excel Function: - * IMDIV(complexDividend,complexDivisor) - * - * @deprecated 1.18.0 - * Use the IMDIV() method in the Engineering\ComplexOperations class instead - * @see ComplexOperations::IMDIV() - * - * @param string $complexDividend the complex numerator or dividend - * @param string $complexDivisor the complex denominator or divisor - * - * @return array|string - */ - public static function IMDIV(string $complexDividend, string $complexDivisor) - { - return ComplexOperations::IMDIV($complexDividend, $complexDivisor); - } - - /** - * IMSUB. - * - * Returns the difference of two complex numbers in x + yi or x + yj text format. - * - * Excel Function: - * IMSUB(complexNumber1,complexNumber2) - * - * @deprecated 1.18.0 - * Use the IMSUB() method in the Engineering\ComplexOperations class instead - * @see ComplexOperations::IMSUB() - * - * @param string $complexNumber1 the complex number from which to subtract complexNumber2 - * @param string $complexNumber2 the complex number to subtract from complexNumber1 - * - * @return array|string - */ - public static function IMSUB(string $complexNumber1, string $complexNumber2) - { - return ComplexOperations::IMSUB($complexNumber1, $complexNumber2); - } - - /** - * IMSUM. - * - * Returns the sum of two or more complex numbers in x + yi or x + yj text format. - * - * Excel Function: - * IMSUM(complexNumber[,complexNumber[,...]]) - * - * @deprecated 1.18.0 - * Use the IMSUM() method in the Engineering\ComplexOperations class instead - * @see ComplexOperations::IMSUM() - * - * @param string ...$complexNumbers Series of complex numbers to add - */ - public static function IMSUM(...$complexNumbers): string - { - return ComplexOperations::IMSUM(...$complexNumbers); - } - - /** - * IMPRODUCT. - * - * Returns the product of two or more complex numbers in x + yi or x + yj text format. - * - * Excel Function: - * IMPRODUCT(complexNumber[,complexNumber[,...]]) - * - * @deprecated 1.18.0 - * Use the IMPRODUCT() method in the Engineering\ComplexOperations class instead - * @see ComplexOperations::IMPRODUCT() - * - * @param string ...$complexNumbers Series of complex numbers to multiply - */ - public static function IMPRODUCT(...$complexNumbers): string - { - return ComplexOperations::IMPRODUCT(...$complexNumbers); - } - - /** - * DELTA. - * - * Tests whether two values are equal. Returns 1 if number1 = number2; returns 0 otherwise. - * Use this function to filter a set of values. For example, by summing several DELTA - * functions you calculate the count of equal pairs. This function is also known as the - * Kronecker Delta function. - * - * Excel Function: - * DELTA(a[,b]) - * - * @deprecated 1.17.0 - * Use the DELTA() method in the Engineering\Compare class instead - * @see Engineering\Compare::DELTA() - * - * @param float $a the first number - * @param float $b The second number. If omitted, b is assumed to be zero. - * - * @return array|int|string (string in the event of an error) - */ - public static function DELTA(float $a, float $b = 0) - { - return Engineering\Compare::DELTA($a, $b); - } - - /** - * GESTEP. - * - * Excel Function: - * GESTEP(number[,step]) - * - * Returns 1 if number >= step; returns 0 (zero) otherwise - * Use this function to filter a set of values. For example, by summing several GESTEP - * functions you calculate the count of values that exceed a threshold. - * - * @deprecated 1.17.0 - * Use the GESTEP() method in the Engineering\Compare class instead - * @see Engineering\Compare::GESTEP() - * - * @param float $number the value to test against step - * @param float $step The threshold value. If you omit a value for step, GESTEP uses zero. - * - * @return array|int|string (string in the event of an error) - */ - public static function GESTEP(float $number, float $step = 0) - { - return Engineering\Compare::GESTEP($number, $step); - } - - /** - * BITAND. - * - * Returns the bitwise AND of two integer values. - * - * Excel Function: - * BITAND(number1, number2) - * - * @deprecated 1.17.0 - * Use the BITAND() method in the Engineering\BitWise class instead - * @see Engineering\BitWise::BITAND() - * - * @return array|int|string - */ - public static function BITAND(int $number1, int $number2) - { - return Engineering\BitWise::BITAND($number1, $number2); - } - - /** - * BITOR. - * - * Returns the bitwise OR of two integer values. - * - * Excel Function: - * BITOR(number1, number2) - * - * @deprecated 1.17.0 - * Use the BITOR() method in the Engineering\BitWise class instead - * @see Engineering\BitWise::BITOR() - * - * @return array|int|string - */ - public static function BITOR(int $number1, int $number2) - { - return Engineering\BitWise::BITOR($number1, $number2); - } - - /** - * BITXOR. - * - * Returns the bitwise XOR of two integer values. - * - * Excel Function: - * BITXOR(number1, number2) - * - * @deprecated 1.17.0 - * Use the BITXOR() method in the Engineering\BitWise class instead - * @see Engineering\BitWise::BITXOR() - * - * @return array|int|string - */ - public static function BITXOR(int $number1, int $number2) - { - return Engineering\BitWise::BITXOR($number1, $number2); - } - - /** - * BITLSHIFT. - * - * Returns the number value shifted left by shift_amount bits. - * - * Excel Function: - * BITLSHIFT(number, shift_amount) - * - * @deprecated 1.17.0 - * Use the BITLSHIFT() method in the Engineering\BitWise class instead - * @see Engineering\BitWise::BITLSHIFT() - * - * @return array|float|int|string - */ - public static function BITLSHIFT(int $number, int $shiftAmount) - { - return Engineering\BitWise::BITLSHIFT($number, $shiftAmount); - } - - /** - * BITRSHIFT. - * - * Returns the number value shifted right by shift_amount bits. - * - * Excel Function: - * BITRSHIFT(number, shift_amount) - * - * @deprecated 1.17.0 - * Use the BITRSHIFT() method in the Engineering\BitWise class instead - * @see Engineering\BitWise::BITRSHIFT() - * - * @return array|float|int|string - */ - public static function BITRSHIFT(int $number, int $shiftAmount) - { - return Engineering\BitWise::BITRSHIFT($number, $shiftAmount); - } - - /** - * ERF. - * - * Returns the error function integrated between the lower and upper bound arguments. - * - * Note: In Excel 2007 or earlier, if you input a negative value for the upper or lower bound arguments, - * the function would return a #NUM! error. However, in Excel 2010, the function algorithm was - * improved, so that it can now calculate the function for both positive and negative ranges. - * PhpSpreadsheet follows Excel 2010 behaviour, and accepts negative arguments. - * - * Excel Function: - * ERF(lower[,upper]) - * - * @deprecated 1.17.0 - * Use the ERF() method in the Engineering\Erf class instead - * @see Engineering\Erf::ERF() - * - * @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 - */ - public static function ERF(float $lower, ?float $upper = null): float|string|array - { - return Engineering\Erf::ERF($lower, $upper); - } - - /** - * ERFPRECISE. - * - * Returns the error function integrated between the lower and upper bound arguments. - * - * Excel Function: - * ERF.PRECISE(limit) - * - * @deprecated 1.17.0 - * Use the ERFPRECISE() method in the Engineering\Erf class instead - * @see Engineering\Erf::ERFPRECISE() - * - * @param float $limit bound for integrating ERF - * - * @return array|float|string - */ - public static function ERFPRECISE(float $limit) - { - return Engineering\Erf::ERFPRECISE($limit); - } - - /** - * ERFC. - * - * Returns the complementary ERF function integrated between x and infinity - * - * Note: In Excel 2007 or earlier, if you input a negative value for the lower bound argument, - * the function would return a #NUM! error. However, in Excel 2010, the function algorithm was - * improved, so that it can now calculate the function for both positive and negative x values. - * PhpSpreadsheet follows Excel 2010 behaviour, and accepts nagative arguments. - * - * Excel Function: - * ERFC(x) - * - * @deprecated 1.17.0 - * Use the ERFC() method in the Engineering\ErfC class instead - * @see Engineering\ErfC::ERFC() - * - * @param float $x The lower bound for integrating ERFC - * - * @return array|float|string - */ - public static function ERFC(float $x) - { - return Engineering\ErfC::ERFC($x); - } - - /** - * getConversionGroups - * Returns a list of the different conversion groups for UOM conversions. - * - * @deprecated 1.16.0 - * Use the getConversionCategories() method in the Engineering\ConvertUOM class instead - * @see Engineering\ConvertUOM::getConversionCategories() - */ - public static function getConversionGroups(): array - { - return Engineering\ConvertUOM::getConversionCategories(); - } - - /** - * getConversionGroupUnits - * Returns an array of units of measure, for a specified conversion group, or for all groups. - * - * @deprecated 1.16.0 - * Use the getConversionCategoryUnits() method in the ConvertUOM class instead - * @see Engineering\ConvertUOM::getConversionCategoryUnits() - * - * @param null|mixed $category - */ - public static function getConversionGroupUnits($category = null): array - { - return Engineering\ConvertUOM::getConversionCategoryUnits($category); - } - - /** - * getConversionGroupUnitDetails. - * - * @deprecated 1.16.0 - * Use the getConversionCategoryUnitDetails() method in the ConvertUOM class instead - * @see Engineering\ConvertUOM::getConversionCategoryUnitDetails() - * - * @param null|mixed $category - */ - public static function getConversionGroupUnitDetails($category = null): array - { - return Engineering\ConvertUOM::getConversionCategoryUnitDetails($category); - } - - /** - * getConversionMultipliers - * Returns an array of the Multiplier prefixes that can be used with Units of Measure in CONVERTUOM(). - * - * @deprecated 1.16.0 - * Use the getConversionMultipliers() method in the ConvertUOM class instead - * @see Engineering\ConvertUOM::getConversionMultipliers() - * - * @return mixed[] - */ - public static function getConversionMultipliers(): array - { - return Engineering\ConvertUOM::getConversionMultipliers(); - } - - /** - * getBinaryConversionMultipliers. - * - * Returns an array of the additional Multiplier prefixes that can be used with Information Units of Measure - * in CONVERTUOM(). - * - * @deprecated 1.16.0 - * Use the getBinaryConversionMultipliers() method in the ConvertUOM class instead - * @see Engineering\ConvertUOM::getBinaryConversionMultipliers() - * - * @return mixed[] - */ - public static function getBinaryConversionMultipliers(): array - { - return Engineering\ConvertUOM::getBinaryConversionMultipliers(); - } - - /** - * CONVERTUOM. - * - * Converts a number from one measurement system to another. - * For example, CONVERT can translate a table of distances in miles to a table of distances - * in kilometers. - * - * Excel Function: - * CONVERT(value,fromUOM,toUOM) - * - * @deprecated 1.16.0 - * Use the CONVERT() method in the ConvertUOM class instead - * @see Engineering\ConvertUOM::CONVERT() - * - * @param float|int $value the value in fromUOM to convert - * @param string $fromUOM the units for value - * @param string $toUOM the units for the result - * - * @return array|float|string - */ - public static function CONVERTUOM($value, string $fromUOM, string $toUOM) - { - return Engineering\ConvertUOM::CONVERT($value, $fromUOM, $toUOM); - } -} diff --git a/src/PhpSpreadsheet/Calculation/Financial.php b/src/PhpSpreadsheet/Calculation/Financial.php deleted file mode 100644 index 0d1b911e9c..0000000000 --- a/src/PhpSpreadsheet/Calculation/Financial.php +++ /dev/null @@ -1,1372 +0,0 @@ -getWorksheet(); diff --git a/src/PhpSpreadsheet/Calculation/Information/ExcelError.php b/src/PhpSpreadsheet/Calculation/Information/ExcelError.php index b1514cf9a5..d9aabfd0a1 100644 --- a/src/PhpSpreadsheet/Calculation/Information/ExcelError.php +++ b/src/PhpSpreadsheet/Calculation/Information/ExcelError.php @@ -30,17 +30,6 @@ class ExcelError 'calculation' => '#CALC!', //14 ]; - /** - * List of error codes. Replaced by constant; - * previously it was public and updateable, allowing - * user to make inappropriate alterations. - * - * @deprecated 1.25.0 Use ERROR_CODES constant instead. - * - * @var array - */ - public static array $errorCodes = self::ERROR_CODES; - public static function throwError(mixed $value): string { return in_array($value, self::ERROR_CODES, true) ? $value : self::ERROR_CODES['value']; diff --git a/src/PhpSpreadsheet/Calculation/Logical.php b/src/PhpSpreadsheet/Calculation/Logical.php deleted file mode 100644 index 3532cb1403..0000000000 --- a/src/PhpSpreadsheet/Calculation/Logical.php +++ /dev/null @@ -1,303 +0,0 @@ -fillColor; } - /** - * Get Line Color Property. - * - * @deprecated 1.24.0 - * Use the getLineColor property in the Properties class instead - * @see Properties::getLineColorProperty() - */ - public function getLineProperty(string $propertyName): null|int|string - { - return $this->getLineColorProperty($propertyName); - } - private string $crossBetween = ''; // 'between' or 'midCat' might be better public function setCrossBetween(string $crossBetween): self diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index 60e0272d4b..65e74b1e3d 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -341,32 +341,6 @@ public function setChartAxisX(?Axis $axis): self return $this; } - /** - * Get Major Gridlines. - * - * @deprecated 1.24.0 Use Axis->getMajorGridlines() - * @see Axis::getMajorGridlines() - * - * @codeCoverageIgnore - */ - public function getMajorGridlines(): ?GridLines - { - return $this->yAxis->getMajorGridLines(); - } - - /** - * Get Minor Gridlines. - * - * @deprecated 1.24.0 Use Axis->getMinorGridlines() - * @see Axis::getMinorGridlines() - * - * @codeCoverageIgnore - */ - public function getMinorGridlines(): ?GridLines - { - return $this->yAxis->getMinorGridLines(); - } - /** * Set the Top Left position for the chart. * diff --git a/src/PhpSpreadsheet/Chart/ChartColor.php b/src/PhpSpreadsheet/Chart/ChartColor.php index a73c3fdbf7..ba530e7167 100644 --- a/src/PhpSpreadsheet/Chart/ChartColor.php +++ b/src/PhpSpreadsheet/Chart/ChartColor.php @@ -7,10 +7,8 @@ class ChartColor const EXCEL_COLOR_TYPE_STANDARD = 'prstClr'; const EXCEL_COLOR_TYPE_SCHEME = 'schemeClr'; const EXCEL_COLOR_TYPE_RGB = 'srgbClr'; - /** @deprecated 1.24 use EXCEL_COLOR_TYPE_RGB instead */ - const EXCEL_COLOR_TYPE_ARGB = 'srgbClr'; const EXCEL_COLOR_TYPES = [ - self::EXCEL_COLOR_TYPE_ARGB, + self::EXCEL_COLOR_TYPE_RGB, self::EXCEL_COLOR_TYPE_SCHEME, self::EXCEL_COLOR_TYPE_STANDARD, ]; diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index 6fcfc33621..b9252c2ed0 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -10,13 +10,6 @@ */ abstract class Properties { - /** @deprecated 1.24 use constant from ChartColor instead */ - const EXCEL_COLOR_TYPE_STANDARD = ChartColor::EXCEL_COLOR_TYPE_STANDARD; - /** @deprecated 1.24 use constant from ChartColor instead */ - const EXCEL_COLOR_TYPE_SCHEME = ChartColor::EXCEL_COLOR_TYPE_SCHEME; - /** @deprecated 1.24 use constant from ChartColor instead */ - const EXCEL_COLOR_TYPE_ARGB = ChartColor::EXCEL_COLOR_TYPE_ARGB; - const AXIS_LABELS_LOW = 'low'; const AXIS_LABELS_HIGH = 'high'; const AXIS_LABELS_NEXT_TO = 'nextTo'; @@ -54,8 +47,6 @@ abstract class Properties const LINE_STYLE_DASH_SOLID = 'solid'; const LINE_STYLE_DASH_ROUND_DOT = 'sysDot'; const LINE_STYLE_DASH_SQUARE_DOT = 'sysDash'; - /** @deprecated 1.24 use LINE_STYLE_DASH_SQUARE_DOT instead */ - const LINE_STYLE_DASH_SQUERE_DOT = 'sysDash'; const LINE_STYPE_DASH_DASH = 'dash'; const LINE_STYLE_DASH_DASH_DOT = 'dashDot'; const LINE_STYLE_DASH_LONG_DASH = 'lgDash'; diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 47e46dfe35..2acb3fcf8e 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -205,36 +205,6 @@ public function loadSpreadsheetFromFile(string $filename): Spreadsheet return $this->loadIntoExisting($filename, $spreadsheet); } - /** - * Set input encoding. - * - * @param string $inputEncoding Input encoding, eg: 'ANSI' - * - * @return $this - * - * @codeCoverageIgnore - * - * @deprecated no use is made of this property - */ - public function setInputEncoding(string $inputEncoding): static - { - $this->inputEncoding = $inputEncoding; - - return $this; - } - - /** - * Get input encoding. - * - * @codeCoverageIgnore - * - * @deprecated no use is made of this property - */ - public function getInputEncoding(): string - { - return $this->inputEncoding; - } - // Data Array used for testing only, should write to Spreadsheet object on completion of tests protected array $dataArray = []; diff --git a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php index 1fbddcb3c0..979325a44c 100644 --- a/src/PhpSpreadsheet/Reader/Security/XmlScanner.php +++ b/src/PhpSpreadsheet/Reader/Security/XmlScanner.php @@ -23,16 +23,6 @@ public static function getInstance(Reader\IReader $reader): self return new self($pattern); } - /** - * @codeCoverageIgnore - * - * @deprecated this has no effect at all and always return false. All usages must be removed. - */ - public static function threadSafeLibxmlDisableEntityLoaderAvailability(): bool - { - return false; - } - public function setAdditionalCallback(callable $callback): void { $this->callback = $callback; diff --git a/src/PhpSpreadsheet/Reader/Slk.php b/src/PhpSpreadsheet/Reader/Slk.php index 51e3eec3a5..30fe54718b 100644 --- a/src/PhpSpreadsheet/Reader/Slk.php +++ b/src/PhpSpreadsheet/Reader/Slk.php @@ -14,11 +14,6 @@ class Slk extends BaseReader { - /** - * Input encoding. - */ - private string $inputEncoding = 'ANSI'; - /** * Sheet index to read. */ @@ -87,36 +82,6 @@ private function canReadOrBust(string $filename): void $this->openFile($filename); } - /** - * Set input encoding. - * - * @deprecated no use is made of this property - * - * @param string $inputEncoding Input encoding, eg: 'ANSI' - * - * @return $this - * - * @codeCoverageIgnore - */ - public function setInputEncoding(string $inputEncoding): static - { - $this->inputEncoding = $inputEncoding; - - return $this; - } - - /** - * Get input encoding. - * - * @deprecated no use is made of this property - * - * @codeCoverageIgnore - */ - public function getInputEncoding(): string - { - return $this->inputEncoding; - } - /** * Return worksheet info (Name, Last Column Letter, Last Column Index, Total Rows, Total Columns). */ diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 9f61d070b5..d32f5d9025 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -119,32 +119,6 @@ public static function getLibXmlLoaderOptions(): int return self::$libXmlLoaderOptions; } - /** - * Deprecated, has no effect. - * - * @deprecated will be removed without replacement as it is no longer necessary on PHP 7.3.0+ - * - * @codeCoverageIgnore - */ - public static function setLibXmlDisableEntityLoader(bool $state): void - { - // noop - } - - /** - * Deprecated, has no effect. - * - * @return bool $state - * - * @deprecated will be removed without replacement as it is no longer necessary on PHP 7.3.0+ - * - * @codeCoverageIgnore - */ - public static function getLibXmlDisableEntityLoader(): bool - { - return true; - } - /** * Sets the implementation of cache that should be used for cell collection. */ diff --git a/src/PhpSpreadsheet/Shared/Drawing.php b/src/PhpSpreadsheet/Shared/Drawing.php index 44934f7b0e..6fd5058de2 100644 --- a/src/PhpSpreadsheet/Shared/Drawing.php +++ b/src/PhpSpreadsheet/Shared/Drawing.php @@ -2,8 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Shared; -use GdImage; -use PhpOffice\PhpSpreadsheet\Reader\Exception as ReaderException; use SimpleXMLElement; class Drawing @@ -52,16 +50,16 @@ public static function pixelsToCellDimension(int $pixelValue, \PhpOffice\PhpSpre $name = $defaultFont->getName(); $size = $defaultFont->getSize(); - if (isset(Font::$defaultColumnWidths[$name][$size])) { + if (isset(Font::DEFAULT_COLUMN_WIDTHS[$name][$size])) { // Exact width can be determined - return $pixelValue * Font::$defaultColumnWidths[$name][$size]['width'] - / Font::$defaultColumnWidths[$name][$size]['px']; + return $pixelValue * Font::DEFAULT_COLUMN_WIDTHS[$name][$size]['width'] + / Font::DEFAULT_COLUMN_WIDTHS[$name][$size]['px']; } // We don't have data for this particular font and size, use approximation by // extrapolating from Calibri 11 - return $pixelValue * 11 * Font::$defaultColumnWidths['Calibri'][11]['width'] - / Font::$defaultColumnWidths['Calibri'][11]['px'] / $size; + return $pixelValue * 11 * Font::DEFAULT_COLUMN_WIDTHS['Calibri'][11]['width'] + / Font::DEFAULT_COLUMN_WIDTHS['Calibri'][11]['px'] / $size; } /** @@ -78,15 +76,15 @@ public static function cellDimensionToPixels(float $cellWidth, \PhpOffice\PhpSpr $name = $defaultFont->getName(); $size = $defaultFont->getSize(); - if (isset(Font::$defaultColumnWidths[$name][$size])) { + if (isset(Font::DEFAULT_COLUMN_WIDTHS[$name][$size])) { // Exact width can be determined - $colWidth = $cellWidth * Font::$defaultColumnWidths[$name][$size]['px'] - / Font::$defaultColumnWidths[$name][$size]['width']; + $colWidth = $cellWidth * Font::DEFAULT_COLUMN_WIDTHS[$name][$size]['px'] + / Font::DEFAULT_COLUMN_WIDTHS[$name][$size]['width']; } else { // We don't have data for this particular font and size, use approximation by // extrapolating from Calibri 11 - $colWidth = $cellWidth * $size * Font::$defaultColumnWidths['Calibri'][11]['px'] - / Font::$defaultColumnWidths['Calibri'][11]['width'] / 11; + $colWidth = $cellWidth * $size * Font::DEFAULT_COLUMN_WIDTHS['Calibri'][11]['px'] + / Font::DEFAULT_COLUMN_WIDTHS['Calibri'][11]['width'] / 11; } // Round pixels to closest integer @@ -151,25 +149,4 @@ public static function angleToDegrees($angle): int return 0; } - - /** - * Create a new image from file. By alexander at alexauto dot nl. - * - * @see http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214 - * - * @param string $bmpFilename Path to Windows DIB (BMP) image - * - * @deprecated 1.26 use Php function imagecreatefrombmp instead - * - * @codeCoverageIgnore - */ - public static function imagecreatefrombmp(string $bmpFilename): GdImage - { - $retVal = @imagecreatefrombmp($bmpFilename); - if ($retVal === false) { - throw new ReaderException("Unable to create image from $bmpFilename"); - } - - return $retVal; - } } diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index 4c534fdaac..4b9c470dbe 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -272,15 +272,6 @@ public static function getExtraFontArray(): array ], ]; - /** - * List of column widths. Replaced by constant; - * previously it was public and updateable, allowing - * user to make inappropriate alterations. - * - * @deprecated 1.25.0 Use DEFAULT_COLUMN_WIDTHS constant instead. - */ - public static array $defaultColumnWidths = self::DEFAULT_COLUMN_WIDTHS; - /** * Set autoSize method. * diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index bc9f770e4f..2b7b61f2bb 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -19,8 +19,6 @@ class NumberFormat extends Supervisor const FORMAT_PERCENTAGE_0 = '0.0%'; const FORMAT_PERCENTAGE_00 = '0.00%'; - /** @deprecated 1.26 use FORMAT_DATE_YYYYMMDD instead */ - const FORMAT_DATE_YYYYMMDD2 = 'yyyy-mm-dd'; const FORMAT_DATE_YYYYMMDD = 'yyyy-mm-dd'; const FORMAT_DATE_DDMMYYYY = 'dd/mm/yyyy'; const FORMAT_DATE_DMYSLASH = 'd/m/yy'; @@ -79,12 +77,8 @@ class NumberFormat extends Supervisor self::FORMAT_DATE_TIME8, ]; - /** @deprecated 1.28 use FORMAT_CURRENCY_USD_INTEGER instead */ - const FORMAT_CURRENCY_USD_SIMPLE = '"$"#,##0_-'; const FORMAT_CURRENCY_USD_INTEGER = '$#,##0_-'; const FORMAT_CURRENCY_USD = '$#,##0.00_-'; - /** @deprecated 1.28 use FORMAT_CURRENCY_EUR_INTEGER instead */ - const FORMAT_CURRENCY_EUR_SIMPLE = '#,##0_-"€"'; const FORMAT_CURRENCY_EUR_INTEGER = '#,##0_-[$€]'; const FORMAT_CURRENCY_EUR = '#,##0.00_-[$€]'; const FORMAT_ACCOUNTING_USD = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)'; diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 3eab4b624d..4806370140 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -8,7 +8,6 @@ use PhpOffice\PhpSpreadsheet\Cell\AddressRange; use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\CellAddress; -use PhpOffice\PhpSpreadsheet\Cell\CellRange; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Cell\DataType; use PhpOffice\PhpSpreadsheet\Cell\DataValidation; @@ -1105,28 +1104,6 @@ public function setCellValue($coordinate, mixed $value, ?IValueBinder $binder = return $this; } - /** - * Set a cell value by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the setCellValue() method with a cell address such as 'C5' instead;, - * or passing in an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object. - * @see Worksheet::setCellValue() - * - * @param int $columnIndex Numeric column coordinate of the cell - * @param int $row Numeric row coordinate of the cell - * @param mixed $value Value of the cell - * @param null|IValueBinder $binder Value Binder to override the currently set Value Binder - * - * @return $this - */ - public function setCellValueByColumnAndRow(int $columnIndex, int $row, mixed $value, ?IValueBinder $binder = null): static - { - $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValue($value, $binder); - - return $this; - } - /** * Set a cell value. * @@ -1152,35 +1129,6 @@ public function setCellValueExplicit($coordinate, mixed $value, string $dataType return $this; } - /** - * Set a cell value by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the setCellValueExplicit() method with a cell address such as 'C5' instead;, - * or passing in an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object. - * @see Worksheet::setCellValueExplicit() - * - * @param int $columnIndex Numeric column coordinate of the cell - * @param int $row Numeric row coordinate of the cell - * @param mixed $value Value of the cell - * @param string $dataType Explicit data type, see DataType::TYPE_* - * Note that PhpSpreadsheet does not validate that the value and datatype are consistent, in using this - * method, then it is your responsibility as an end-user developer to validate that the value and - * the datatype match. - * If you do mismatch value and datatpe, then the value you enter may be changed to match the datatype - * that you specify. - * - * @see DataType - * - * @return $this - */ - public function setCellValueExplicitByColumnAndRow(int $columnIndex, int $row, mixed $value, string $dataType): static - { - $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row)->setValueExplicit($value, $dataType); - - return $this; - } - /** * Get cell at a specific coordinate. * @@ -1283,29 +1231,6 @@ private function getCellOrNull(string $coordinate): ?Cell return null; } - /** - * Get cell at a specific coordinate by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the getCell() method with a cell address such as 'C5' instead;, - * or passing in an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object. - * @see Worksheet::getCell() - * - * @param int $columnIndex Numeric column coordinate of the cell - * @param int $row Numeric row coordinate of the cell - * - * @return Cell Cell that was found/created or null - * WARNING: Because the cell collection can be cached to reduce memory, it only allows one - * "active" cell at a time in memory. If you assign that cell to a variable, then select - * another cell using getCell() or any of its variants, the newly selected cell becomes - * the "active" cell, and any previous assignment becomes a disconnected reference because - * the active cell has changed. - */ - public function getCellByColumnAndRow(int $columnIndex, int $row): Cell - { - return $this->getCell(Coordinate::stringFromColumnIndex($columnIndex) . $row); - } - /** * Create a new cell at the specified coordinate. * @@ -1371,22 +1296,6 @@ public function cellExists($coordinate): bool return $sheet->getCellCollection()->has($finalCoordinate); } - /** - * Cell at a specific coordinate by using numeric cell coordinates exists? - * - * @deprecated 1.23.0 - * Use the cellExists() method with a cell address such as 'C5' instead;, - * or passing in an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object. - * @see Worksheet::cellExists() - * - * @param int $columnIndex Numeric column coordinate of the cell - * @param int $row Numeric row coordinate of the cell - */ - public function cellExistsByColumnAndRow(int $columnIndex, int $row): bool - { - return $this->cellExists(Coordinate::stringFromColumnIndex($columnIndex) . $row); - } - /** * Get row dimension at a specific row. * @@ -1478,34 +1387,6 @@ public function getStyle($cellCoordinate): Style return $this->getParentOrThrow()->getCellXfSupervisor(); } - /** - * Get style for cell by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the getStyle() method with a cell address range such as 'C5:F8' instead;, - * or passing in an array of [$fromColumnIndex, $fromRow, $toColumnIndex, $toRow] (e.g. [3, 5, 6, 8]), - * or an AddressRange object. - * @see Worksheet::getStyle() - * - * @param int $columnIndex1 Numeric column coordinate of the cell - * @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 - */ - public function getStyleByColumnAndRow(int $columnIndex1, int $row1, ?int $columnIndex2 = null, ?int $row2 = null): Style - { - if ($columnIndex2 !== null && $row2 !== null) { - $cellRange = new CellRange( - CellAddress::fromColumnAndRow($columnIndex1, $row1), - CellAddress::fromColumnAndRow($columnIndex2, $row2) - ); - - return $this->getStyle($cellRange); - } - - return $this->getStyle(CellAddress::fromColumnAndRow($columnIndex1, $row1)); - } - /** * Get conditional styles for a cell. * @@ -1715,25 +1596,6 @@ public function setBreak($coordinate, int $break, int $max = -1): static return $this; } - /** - * Set break on a cell by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the setBreak() method with a cell address such as 'C5' instead;, - * or passing in an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object. - * @see Worksheet::setBreak() - * - * @param int $columnIndex Numeric column coordinate of the cell - * @param int $row Numeric row coordinate of the cell - * @param int $break Break type (type of Worksheet::BREAK_*) - * - * @return $this - */ - public function setBreakByColumnAndRow(int $columnIndex, int $row, int $break): static - { - return $this->setBreak(Coordinate::stringFromColumnIndex($columnIndex) . $row, $break); - } - /** * Get breaks. * @@ -1927,37 +1789,6 @@ public function mergeCellBehaviour(Cell $cell, string $upperLeft, string $behavi return $leftCellValue; } - /** - * Set merge on a cell range by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the mergeCells() method with a cell address range such as 'C5:F8' instead;, - * or passing in an array of [$fromColumnIndex, $fromRow, $toColumnIndex, $toRow] (e.g. [3, 5, 6, 8]), - * or an AddressRange object. - * @see Worksheet::mergeCells() - * - * @param int $columnIndex1 Numeric column coordinate of the first cell - * @param int $row1 Numeric row coordinate of the first cell - * @param int $columnIndex2 Numeric column coordinate of the last cell - * @param int $row2 Numeric row coordinate of the last cell - * @param string $behaviour How the merged cells should behave. - * Possible values are: - * MERGE_CELL_CONTENT_EMPTY - Empty the content of the hidden cells - * MERGE_CELL_CONTENT_HIDE - Keep the content of the hidden cells - * MERGE_CELL_CONTENT_MERGE - Move the content of the hidden cells into the first cell - * - * @return $this - */ - public function mergeCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2, string $behaviour = self::MERGE_CELL_CONTENT_EMPTY): static - { - $cellRange = new CellRange( - CellAddress::fromColumnAndRow($columnIndex1, $row1), - CellAddress::fromColumnAndRow($columnIndex2, $row2) - ); - - return $this->mergeCells($cellRange, $behaviour); - } - /** * Remove merge on a cell range. * @@ -1984,32 +1815,6 @@ public function unmergeCells($range): static return $this; } - /** - * Remove merge on a cell range by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the unmergeCells() method with a cell address range such as 'C5:F8' instead;, - * or passing in an array of [$fromColumnIndex, $fromRow, $toColumnIndex, $toRow] (e.g. [3, 5, 6, 8]), - * or an AddressRange object. - * @see Worksheet::unmergeCells() - * - * @param int $columnIndex1 Numeric column coordinate of the first cell - * @param int $row1 Numeric row coordinate of the first cell - * @param int $columnIndex2 Numeric column coordinate of the last cell - * @param int $row2 Numeric row coordinate of the last cell - * - * @return $this - */ - public function unmergeCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2): static - { - $cellRange = new CellRange( - CellAddress::fromColumnAndRow($columnIndex1, $row1), - CellAddress::fromColumnAndRow($columnIndex2, $row2) - ); - - return $this->unmergeCells($cellRange); - } - /** * Get merge cells array. * @@ -2058,34 +1863,6 @@ public function protectCells($range, string $password, bool $alreadyHashed = fal return $this; } - /** - * Set protection on a cell range by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the protectCells() method with a cell address range such as 'C5:F8' instead;, - * or passing in an array of [$fromColumnIndex, $fromRow, $toColumnIndex, $toRow] (e.g. [3, 5, 6, 8]), - * or an AddressRange object. - * @see Worksheet::protectCells() - * - * @param int $columnIndex1 Numeric column coordinate of the first cell - * @param int $row1 Numeric row coordinate of the first cell - * @param int $columnIndex2 Numeric column coordinate of the last cell - * @param int $row2 Numeric row coordinate of the last cell - * @param string $password Password to unlock the protection - * @param bool $alreadyHashed If the password has already been hashed, set this to true - * - * @return $this - */ - public function protectCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2, string $password, bool $alreadyHashed = false): static - { - $cellRange = new CellRange( - CellAddress::fromColumnAndRow($columnIndex1, $row1), - CellAddress::fromColumnAndRow($columnIndex2, $row2) - ); - - return $this->protectCells($cellRange, $password, $alreadyHashed); - } - /** * Remove protection on a cell or cell range. * @@ -2108,32 +1885,6 @@ public function unprotectCells($range): static return $this; } - /** - * Remove protection on a cell range by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the unprotectCells() method with a cell address range such as 'C5:F8' instead;, - * or passing in an array of [$fromColumnIndex, $fromRow, $toColumnIndex, $toRow] (e.g. [3, 5, 6, 8]), - * or an AddressRange object. - * @see Worksheet::unprotectCells() - * - * @param int $columnIndex1 Numeric column coordinate of the first cell - * @param int $row1 Numeric row coordinate of the first cell - * @param int $columnIndex2 Numeric column coordinate of the last cell - * @param int $row2 Numeric row coordinate of the last cell - * - * @return $this - */ - public function unprotectCellsByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2): static - { - $cellRange = new CellRange( - CellAddress::fromColumnAndRow($columnIndex1, $row1), - CellAddress::fromColumnAndRow($columnIndex2, $row2) - ); - - return $this->unprotectCells($cellRange); - } - /** * Get protected cells. * @@ -2175,32 +1926,6 @@ public function setAutoFilter($autoFilterOrRange): static return $this; } - /** - * Set Autofilter Range by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the setAutoFilter() method with a cell address range such as 'C5:F8' instead;, - * or passing in an array of [$fromColumnIndex, $fromRow, $toColumnIndex, $toRow] (e.g. [3, 5, 6, 8]), - * or an AddressRange object or AutoFilter object. - * @see Worksheet::setAutoFilter() - * - * @param int $columnIndex1 Numeric column coordinate of the first cell - * @param int $row1 Numeric row coordinate of the first cell - * @param int $columnIndex2 Numeric column coordinate of the second cell - * @param int $row2 Numeric row coordinate of the second cell - * - * @return $this - */ - public function setAutoFilterByColumnAndRow(int $columnIndex1, int $row1, int $columnIndex2, int $row2): static - { - $cellRange = new CellRange( - CellAddress::fromColumnAndRow($columnIndex1, $row1), - CellAddress::fromColumnAndRow($columnIndex2, $row2) - ); - - return $this->setAutoFilter($cellRange); - } - /** * Remove autofilter. */ @@ -2389,24 +2114,6 @@ public function setTopLeftCell(string $topLeftCell): self return $this; } - /** - * Freeze Pane by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the freezePane() method with a cell address such as 'C5' instead;, - * or passing in an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object. - * @see Worksheet::freezePane() - * - * @param int $columnIndex Numeric column coordinate of the cell - * @param int $row Numeric row coordinate of the cell - * - * @return $this - */ - public function freezePaneByColumnAndRow(int $columnIndex, int $row): static - { - return $this->freezePane(Coordinate::stringFromColumnIndex($columnIndex) . $row); - } - /** * Unfreeze Pane. * @@ -2910,22 +2617,6 @@ public function getComment($cellCoordinate): Comment return $newComment; } - /** - * Get comment for cell by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the getComment() method with a cell address such as 'C5' instead;, - * or passing in an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object. - * @see Worksheet::getComment() - * - * @param int $columnIndex Numeric column coordinate of the cell - * @param int $row Numeric row coordinate of the cell - */ - public function getCommentByColumnAndRow(int $columnIndex, int $row): Comment - { - return $this->getComment(Coordinate::stringFromColumnIndex($columnIndex) . $row); - } - /** * Get active cell. * @@ -3003,24 +2694,6 @@ private function setSelectedCellsActivePane(): void } } - /** - * Selected cell by using numeric cell coordinates. - * - * @deprecated 1.23.0 - * Use the setSelectedCells() method with a cell address such as 'C5' instead;, - * or passing in an array of [$columnIndex, $row] (e.g. [3, 5]), or a CellAddress object. - * @see Worksheet::setSelectedCells() - * - * @param int $columnIndex Numeric column coordinate of the cell - * @param int $row Numeric row coordinate of the cell - * - * @return $this - */ - public function setSelectedCellByColumnAndRow(int $columnIndex, int $row): static - { - return $this->setSelectedCells(Coordinate::stringFromColumnIndex($columnIndex) . $row); - } - /** * Get right-to-left. */ diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 9056f17578..046ab94e67 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -60,11 +60,6 @@ class Html extends BaseWriter */ private bool $useInlineCss = false; - /** - * Use embedded CSS? - */ - private bool $useEmbeddedCSS = true; - /** * Array of CSS styles. */ @@ -1593,34 +1588,6 @@ public function setUseInlineCss(bool $useInlineCss): static return $this; } - /** - * Get use embedded CSS? - * - * @codeCoverageIgnore - * - * @deprecated no longer used - */ - public function getUseEmbeddedCSS(): bool - { - return $this->useEmbeddedCSS; - } - - /** - * Set use embedded CSS? - * - * @return $this - * - * @codeCoverageIgnore - * - * @deprecated no longer used - */ - public function setUseEmbeddedCSS(bool $useEmbeddedCSS): static - { - $this->useEmbeddedCSS = $useEmbeddedCSS; - - return $this; - } - /** * Add color to formatted string as inline style. * diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MovedFunctionsTest.php deleted file mode 100644 index ec851e6b14..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/MovedFunctionsTest.php +++ /dev/null @@ -1,62 +0,0 @@ -format('s'); - $nowResult = DateTime::DATETIMENOW(); - $todayResult = DateTime::DATENOW(); - $dtEnd = new DateTimeImmutable(); - $endSecond = $dtEnd->format('s'); - } while ($startSecond !== $endSecond); - self::assertSame(DateTime::DAYOFMONTH($nowResult), DateTime::DAYOFMONTH($todayResult)); - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DeprecatedExcelErrorTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DeprecatedExcelErrorTest.php deleted file mode 100644 index a2356f7fad..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DeprecatedExcelErrorTest.php +++ /dev/null @@ -1,55 +0,0 @@ - [ - [Functions::class, 'null'], - ExcelError::null(), - ], - 'NAN' => [ - [Functions::class, 'NAN'], - ExcelError::NAN(), - ], - 'NA' => [ - [Functions::class, 'NA'], - ExcelError::NA(), - ], - 'NAME' => [ - [Functions::class, 'NAME'], - ExcelError::NAME(), - ], - 'REF' => [ - [Functions::class, 'REF'], - ExcelError::REF(), - ], - 'VALUE' => [ - [Functions::class, 'VALUE'], - ExcelError::VALUE(), - ], - 'DIV0' => [ - [Functions::class, 'DIV0'], - ExcelError::DIV0(), - ], - ]; - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/MovedBitwiseTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/MovedBitwiseTest.php deleted file mode 100644 index 995ae35452..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/MovedBitwiseTest.php +++ /dev/null @@ -1,24 +0,0 @@ -setDelta(1.0E-8); - self::assertSame('3+4i', Engineering::COMPLEX(3, 4)); - self::assertEqualsWithDelta(5.67, Engineering::IMAGINARY('12.34+5.67j'), 1E-8); - self::assertEqualsWithDelta(12.34, Engineering::IMREAL('12.34+5.67j'), 1E-8); - self::assertEqualsWithDelta(13.58029822942, Engineering::IMABS('12.34+5.67j'), 1E-8); - self::assertEqualsWithDelta(0.43071059555, Engineering::IMARGUMENT('12.34+5.67j'), 1E-8); - $complexAssert->runAssertComplexEquals('12.34-5.67j', Engineering::IMCONJUGATE('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('141.319179436356+32.547610312508j', Engineering::IMCOS('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('93502.0563713182121-65794.6618967782119j', Engineering::IMCOSH('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('93502.0563713182121-65794.6618967782119j', Engineering::IMCOSH('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('-0.0000104004141424230319-1.00002138037057154j', Engineering::IMCOT('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('-0.00154774455592154432-0.00671986631601416928j', Engineering::IMCSC('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('7.15308425027293823E-6+5.03341614148979354E-6j', Engineering::IMCSCH('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('0.0961415519586104-0.00694248653276682j', Engineering::IMDIV('12.34+5.67j', '123.45+67.89j')); - $complexAssert->runAssertComplexEquals('187004.11273906-131589.323796073j', Engineering::IMEXP('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('2.60862008281875+0.430710595550204j', Engineering::IMLN('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('3.76344325733562+0.621384040306436j', Engineering::IMLOG2('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('1.13290930735019+0.187055234944717j', Engineering::IMLOG10('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('120.1267+139.9356j', Engineering::IMPOWER('12.34+5.67j', 2)); - $complexAssert->runAssertComplexEquals('6454.936089+8718.895647i', Engineering::IMPRODUCT('12.34+5.67i', '123.45+67.89i', '5.67')); - $complexAssert->runAssertComplexEquals('0.00671973874162309199-0.00154764157870523791j', Engineering::IMSEC('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('7.15308425036177674E-6+5.03341614116724074E-6j', Engineering::IMSECH('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('-32.5483841590412+141.315819535092j', Engineering::IMSIN('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('93502.0563677416700-65794.6618992949199j', Engineering::IMSINH('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('3.60002071031685+0.787495469644252j', Engineering::IMSQRT('12.34+5.67j')); - $complexAssert->runAssertComplexEquals('-111.11-62.22j', Engineering::IMSUB('12.34+5.67j', '123.45+67.89j')); - $complexAssert->runAssertComplexEquals('135.79+73.56j', Engineering::IMSUM('12.34+5.67j', '123.45+67.89j')); - $complexAssert->runAssertComplexEquals('-0.0000103999694261435177+0.999978619978377253j', Engineering::IMTAN('12.34+5.67j')); - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MovedFunctionsTest.php deleted file mode 100644 index 657d1752a0..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Financial/MovedFunctionsTest.php +++ /dev/null @@ -1,67 +0,0 @@ -getActiveSheet(); - $cell = $sheet->getCell('A1'); - $cell->setValue('=1'); - self::assertTrue(Functions::isFormula('A1', $cell)); - $spreadsheet->disconnectWorksheets(); - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/DeprecatedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/DeprecatedFunctionsTest.php deleted file mode 100644 index 341d04e404..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Logical/DeprecatedFunctionsTest.php +++ /dev/null @@ -1,30 +0,0 @@ -getSheet(); $sheet->getCell('A1')->setValue('A2'); $sheet->getCell('A2')->setValue('This is it'); - $result = \PhpOffice\PhpSpreadsheet\Calculation\LookupRef::INDIRECT('A2', $sheet->getCell('A1')); + $result = \PhpOffice\PhpSpreadsheet\Calculation\LookupRef\Indirect::INDIRECT('A2', true, $sheet->getCell('A1')); $result = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenSingleValue($result); self::assertSame('This is it', $result); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MovedFunctionsTest.php deleted file mode 100644 index 860c3e4db2..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/LookupRef/MovedFunctionsTest.php +++ /dev/null @@ -1,103 +0,0 @@ -2')); - self::assertEquals(2, MathTrig::SUMIFS( - [[1], [1], [1]], - [['Y'], ['Y'], ['N']], - '=Y', - [['H'], ['H'], ['H']], - '=H' - )); - self::assertEquals(17, MathTrig::SUMPRODUCT([1, 2, 3], [5, 0, 4])); - self::assertEquals(21, MathTrig::SUMSQ(1, 2, 4)); - self::assertEquals(-20, MathTrig::SUMX2MY2([1, 2], [3, 4])); - self::assertEquals(30, MathTrig::SUMX2PY2([1, 2], [3, 4])); - self::assertEquals(8, MathTrig::SUMXMY2([1, 2], [3, 4])); - self::assertEquals(0, MathTrig::builtinTAN(0)); - self::assertEquals(0, MathTrig::builtinTANH(0)); - self::assertEquals(70, MathTrig::TRUNC(79.2, -1)); - self::assertEquals(1, MathTrig::returnSign(79.2)); - self::assertEquals(80, MathTrig::getEven(79.2)); - $nullVal = null; - MathTrig::nullFalseTrueToNumber($nullVal); - self::assertSame(0, $nullVal); - $nullVal = true; - MathTrig::nullFalseTrueToNumber($nullVal); - self::assertSame(1, $nullVal); - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MovedFunctionsTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MovedFunctionsTest.php deleted file mode 100644 index 37f84705e8..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/Statistical/MovedFunctionsTest.php +++ /dev/null @@ -1,116 +0,0 @@ - 7000, 14000, 21000, 28000], '<23000'), 1E-8); - self::assertEqualsWithDelta(0.4059136, Statistical::BETADIST(0.4, 4, 5), 1E-8); - self::assertEqualsWithDelta(1.862243320728, Statistical::BETAINV(0.52, 3, 4, 1, 3), 1E-8); - self::assertEqualsWithDelta(0.706399436132, Statistical::BINOMDIST(3, 8, 0.35, true), 1E-8); - self::assertEqualsWithDelta(0.964294972685, Statistical::CHIDIST(3, 9), 1E-8); - self::assertEqualsWithDelta(8.383430828608, Statistical::CHIINV(0.3, 7), 1E-8); - self::assertEqualsWithDelta(0.692951912734, Statistical::CONFIDENCE(0.05, 2.5, 50), 1E-8); - self::assertEqualsWithDelta(0.997054485502, Statistical::CORREL([3, 2, 4, 5, 6], [9, 7, 12, 15, 17]), 1E-8); - self::assertEqualsWithDelta(4, Statistical::COUNT(['0.1.A' => 0, '0.2.A' => 2, '0.3.A' => '', '0.4.A' => null, '0.5.A' => 5, '0.6.A' => 6.1]), 1E-8); - self::assertEqualsWithDelta(5, Statistical::COUNTA(['0.1.A' => 0, '0.2.A' => 2, '0.3.A' => '', '0.4.A' => null, '0.5.A' => 5, '0.6.A' => 6.1]), 1E-8); - self::assertEqualsWithDelta(2, Statistical::COUNTBLANK(['0.1.A' => 0, '0.2.A' => 2, '0.3.A' => '', '0.4.A' => null, '0.5.A' => 5, '0.6.A' => 6.1]), 1E-8); - self::assertEqualsWithDelta(2, Statistical::COUNTIF(['apples', 'oranges', 'peaches', 'apples'], 'apples'), 1E-8); - self::assertEqualsWithDelta(2, Statistical::COUNTIFS(['Y', 'Y', 'N'], '=Y'), 1E-8); - self::assertEqualsWithDelta(5.2, Statistical::COVAR([3, 2, 4, 5, 6], [9, 7, 12, 15, 17]), 1E-8); - self::assertEqualsWithDelta(32, Statistical::CRITBINOM(100, 0.3, 0.7), 1E-8); - self::assertEqualsWithDelta(48, Statistical::DEVSQ(4, 5, 8, 7, 11, 4, 3), 1E-8); - self::assertEqualsWithDelta(1.353352832366, Statistical::EXPONDIST(0.2, 10, false), 1E-8); - self::assertEqualsWithDelta(0.001223791709, Statistical::FDIST2(15.2069, 6, 4, false), 1E-8); - self::assertEqualsWithDelta(-1.472219489583, Statistical::FISHER(-0.9), 1E-8); - self::assertEqualsWithDelta(-0.197375320225, Statistical::FISHERINV(-0.2), 1E-8); - self::assertEqualsWithDelta(10.607253086419, Statistical::FORECAST(30, [6, 7, 9, 15, 21], [20, 28, 31, 38, 40]), 1E-8); - self::assertEqualsWithDelta(1.329340388179, Statistical::GAMMAFunction(2.5), 1E-8); - self::assertEqualsWithDelta(0.03263913041829, Statistical::GAMMADIST(10.00001131, 9, 2, false), 1E-8); - self::assertEqualsWithDelta(10.0000111914377, Statistical::GAMMAINV(0.068094, 9, 2), 1E-8); - self::assertEqualsWithDelta(2.453736570842, Statistical::GAMMALN(4.5), 1E-8); - self::assertEqualsWithDelta(0.4772498680518, Statistical::GAUSS(2), 1E-8); - self::assertEqualsWithDelta(5.47698696965696, Statistical::GEOMEAN(4, 5, 8, 7, 11, 4, 3), 1E-8); - self::assertEqualsWithDelta([[[32618.203773539713], [47729.42261474774], [69841.30085621739], [102197.07337883231], [149542.48674004572], [218821.87621459525]]], Statistical::GROWTH([33100, 47300, 69000, 102000, 150000, 220000], [11, 12, 13, 14, 15, 16]), 1E-8); - self::assertEqualsWithDelta(5.028375962062, Statistical::HARMEAN(4, 5, 8, 7, 11, 4, 3), 1E-8); - self::assertEqualsWithDelta(0.3632610939112, Statistical::HYPGEOMDIST(1, 4, 8, 20), 1E-8); - self::assertEqualsWithDelta(25.0, Statistical::INTERCEPT([5, 10, 15, 20], [12, 9, 6, 3]), 1E-8); - self::assertEqualsWithDelta(-0.1517996372084, Statistical::KURT([3, 4, 5, 2, 3, 4, 5, 6, 4, 7]), 1E-8); - self::assertEqualsWithDelta(5, Statistical::LARGE([3, 4, 5, 2, 3, 4, 5, 6, 4, 7], 3), 1E-8); - self::assertEqualsWithDelta([1.0, 0.0], Statistical::LINEST([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], false, false), 1E-8); - self::assertEqualsWithDelta([1.000174230092, 1.0], Statistical::LOGEST([1, 2, 3, 4, 5], [1, 10, 100, 1000, 10000], false, false), 1E-8); - self::assertEqualsWithDelta(4.000025209777, Statistical::LOGINV(0.039084, 3.5, 1.2), 1E-8); - self::assertEqualsWithDelta(0.0390835557068, Statistical::LOGNORMDIST(4, 3.5, 1.2), 1E-8); - self::assertEqualsWithDelta(0.0390835557068, Statistical::LOGNORMDIST2(4, 3.5, 1.2, true), 1E-8); - self::assertEqualsWithDelta(27, Statistical::MAX(10, 7, 9, 27, 2), 1E-8); - self::assertEqualsWithDelta(10, Statistical::MAXA(10, 7, 9, '17', 2), 1E-8); - self::assertEqualsWithDelta(2, Statistical::MAXIFS([1, 2, 3], ['Y', 'Y', 'N'], '=Y', ['H', 'H', 'H'], '=H'), 1E-8); - self::assertEqualsWithDelta(8.0, Statistical::MEDIAN(1, 4.5, 7, 8, 9, 13, 14), 1E-8); - self::assertEqualsWithDelta(2, Statistical::MIN(10, 7, 9, 27, 2), 1E-8); - self::assertEqualsWithDelta(-7, Statistical::MINA(10, '-9', -7, '17', 2), 1E-8); - self::assertEqualsWithDelta(1, Statistical::MINIFS([1, 2, 3], ['Y', 'Y', 'N'], '=Y', ['H', 'H', 'H'], '=H'), 1E-8); - self::assertEqualsWithDelta(4.1, Statistical::MODE(5.6, 4.1, 4.1, 3, 2, 4.1), 1E-8); - self::assertEqualsWithDelta(0.05504866037517786, Statistical::NEGBINOMDIST(10, 5, 0.25), 1E-8); - self::assertEqualsWithDelta(0.05504866037517786, Statistical::NEGBINOMDIST(10, 5, 0.25), 1E-8); - self::assertEqualsWithDelta(0.9087887802741, Statistical::NORMDIST(42, 40, 1.5, true), 1E-8); - self::assertEqualsWithDelta(42.000002008416, Statistical::NORMINV(0.908789, 40, 1.5), 1E-8); - self::assertEqualsWithDelta(0.908788780274, Statistical::NORMSDIST(1.333333333333), 1E-8); - self::assertEqualsWithDelta(0.164010074676, Statistical::NORMSDIST2(1.333333333333, false), 1E-8); - self::assertEqualsWithDelta(1.9, Statistical::PERCENTILE([1, 2, 3, 4], 0.3), 1E-8); - self::assertEqualsWithDelta(0.667, Statistical::PERCENTRANK([1, 2, 3, 4], 3), 1E-8); - self::assertEqualsWithDelta(20, Statistical::PERMUT(5, 2), 1E-8); - self::assertEqualsWithDelta(0.12465201948308113, Statistical::POISSON(2, 5, true), 1E-8); - self::assertEqualsWithDelta(3.5, Statistical::QUARTILE([1, 2, 4, 7, 8, 9, 10, 12], 1), 1E-8); - self::assertEqualsWithDelta(2, Statistical::RANK(3.5, [7, 3.5, 3.5, 2, 1]), 1E-8); - self::assertEqualsWithDelta(0.057950191571, Statistical::RSQ([2, 3, 9, 1, 8, 7, 5], [6, 5, 11, 7, 5, 4, 4]), 1E-8); - self::assertEqualsWithDelta(0.359543071407, Statistical::SKEW([3, 4, 5, 2, 3, 4, 5, 6, 4, 7]), 1E-8); - self::assertEqualsWithDelta(0.6, Statistical::SLOPE([3, 6, 9, 12], [5, 10, 15, 20]), 1E-8); - self::assertEqualsWithDelta(3, Statistical::SMALL([1, 4, 8, 3, 7, 12, 54, 8, 23], 2), 1E-8); - self::assertEqualsWithDelta(1.333333333333, Statistical::STANDARDIZE(42, 40, 1.5), 1E-8); - self::assertEqualsWithDelta(27.463915719843, Statistical::STDEV([1345, 1301, 1368, 1322, 1310, 1370, 1318, 1350, 1303, 1299]), 1E-8); - self::assertEqualsWithDelta(0.577350269190, Statistical::STDEVA([true, false, 1]), 1E-8); - self::assertEqualsWithDelta(26.0545581424825, Statistical::STDEVP([1345, 1301, 1368, 1322, 1310, 1370, 1318, 1350, 1303, 1299]), 1E-8); - self::assertEqualsWithDelta(0.471404520791, Statistical::STDEVPA([true, false, 1]), 1E-8); - self::assertEqualsWithDelta(3.305718950210, Statistical::STEYX([2, 3, 9, 1, 8, 7, 5], [6, 5, 11, 7, 5, 4, 4]), 1E-8); - self::assertEqualsWithDelta(0.027322464988, Statistical::TDIST(1.959999998, 60, 1), 1E-8); - self::assertEqualsWithDelta(1.960041187127, Statistical::TINV(0.05464, 60), 1E-8); - $trendExpected = [[ - [133953.33333333334], - [134971.51515151517], - [135989.69696969696], - [137007.87878787878], - [138026.0606060606], - [139044.24242424243], - [140062.42424242425], - [141080.60606060608], - [142098.78787878787], - [143116.9696969697], - [144135.15151515152], - [145153.33333333334], - ]]; - $trendArg1 = [133890, 135000, 135790, 137300, 138130, 139100, 139900, 141120, 141890, 143230, 144000, 145290]; - $trendArg2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; - self::assertEqualsWithDelta($trendExpected, Statistical::TREND($trendArg1, $trendArg2), 1E-8); - self::assertEqualsWithDelta(3.777777777778, Statistical::TRIMMEAN([4, 5, 6, 7, 2, 3, 4, 5, 1, 2, 3], 0.2), 1E-8); - self::assertEqualsWithDelta(754.266666666667, Statistical::VARFunc([1345, 1301, 1368, 1322, 1310, 1370, 1318, 1350, 1303, 1299]), 1E-8); - self::assertEqualsWithDelta(754.266666666667, Statistical::VARA([1345, 1301, 1368, 1322, 1310, 1370, 1318, 1350, 1303, 1299]), 1E-8); - self::assertEqualsWithDelta(678.84, Statistical::VARP([1345, 1301, 1368, 1322, 1310, 1370, 1318, 1350, 1303, 1299]), 1E-8); - self::assertEqualsWithDelta(0.222222222222, Statistical::VARPA([true, false, 1]), 1E-8); - self::assertEqualsWithDelta(0.929581390070, Statistical::WEIBULL(105, 20, 100, true), 1E-8); - self::assertEqualsWithDelta(0.090574196851, Statistical::ZTEST([3, 6, 7, 8, 6, 5, 4, 2, 1, 9], 4), 1E-8); - } -} diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php deleted file mode 100644 index b532ead464..0000000000 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/TextData/DeprecatedTest.php +++ /dev/null @@ -1,45 +0,0 @@ -getMajorGridlines(); + $majorGridlines2 = $chart->getChartAxisY()->getMajorGridlines(); self::assertNotNull($majorGridlines2); self::assertEquals($width, $majorGridlines2->getLineStyleProperty('width')); self::assertEquals($compound, $majorGridlines2->getLineStyleProperty('compound')); @@ -368,7 +368,7 @@ public function testLineStylesDeprecated(): void self::assertEquals('sm', $majorGridlines2->getLineStyleProperty(['arrow', 'end', 'w'])); self::assertEquals('lg', $majorGridlines2->getLineStyleProperty(['arrow', 'end', 'len'])); - $minorGridlines2 = $chart->getMinorGridlines(); + $minorGridlines2 = $chart->getChartAxisY()->getMinorGridlines(); self::assertNotNull($minorGridlines2); self::assertSame('00FF00', $minorGridlines2->getLineColorProperty('value')); self::assertSame(30, $minorGridlines2->getLineColorProperty('alpha')); @@ -393,7 +393,7 @@ public function testLineStylesDeprecated(): void self::assertCount(1, $charts2); $chart2 = $charts2[0]; self::assertNotNull($chart2); - $majorGridlines3 = $chart2->getMajorGridlines(); + $majorGridlines3 = $chart2->getChartAxisY()->getMajorGridlines(); self::assertNotNull($majorGridlines3); self::assertEquals($width, $majorGridlines3->getLineStyleProperty('width')); self::assertEquals($compound, $majorGridlines3->getLineStyleProperty('compound')); @@ -407,7 +407,7 @@ public function testLineStylesDeprecated(): void self::assertEquals('sm', $majorGridlines3->getLineStyleProperty(['arrow', 'end', 'w'])); self::assertEquals('lg', $majorGridlines3->getLineStyleProperty(['arrow', 'end', 'len'])); - $minorGridlines3 = $chart2->getMinorGridlines(); + $minorGridlines3 = $chart2->getChartAxisY()->getMinorGridlines(); self::assertNotNull($minorGridlines3); self::assertSame('00FF00', $minorGridlines3->getLineColorProperty('value')); self::assertSame(30, $minorGridlines3->getLineColorProperty('alpha')); diff --git a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php index ef1d3d3529..9d62eae37b 100644 --- a/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php +++ b/tests/PhpSpreadsheetTests/DocumentGeneratorTest.php @@ -6,7 +6,7 @@ use PhpOffice\PhpSpreadsheet\Calculation\Category as Cat; use PhpOffice\PhpSpreadsheet\Calculation\Functions; -use PhpOffice\PhpSpreadsheet\Calculation\Logical; +use PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations; use PhpOffice\PhpSpreadsheetInfra\DocumentGenerator; use PHPUnit\Framework\TestCase; use UnexpectedValueException; @@ -35,7 +35,7 @@ public static function providerGenerateFunctionListByName(): array [ [ 'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs'], - 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'logicalAnd']], + 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Operations::class, 'logicalAnd']], 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY']], ], <<<'EXPECTED' @@ -46,7 +46,7 @@ public static function providerGenerateFunctionListByName(): array Excel Function | Category | PhpSpreadsheet Function -------------------------|--------------------------------|-------------------------------------- ABS | CATEGORY_MATH_AND_TRIG | abs - AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd + AND | CATEGORY_LOGICAL | \PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations::logicalAnd ## I @@ -66,7 +66,7 @@ public static function providerGenerateFunctionListByCategory(): array [ [ 'ABS' => ['category' => Cat::CATEGORY_MATH_AND_TRIG, 'functionCall' => 'abs'], - 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Logical::class, 'logicalAnd']], + 'AND' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Operations::class, 'logicalAnd']], 'IFS' => ['category' => Cat::CATEGORY_LOGICAL, 'functionCall' => [Functions::class, 'DUMMY']], ], <<<'EXPECTED' @@ -106,7 +106,7 @@ public static function providerGenerateFunctionListByCategory(): array Excel Function | PhpSpreadsheet Function -------------------------|-------------------------------------- - AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical::logicalAnd + AND | \PhpOffice\PhpSpreadsheet\Calculation\Logical\Operations::logicalAnd IFS | **Not yet Implemented** ## CATEGORY_LOOKUP_AND_REFERENCE diff --git a/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowTest.php b/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowTest.php index 2d07fb6c98..4670719242 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/ByColumnAndRowTest.php @@ -18,7 +18,7 @@ public function testSetCellValueByColumnAndRow(): void $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); - $sheet->setCellValueByColumnAndRow(2, 2, 2); + $sheet->setCellValue([2, 2], 2); self::assertSame(2, $sheet->getCell('B2')->getValue()); $spreadsheet->disconnectWorksheets(); } @@ -28,7 +28,7 @@ public function testSetCellValueExplicitByColumnAndRow(): void $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); - $sheet->setCellValueExplicitByColumnAndRow(2, 2, '="PHP Rules"', DataType::TYPE_STRING); + $sheet->setCellValueExplicit([2, 2], '="PHP Rules"', DataType::TYPE_STRING); self::assertSame('="PHP Rules"', $sheet->getCell('B2')->getValue()); self::assertSame(DataType::TYPE_STRING, $sheet->getCell('B2')->getDataType()); $spreadsheet->disconnectWorksheets(); @@ -39,12 +39,12 @@ public function testCellExistsByColumnAndRow(): void $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); - $cellExists = $sheet->cellExistsByColumnAndRow(2, 2); + $cellExists = $sheet->cellExists([2, 2]); self::assertFalse($cellExists); $sheet->setCellValue('B2', 2); - $cellExists = $sheet->cellExistsByColumnAndRow(2, 2); + $cellExists = $sheet->cellExists([2, 2]); self::assertTrue($cellExists); $spreadsheet->disconnectWorksheets(); } @@ -55,7 +55,7 @@ public function testGetCellByColumnAndRow(): void $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('B2', 2); - $cell = $sheet->getCellByColumnAndRow(2, 2); + $cell = $sheet->getCell([2, 2]); self::assertSame('B2', $cell->getCoordinate()); self::assertSame(2, $cell->getValue()); $spreadsheet->disconnectWorksheets(); @@ -70,10 +70,10 @@ public function testGetStyleByColumnAndRow(): void $sheet->fromArray($data, null, 'B2', true); $sheet->getStyle('B2:C3')->getFont()->setBold(true); - $rangeStyle = $sheet->getStyleByColumnAndRow(2, 2, 3, 3); + $rangeStyle = $sheet->getStyle([2, 2, 3, 3]); self::assertTrue($rangeStyle->getFont()->getBold()); - $cellStyle = $sheet->getStyleByColumnAndRow(2, 2); + $cellStyle = $sheet->getStyle([2, 2]); self::assertTrue($cellStyle->getFont()->getBold()); $spreadsheet->disconnectWorksheets(); } @@ -84,7 +84,7 @@ public function testSetBreakByColumnAndRow(): void $sheet = $spreadsheet->getActiveSheet(); $sheet->setCellValue('B2', 2); - $sheet->setBreakByColumnAndRow(2, 2, Worksheet::BREAK_COLUMN); + $sheet->setBreak([2, 2], Worksheet::BREAK_COLUMN); $breaks = $sheet->getBreaks(); self::assertArrayHasKey('B2', $breaks); @@ -100,7 +100,7 @@ public function testMergeCellsByColumnAndRow(): void $data = [['A', 'B'], ['C', 'D']]; $sheet->fromArray($data, null, 'B2', true); - $sheet->mergeCellsByColumnAndRow(2, 2, 3, 3); + $sheet->mergeCells([2, 2, 3, 3]); $mergeRanges = $sheet->getMergeCells(); self::assertArrayHasKey('B2:C3', $mergeRanges); $spreadsheet->disconnectWorksheets(); @@ -118,7 +118,7 @@ public function testUnergeCellsByColumnAndRow(): void $mergeRanges = $sheet->getMergeCells(); self::assertArrayHasKey('B2:C3', $mergeRanges); - $sheet->unmergeCellsByColumnAndRow(2, 2, 3, 3); + $sheet->unmergeCells([2, 2, 3, 3]); $mergeRanges = $sheet->getMergeCells(); self::assertEmpty($mergeRanges); $spreadsheet->disconnectWorksheets(); @@ -132,7 +132,7 @@ public function testProtectCellsByColumnAndRow(): void $data = [['A', 'B'], ['C', 'D']]; $sheet->fromArray($data, null, 'B2', true); - $sheet->protectCellsByColumnAndRow(2, 2, 3, 3, 'secret', false); + $sheet->protectCells([2, 2, 3, 3], 'secret', false); $protectedRanges = $sheet->getProtectedCells(); self::assertArrayHasKey('B2:C3', $protectedRanges); $spreadsheet->disconnectWorksheets(); @@ -150,7 +150,7 @@ public function testUnprotectCellsByColumnAndRow(): void $protectedRanges = $sheet->getProtectedCells(); self::assertArrayHasKey('B2:C3', $protectedRanges); - $sheet->unprotectCellsByColumnAndRow(2, 2, 3, 3); + $sheet->unprotectCells([2, 2, 3, 3]); $protectedRanges = $sheet->getProtectedCells(); self::assertEmpty($protectedRanges); $spreadsheet->disconnectWorksheets(); @@ -164,7 +164,7 @@ public function testSetAutoFilterByColumnAndRow(): void $data = [['A', 'B'], ['C', 'D']]; $sheet->fromArray($data, null, 'B2', true); - $sheet->setAutoFilterByColumnAndRow(2, 2, 3, 3); + $sheet->setAutoFilter([2, 2, 3, 3]); $autoFilter = $sheet->getAutoFilter(); self::assertInstanceOf(AutoFilter::class, $autoFilter); self::assertSame('B2:C3', $autoFilter->getRange()); @@ -179,7 +179,7 @@ public function testFreezePaneByColumnAndRow(): void $data = [['A', 'B'], ['C', 'D']]; $sheet->fromArray($data, null, 'B2', true); - $sheet->freezePaneByColumnAndRow(2, 2); + $sheet->freezePane([2, 2]); $freezePane = $sheet->getFreezePane(); self::assertSame('B2', $freezePane); $spreadsheet->disconnectWorksheets(); @@ -195,7 +195,7 @@ public function testGetCommentByColumnAndRow(): void ->getComment('B2') ->getText()->createTextRun('My Test Comment'); - $comment = $sheet->getCommentByColumnAndRow(2, 2); + $comment = $sheet->getComment([2, 2]); self::assertInstanceOf(Comment::class, $comment); self::assertSame('My Test Comment', $comment->getText()->getPlainText()); $spreadsheet->disconnectWorksheets(); From 72d32662c8809f1baa6c6565ab22be2b99bd7659 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 10 Dec 2023 19:48:32 +0100 Subject: [PATCH 10/25] Last scalar return types --- src/PhpSpreadsheet/Calculation/Functions.php | 3 --- src/PhpSpreadsheet/Chart/Properties.php | 4 +--- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 8e74b35cb8..7aab6ec337 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -226,9 +226,6 @@ public static function flattenArray($array): array return $flattened; } - /** - * @return null|mixed - */ public static function scalar(mixed $value): mixed { if (!is_array($value)) { diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index b9252c2ed0..343c40fef7 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -464,10 +464,8 @@ public function getGlowProperty(array|string $property): null|array|float|int|st /** * Get Glow Color Property. - * - * @return null|int|string */ - public function getGlowColor(string $propertyName) + public function getGlowColor(string $propertyName): null|int|string { return $this->glowColor->getColorProperty($propertyName); } From 4c2f3804c1d36bda4348c041bc1d7be343b67a88 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Sun, 10 Dec 2023 19:51:55 +0100 Subject: [PATCH 11/25] Remove duplicated return types --- src/PhpSpreadsheet/Cell/Cell.php | 2 -- src/PhpSpreadsheet/Chart/Legend.php | 2 -- src/PhpSpreadsheet/Shared/Escher.php | 4 ---- src/PhpSpreadsheet/Shared/Escher/DggContainer.php | 2 -- .../Shared/Escher/DggContainer/BstoreContainer/BSE.php | 2 -- src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php | 2 -- 6 files changed, 14 deletions(-) diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index 3a2b689d58..d0fc390ff7 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -546,8 +546,6 @@ public function setHyperlink(?Hyperlink $hyperlink = null): self /** * Get cell collection. - * - * @return ?Cells */ public function getParent(): ?Cells { diff --git a/src/PhpSpreadsheet/Chart/Legend.php b/src/PhpSpreadsheet/Chart/Legend.php index 53407a590e..237457f2b2 100644 --- a/src/PhpSpreadsheet/Chart/Legend.php +++ b/src/PhpSpreadsheet/Chart/Legend.php @@ -131,8 +131,6 @@ public function setOverlay(bool $overlay): void /** * Get Layout. - * - * @return ?Layout */ public function getLayout(): ?Layout { diff --git a/src/PhpSpreadsheet/Shared/Escher.php b/src/PhpSpreadsheet/Shared/Escher.php index feb314bb58..8b9b3df115 100644 --- a/src/PhpSpreadsheet/Shared/Escher.php +++ b/src/PhpSpreadsheet/Shared/Escher.php @@ -20,8 +20,6 @@ class Escher /** * Get Drawing Group Container. - * - * @return ?Escher\DggContainer */ public function getDggContainer(): ?Escher\DggContainer { @@ -38,8 +36,6 @@ public function setDggContainer(Escher\DggContainer $dggContainer): Escher\DggCo /** * Get Drawing Container. - * - * @return ?Escher\DgContainer */ public function getDgContainer(): ?Escher\DgContainer { diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php index 523bb41773..9b0c9bb263 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer.php @@ -86,8 +86,6 @@ public function setCSpSaved(int $value): void /** * Get BLIP Store Container. - * - * @return ?DggContainer\BstoreContainer */ public function getBstoreContainer(): ?DggContainer\BstoreContainer { diff --git a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php index ee2a5c2a75..8ea6fac40c 100644 --- a/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php +++ b/src/PhpSpreadsheet/Shared/Escher/DggContainer/BstoreContainer/BSE.php @@ -45,8 +45,6 @@ public function setParent(BstoreContainer $parent): void /** * Get the BLIP. - * - * @return ?BSE\Blip */ public function getBlip(): ?BSE\Blip { diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php index 6be6ccbc61..93768a1ce8 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column/Rule.php @@ -367,8 +367,6 @@ public function setRule(string $operator, $value, ?string $grouping = null): sta /** * Get this Rule's AutoFilter Column Parent. - * - * @return ?Column */ public function getParent(): ?Column { From bab6fc4e24e19fc1b47cd66068d9d9dda5b38b70 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 11 Dec 2023 09:06:11 +0100 Subject: [PATCH 12/25] More @param to native types --- phpstan-baseline.neon | 5 +++ .../Calculation/Calculation.php | 4 +- .../Calculation/Database/DatabaseAbstract.php | 5 +-- .../Calculation/DateTimeExcel/Difference.php | 7 +-- .../Calculation/DateTimeExcel/Helpers.php | 2 +- .../Calculation/Engineering/BitWise.php | 44 +++++++------------ .../Calculation/Engineering/Erf.php | 4 +- .../CashFlow/CashFlowValidations.php | 5 +-- src/PhpSpreadsheet/Calculation/Functions.php | 4 +- .../Calculation/LookupRef/Indirect.php | 4 +- .../Calculation/MathTrig/Helpers.php | 16 ++----- .../Calculation/MathTrig/Operations.php | 8 ++-- .../Calculation/MathTrig/Trunc.php | 8 ++-- .../Distributions/StandardNormal.php | 3 +- src/PhpSpreadsheet/Chart/Axis.php | 2 - src/PhpSpreadsheet/Chart/Chart.php | 6 --- src/PhpSpreadsheet/Chart/ChartColor.php | 11 +---- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 6 +-- src/PhpSpreadsheet/Chart/Layout.php | 4 -- src/PhpSpreadsheet/Chart/Properties.php | 31 ++----------- src/PhpSpreadsheet/Chart/Title.php | 8 +--- src/PhpSpreadsheet/Document/Properties.php | 13 ++---- src/PhpSpreadsheet/Reader/Html.php | 4 +- src/PhpSpreadsheet/Reader/Xls.php | 6 +-- src/PhpSpreadsheet/Reader/Xlsx.php | 12 +---- src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php | 10 +---- src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 3 -- .../Reader/Xlsx/ConditionalStyles.php | 10 +---- src/PhpSpreadsheet/Reader/Xlsx/Properties.php | 5 +-- src/PhpSpreadsheet/Reader/Xlsx/Styles.php | 4 +- src/PhpSpreadsheet/Shared/Date.php | 4 +- src/PhpSpreadsheet/Shared/Font.php | 4 +- src/PhpSpreadsheet/Shared/OLERead.php | 2 - src/PhpSpreadsheet/Shared/StringHelper.php | 4 +- src/PhpSpreadsheet/Shared/Trend/BestFit.php | 5 +-- src/PhpSpreadsheet/Spreadsheet.php | 10 +---- src/PhpSpreadsheet/Style/Border.php | 5 +-- .../ConditionalDataBarExtension.php | 6 +-- .../Style/NumberFormat/NumberFormatter.php | 5 +-- .../Style/NumberFormat/Wizard/DateTime.php | 5 +-- src/PhpSpreadsheet/Style/Supervisor.php | 4 +- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 6 +-- src/PhpSpreadsheet/Worksheet/PageSetup.php | 2 - src/PhpSpreadsheet/Worksheet/SheetView.php | 6 --- src/PhpSpreadsheet/Worksheet/Table.php | 2 +- src/PhpSpreadsheet/Writer/Html.php | 26 ++++++----- src/PhpSpreadsheet/Writer/Xls.php | 5 +-- src/PhpSpreadsheet/Writer/Xls/Xf.php | 4 -- src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php | 13 ++---- .../PhpSpreadsheetTests/Shared/Date2Test.php | 2 - .../Worksheet/AutoFilter/AutoFilterTest.php | 12 ----- .../Worksheet/Table/TableTest.php | 10 ----- 52 files changed, 98 insertions(+), 298 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index a5573ea05d..fecf4eca6f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1175,6 +1175,11 @@ parameters: count: 1 path: src/PhpSpreadsheet/Chart/DataSeriesValues.php + - + message: "#^Argument of an invalid type array\\\\|SimpleXMLElement\\|null supplied for foreach, only iterables are supported\\.$#" + count: 2 + path: src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php + - message: "#^Cannot access property \\$color on SimpleXMLElement\\|null\\.$#" count: 2 diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index 88caeefe71..f9da3c4ea2 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -5526,10 +5526,8 @@ private function getArgumentDefaultValue(ReflectionParameter $methodArgument): m /** * Add cell reference if needed while making sure that it is the last argument. - * - * @param array|string $functionCall */ - private function addCellReference(array $args, bool $passCellReference, $functionCall, ?Cell $cell = null): array + private function addCellReference(array $args, bool $passCellReference, array|string $functionCall, ?Cell $cell = null): array { if ($passCellReference) { if (is_array($functionCall)) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php b/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php index a1542b7195..6905323c92 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php +++ b/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php @@ -8,10 +8,7 @@ abstract class DatabaseAbstract { - /** - * @param null|int|string $field - */ - abstract public static function evaluate(array $database, $field, array $criteria): null|float|int|string; + abstract public static function evaluate(array $database, null|int|string $field, array $criteria): null|float|int|string; /** * fieldExtract. diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php index 9052b8485b..daf70ad03f 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php @@ -22,8 +22,7 @@ class Difference * @param mixed $endDate Excel date serial value, PHP date/time stamp, PHP DateTime object * or a standard date string * Or can be an array of date values - * @param array|string $unit - * Or can be an array of unit values + * @param array|string $unit Or can be an array of unit values * * @return array|int|string Interval between the dates * If an array of values is passed for the $startDate or $endDays,arguments, then the returned result @@ -80,10 +79,8 @@ private static function initialDiff(float $startDate, float $endDate): float /** * Decide whether it's time to set retVal. - * - * @param bool|int $retVal */ - private static function replaceRetValue($retVal, string $unit, string $compare): null|bool|int + private static function replaceRetValue(bool|int $retVal, string $unit, string $compare): null|bool|int { if ($retVal !== false || $unit !== $compare) { return $retVal; diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index 5f355d47f7..3dd2e4bc6c 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -275,7 +275,7 @@ public static function dateParseSucceeded(array $dateArray): bool * * @param array|false $dateArray */ - private static function forceArray($dateArray): array + private static function forceArray(array|bool $dateArray): array { return is_array($dateArray) ? $dateArray : ['error_count' => 1]; } diff --git a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php index f443c83be2..e1ace4f313 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/BitWise.php @@ -15,11 +15,9 @@ class BitWise /** * Split a number into upper and lower portions for full 32-bit support. * - * @param float|int $number - * * @return int[] */ - private static function splitNumber($number): array + private static function splitNumber(float|int $number): array { return [(int) floor($number / self::SPLIT_DIVISOR), (int) fmod($number, self::SPLIT_DIVISOR)]; } @@ -32,15 +30,13 @@ private static function splitNumber($number): array * Excel Function: * BITAND(number1, number2) * - * @param array|int $number1 - * Or can be an array of values - * @param array|int $number2 - * Or can be an array of values + * @param null|array|bool|float|int|string $number1 Or can be an array of values + * @param null|array|bool|float|int|string $number2 Or can be an array of values * * @return array|int|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 BITAND($number1, $number2): array|string|int + public static function BITAND(null|array|bool|float|int|string $number1, null|array|bool|float|int|string $number2): array|string|int { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -66,15 +62,13 @@ public static function BITAND($number1, $number2): array|string|int * Excel Function: * BITOR(number1, number2) * - * @param array|int $number1 - * Or can be an array of values - * @param array|int $number2 - * Or can be an array of values + * @param null|array|bool|float|int|string $number1 Or can be an array of values + * @param null|array|bool|float|int|string $number2 Or can be an array of values * * @return array|int|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 BITOR($number1, $number2): array|string|int + public static function BITOR(null|array|bool|float|int|string $number1, null|array|bool|float|int|string $number2): array|string|int { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -101,15 +95,13 @@ public static function BITOR($number1, $number2): array|string|int * Excel Function: * BITXOR(number1, number2) * - * @param array|int $number1 - * Or can be an array of values - * @param array|int $number2 - * Or can be an array of values + * @param null|array|bool|float|int|string $number1 Or can be an array of values + * @param null|array|bool|float|int|string $number2 Or can be an array of values * * @return array|int|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 BITXOR($number1, $number2): array|string|int + public static function BITXOR(null|array|bool|float|int|string $number1, null|array|bool|float|int|string $number2): array|string|int { if (is_array($number1) || is_array($number2)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number1, $number2); @@ -136,15 +128,13 @@ public static function BITXOR($number1, $number2): array|string|int * Excel Function: * BITLSHIFT(number, shift_amount) * - * @param array|int $number - * Or can be an array of values - * @param array|int $shiftAmount - * Or can be an array of values + * @param null|array|bool|float|int|string $number Or can be an array of values + * @param null|array|bool|float|int|string $shiftAmount Or can be an array of values * * @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): array|string|float + public static function BITLSHIFT(null|array|bool|float|int|string $number, null|array|bool|float|int|string $shiftAmount): array|string|float { if (is_array($number) || is_array($shiftAmount)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $shiftAmount); @@ -173,15 +163,13 @@ public static function BITLSHIFT($number, $shiftAmount): array|string|float * Excel Function: * BITRSHIFT(number, shift_amount) * - * @param array|int $number - * Or can be an array of values - * @param array|int $shiftAmount - * Or can be an array of values + * @param null|array|bool|float|int|string $number Or can be an array of values + * @param null|array|bool|float|int|string $shiftAmount Or can be an array of values * * @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): array|string|float + public static function BITRSHIFT(null|array|bool|float|int|string $number, null|array|bool|float|int|string $shiftAmount): array|string|float { if (is_array($number) || is_array($shiftAmount)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $number, $shiftAmount); diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Erf.php b/src/PhpSpreadsheet/Calculation/Engineering/Erf.php index 8a64a23463..aee7e31751 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/Erf.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/Erf.php @@ -82,10 +82,8 @@ private static function makeFloat(mixed $value): float /** * Method to calculate the erf value. - * - * @param float|int|string $value */ - public static function erfValue($value): float + public static function erfValue(float|int|string $value): float { $value = (float) $value; if (abs($value) > 2.2) { diff --git a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php index ae5a794b0a..f5719b6992 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php +++ b/src/PhpSpreadsheet/Calculation/Financial/CashFlow/CashFlowValidations.php @@ -9,10 +9,7 @@ class CashFlowValidations extends FinancialValidations { - /** - * @param mixed $rate - */ - public static function validateRate($rate): float + public static function validateRate(mixed $rate): float { $rate = self::validateFloat($rate); diff --git a/src/PhpSpreadsheet/Calculation/Functions.php b/src/PhpSpreadsheet/Calculation/Functions.php index 7aab6ec337..e838ef9cbb 100644 --- a/src/PhpSpreadsheet/Calculation/Functions.php +++ b/src/PhpSpreadsheet/Calculation/Functions.php @@ -200,11 +200,11 @@ private static function operandSpecialHandling(mixed $operand): mixed /** * Convert a multi-dimensional array to a simple 1-dimensional array. * - * @param array|mixed $array Array to be flattened + * @param mixed $array Array to be flattened * * @return array Flattened array */ - public static function flattenArray($array): array + public static function flattenArray(mixed $array): array { if (!is_array($array)) { return (array) $array; diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php b/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php index aa480ab25c..d53900d420 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Indirect.php @@ -34,10 +34,8 @@ private static function a1Format(mixed $a1fmt): bool /** * Convert cellAddress to string, verify not null string. - * - * @param array|string $cellAddress */ - private static function validateAddress($cellAddress): string + private static function validateAddress(array|string|null $cellAddress): string { $cellAddress = Functions::flattenSingleValue($cellAddress); if (!is_string($cellAddress) || !$cellAddress) { diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php b/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php index fd8b2ea9da..57e05b1910 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Helpers.php @@ -39,10 +39,8 @@ public static function validateNumericNullBool(mixed $number): int|float /** * Validate numeric, but allow substitute for null. - * - * @param null|float|int $substitute */ - public static function validateNumericNullSubstitution(mixed $number, $substitute): float|int + public static function validateNumericNullSubstitution(mixed $number, null|float|int $substitute): float|int { $number = Functions::flattenSingleValue($number); if ($number === null && $substitute !== null) { @@ -57,10 +55,8 @@ public static function validateNumericNullSubstitution(mixed $number, $substitut /** * Confirm number >= 0. - * - * @param float|int $number */ - public static function validateNotNegative($number, ?string $except = null): void + public static function validateNotNegative(float|int $number, ?string $except = null): void { if ($number >= 0) { return; @@ -71,10 +67,8 @@ public static function validateNotNegative($number, ?string $except = null): voi /** * Confirm number > 0. - * - * @param float|int $number */ - public static function validatePositive($number, ?string $except = null): void + public static function validatePositive(float|int $number, ?string $except = null): void { if ($number > 0) { return; @@ -85,10 +79,8 @@ public static function validatePositive($number, ?string $except = null): void /** * Confirm number != 0. - * - * @param float|int $number */ - public static function validateNotZero($number): void + public static function validateNotZero(float|int $number): void { if ($number) { return; diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php b/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php index 2c224430be..9c4a6f44a5 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Operations.php @@ -52,16 +52,14 @@ public static function mod(mixed $dividend, mixed $divisor): array|string|float * * Computes x raised to the power y. * - * @param array|float|int $x - * Or can be an array of values - * @param array|float|int $y - * Or can be an array of values + * @param array|float|int|string $x Or can be an array of values + * @param array|float|int|string $y Or can be an array of values * * @return array|float|int|string The result, 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 power($x, $y) + public static function power(array|float|int|string $x, array|float|int|string $y): array|float|int|string { if (is_array($x) || is_array($y)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $x, $y); diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php b/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php index 943e209dd2..44aedd2ca0 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Trunc.php @@ -14,16 +14,14 @@ class Trunc * * Truncates value to the number of fractional digits by number_digits. * - * @param array|float $value - * Or can be an array of values - * @param array|int $digits - * Or can be an array of values + * @param array|float $value Or can be an array of values + * @param array|int $digits Or can be an array of values * * @return array|float|string Truncated value, 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 evaluate($value = 0, $digits = 0) + public static function evaluate(array|float|string|null $value = 0, array|int|string $digits = 0): array|float|string { if (is_array($value) || is_array($digits)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $value, $digits); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php index b7995d400d..a27870158e 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php @@ -87,8 +87,7 @@ public static function inverse(mixed $value) * Calculates the probability that a member of a standard normal population will fall between * the mean and z standard deviations from the mean. * - * @param mixed $value - * Or can be an array of values + * @param mixed $value Or can be an array of values * * @return array|float|string The result, 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 diff --git a/src/PhpSpreadsheet/Chart/Axis.php b/src/PhpSpreadsheet/Chart/Axis.php index 96c3d7f9d8..461a9f72c0 100644 --- a/src/PhpSpreadsheet/Chart/Axis.php +++ b/src/PhpSpreadsheet/Chart/Axis.php @@ -207,8 +207,6 @@ public function setAxisType(string $type): self /** * Set Fill Property. - * - * @param ?int $alpha */ public function setFillParameters(?string $color, ?int $alpha = null, ?string $AlphaType = ChartColor::EXCEL_COLOR_TYPE_RGB): void { diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index 65e74b1e3d..5d370bfc8c 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -398,9 +398,6 @@ public function setTopLeftCell(string $cellAddress): static /** * Set the offset position within the Top Left cell for the chart. * - * @param ?int $xOffset - * @param ?int $yOffset - * * @return $this */ public function setTopLeftOffset(?int $xOffset, ?int $yOffset): static @@ -514,9 +511,6 @@ public function getBottomRightCell(): string /** * Set the offset position within the Bottom Right cell for the chart. * - * @param ?int $xOffset - * @param ?int $yOffset - * * @return $this */ public function setBottomRightOffset(?int $xOffset, ?int $yOffset): static diff --git a/src/PhpSpreadsheet/Chart/ChartColor.php b/src/PhpSpreadsheet/Chart/ChartColor.php index ba530e7167..d6306de6bf 100644 --- a/src/PhpSpreadsheet/Chart/ChartColor.php +++ b/src/PhpSpreadsheet/Chart/ChartColor.php @@ -81,11 +81,7 @@ public function setBrightness(?int $brightness): self return $this; } - /** - * @param null|float|int|string $alpha - * @param null|float|int|string $brightness - */ - public function setColorProperties(?string $color, $alpha = null, ?string $type = null, $brightness = null): self + public function setColorProperties(?string $color, null|float|int|string $alpha = null, ?string $type = null, null|float|int|string $brightness = null): self { if (empty($type) && !empty($color)) { if (str_starts_with($color, '*')) { @@ -157,10 +153,7 @@ public static function alphaToXml(int $alpha): string return (string) (100 - $alpha) . '000'; } - /** - * @param float|int|string $alpha - */ - public static function alphaFromXml($alpha): int + public static function alphaFromXml(float|int|string $alpha): int { return 100 - ((int) $alpha / 1000); } diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index f2e913d400..9e10bf97d1 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -147,8 +147,6 @@ public function getDataSource(): ?string /** * Set Series Data Source (formula). * - * @param ?string $dataSource - * * @return $this */ public function setDataSource(?string $dataSource): static @@ -357,11 +355,9 @@ public function getLineWidth(): null|float|int /** * Set line width for the series. * - * @param null|float|int $width - * * @return $this */ - public function setLineWidth($width): static + public function setLineWidth(null|float|int $width): static { $this->lineStyleProperties['width'] = $width; diff --git a/src/PhpSpreadsheet/Chart/Layout.php b/src/PhpSpreadsheet/Chart/Layout.php index c572a1b3f1..54bde2347a 100644 --- a/src/PhpSpreadsheet/Chart/Layout.php +++ b/src/PhpSpreadsheet/Chart/Layout.php @@ -200,8 +200,6 @@ public function getXMode(): ?string /** * Set X-Mode. * - * @param ?string $mode - * * @return $this */ public function setXMode(?string $mode): static @@ -222,8 +220,6 @@ public function getYMode(): ?string /** * Set Y-Mode. * - * @param ?string $mode - * * @return $this */ public function setYMode(?string $mode): static diff --git a/src/PhpSpreadsheet/Chart/Properties.php b/src/PhpSpreadsheet/Chart/Properties.php index 343c40fef7..b22d5e03d9 100644 --- a/src/PhpSpreadsheet/Chart/Properties.php +++ b/src/PhpSpreadsheet/Chart/Properties.php @@ -178,10 +178,7 @@ public static function xmlToTenthOfPercent(string $value): float return ((float) $value) / self::PERCENTAGE_MULTIPLIER; } - /** - * @param null|float|int|string $alpha - */ - protected function setColorProperties(?string $color, $alpha, ?string $colorType): array + protected function setColorProperties(?string $color, null|float|int|string $alpha, ?string $colorType): array { return [ 'type' => $colorType, @@ -422,10 +419,6 @@ protected function getArrayElementsValue(mixed $properties, mixed $elements): mi /** * Set Glow Properties. - * - * @param ?string $colorValue - * @param ?int $colorAlpha - * @param ?string $colorType */ public function setGlowProperties(float $size, ?string $colorValue = null, ?int $colorAlpha = null, ?string $colorType = null): void { @@ -486,8 +479,6 @@ public function getGlowSize(): ?float /** * Set Glow Size. * - * @param ?float $size - * * @return $this */ protected function setGlowSize(?float $size) @@ -499,8 +490,6 @@ protected function setGlowSize(?float $size) /** * Set Soft Edges Size. - * - * @param ?float $size */ public function setSoftEdges(?float $size): void { @@ -532,10 +521,8 @@ public function setShadowProperty(string $propertyName, mixed $value): self /** * Set Shadow Properties. - * - * @param null|float|int|string $colorAlpha */ - public function setShadowProperties(int $presets, ?string $colorValue = null, ?string $colorType = null, $colorAlpha = null, ?float $blur = null, ?int $angle = null, ?float $distance = null): void + public function setShadowProperties(int $presets, ?string $colorValue = null, ?string $colorType = null, null|float|int|string $colorAlpha = null, ?float $blur = null, ?int $angle = null, ?float $distance = null): void { $this->activateObject()->setShadowPresetsProperties((int) $presets); if ($presets === 0) { @@ -602,8 +589,6 @@ protected function setShadowPropertiesMapValues(array $propertiesMap, ?array &$r /** * Set Shadow Blur. * - * @param ?float $blur - * * @return $this */ protected function setShadowBlur(?float $blur) @@ -618,11 +603,9 @@ protected function setShadowBlur(?float $blur) /** * Set Shadow Angle. * - * @param null|float|int|string $angle - * * @return $this */ - protected function setShadowAngle($angle) + protected function setShadowAngle(null|float|int|string $angle) { if (is_numeric($angle)) { $this->shadowProperties['direction'] = $angle; @@ -634,8 +617,6 @@ protected function setShadowAngle($angle) /** * Set Shadow Distance. * - * @param ?float $distance - * * @return $this */ protected function setShadowDistance(?float $distance) @@ -721,8 +702,6 @@ public function getLineColor(): ChartColor /** * Set Line Color Properties. - * - * @param ?int $alpha */ public function setLineColorProperties(?string $value, ?int $alpha = null, ?string $colorType = null): void { @@ -843,10 +822,8 @@ public function setLineStyleProperty(string $propertyName, mixed $value): self /** * Get Line Style Property. - * - * @param array|string $elements */ - public function getLineStyleProperty($elements): ?string + public function getLineStyleProperty(array|string $elements): ?string { return $this->getArrayElementsValue($this->lineStyleProperties, $elements); } diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index dd2742164b..9b657ecb1c 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -25,10 +25,8 @@ class Title /** * Create a new Title. - * - * @param array|RichText|string $caption */ - public function __construct($caption = '', ?Layout $layout = null, bool $overlay = false) + public function __construct(array|RichText|string $caption = '', ?Layout $layout = null, bool $overlay = false) { $this->caption = $caption; $this->layout = $layout; @@ -71,11 +69,9 @@ public function getCaptionText(): string /** * Set caption. * - * @param array|RichText|string $caption - * * @return $this */ - public function setCaption($caption): static + public function setCaption(array|RichText|string $caption): static { $this->caption = $caption; diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index 1212a258bb..1459458f87 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -140,10 +140,7 @@ public function setLastModifiedBy(string $modifiedBy): self return $this; } - /** - * @param null|float|int|string $timestamp - */ - private static function intOrFloatTimestamp($timestamp): float|int + private static function intOrFloatTimestamp(null|float|int|string $timestamp): float|int { if ($timestamp === null) { $timestamp = (float) (new DateTime())->format('U'); @@ -172,11 +169,9 @@ public function getCreated(): float|int /** * Set Created. * - * @param null|float|int|string $timestamp - * * @return $this */ - public function setCreated($timestamp): self + public function setCreated(null|float|int|string $timestamp): self { $this->created = self::intOrFloatTimestamp($timestamp); @@ -194,11 +189,9 @@ public function getModified(): float|int /** * Set Modified. * - * @param null|float|int|string $timestamp - * * @return $this */ - public function setModified($timestamp): self + public function setModified(null|float|int|string $timestamp): self { $this->modified = self::intOrFloatTimestamp($timestamp); diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 2acb3fcf8e..5841a48039 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -238,10 +238,8 @@ protected function releaseTableStartColumn(): string /** * Flush cell. - * - * @param int|string $row */ - protected function flushCell(Worksheet $sheet, string $column, $row, mixed &$cellContent, array $attributeArray): void + protected function flushCell(Worksheet $sheet, string $column, int|string $row, mixed &$cellContent, array $attributeArray): void { if (is_string($cellContent)) { // Simple String content diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index c91ed8c3f8..f90d2decbc 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -7529,11 +7529,7 @@ private function readCFFormula(string $recordData, int $offset, int $size): floa return null; } - /** - * @param null|float|int|string $formula1 - * @param null|float|int|string $formula2 - */ - private function setCFRules(array $cellRanges, string $type, string $operator, $formula1, $formula2, Style $style): void + private function setCFRules(array $cellRanges, string $type, string $operator, null|float|int|string $formula1, null|float|int|string $formula2, Style $style): void { foreach ($cellRanges as $cellRange) { $conditional = new Conditional(); diff --git a/src/PhpSpreadsheet/Reader/Xlsx.php b/src/PhpSpreadsheet/Reader/Xlsx.php index 495e42a963..6d3b961c98 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx.php +++ b/src/PhpSpreadsheet/Reader/Xlsx.php @@ -1950,20 +1950,12 @@ private function readRibbon(Spreadsheet $excel, string $customUITarget, ZipArchi } } - /** - * @param null|array|bool|SimpleXMLElement $array - * @param int|string $key - */ - private static function getArrayItem($array, $key = 0): mixed + private static function getArrayItem(null|array|bool|SimpleXMLElement $array, int|string $key = 0): mixed { return ($array === null || is_bool($array)) ? null : ($array[$key] ?? null); } - /** - * @param null|SimpleXMLElement|string $base - * @param null|SimpleXMLElement|string $add - */ - private static function dirAdd($base, $add): string + private static function dirAdd(null|SimpleXMLElement|string $base, null|SimpleXMLElement|string $add): string { $base = (string) $base; $add = (string) $add; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php b/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php index 68086cc145..49fe3609d8 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/AutoFilter.php @@ -11,17 +11,11 @@ class AutoFilter { - /** - * @var Table|Worksheet - */ - private $parent; + private Table|Worksheet $parent; private SimpleXMLElement $worksheetXml; - /** - * @param Table|Worksheet $parent - */ - public function __construct($parent, SimpleXMLElement $worksheetXml) + public function __construct(Table|Worksheet $parent, SimpleXMLElement $worksheetXml) { $this->parent = $parent; $this->worksheetXml = $worksheetXml; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 71777f230f..36ee58ea7e 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -1202,9 +1202,6 @@ private function parseFont(SimpleXMLElement $titleDetailPart): ?Font return $font; } - /** - * @param ?SimpleXMLElement $chartDetail - */ private function readChartAttributes(?SimpleXMLElement $chartDetail): array { $plotAttributes = []; diff --git a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php index d8a3dfb1f4..8f9d42a1bf 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/ConditionalStyles.php @@ -250,10 +250,7 @@ private function readStyleRules(array $cfRules, SimpleXMLElement $extLst): array return $conditionalStyles; } - /** - * @param SimpleXMLElement|stdClass $cfRule - */ - private function readDataBarOfConditionalRule($cfRule, array $conditionalFormattingRuleExtensions): ConditionalDataBar + private function readDataBarOfConditionalRule(SimpleXMLElement $cfRule, array $conditionalFormattingRuleExtensions): ConditionalDataBar { $dataBar = new ConditionalDataBar(); //dataBar attribute @@ -319,10 +316,7 @@ private function readColorScale(simpleXMLElement|stdClass $cfRule): ConditionalC return $colorScale; } - /** - * @param SimpleXMLElement|stdClass $cfRule - */ - private function readDataBarExtLstOfConditionalRule(ConditionalDataBar $dataBar, $cfRule, array $conditionalFormattingRuleExtensions): void + private function readDataBarExtLstOfConditionalRule(ConditionalDataBar $dataBar, SimpleXMLElement $cfRule, array $conditionalFormattingRuleExtensions): void { if (isset($cfRule->extLst)) { $ns = $cfRule->extLst->getNamespaces(true); diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php index d59fa28803..beac9f9a8c 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Properties.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Properties.php @@ -96,10 +96,7 @@ public function readCustomProperties(string $propertyData): void } } - /** - * @param null|array|false $array - */ - private static function getArrayItem($array, mixed $key = 0): ?SimpleXMLElement + private static function getArrayItem(null|array|false $array, mixed $key = 0): ?SimpleXMLElement { return is_array($array) ? ($array[$key] ?? null) : null; } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php index ee51190d41..31a39af5a9 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Styles.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Styles.php @@ -275,10 +275,8 @@ private static function formatGeneral(string $formatString): string /** * Read style. - * - * @param SimpleXMLElement|stdClass $style */ - public function readStyle(Style $docStyle, $style): void + public function readStyle(Style $docStyle, SimpleXMLElement|stdClass $style): void { if ($style instanceof SimpleXMLElement) { $this->readNumberFormat($docStyle->getNumberFormat(), $style->numFmt); diff --git a/src/PhpSpreadsheet/Shared/Date.php b/src/PhpSpreadsheet/Shared/Date.php index eabe6ae817..39d9a3b21c 100644 --- a/src/PhpSpreadsheet/Shared/Date.php +++ b/src/PhpSpreadsheet/Shared/Date.php @@ -318,11 +318,9 @@ public static function timestampToExcel($unixTimestamp): bool|float /** * formattedPHPToExcel. * - * @param float|int $seconds - * * @return float Excel date/time value */ - public static function formattedPHPToExcel(int $year, int $month, int $day, int $hours = 0, int $minutes = 0, $seconds = 0): float + public static function formattedPHPToExcel(int $year, int $month, int $day, int $hours = 0, int $minutes = 0, float|int $seconds = 0): float { if (self::$excelCalendar == self::CALENDAR_WINDOWS_1900) { // diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index 4b9c470dbe..1e200c79c9 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -328,10 +328,8 @@ public static function getTrueTypeFontPath(): string /** * Set pad amount for exact in pixels; use best guess if null. - * - * @param null|float|int $paddingAmountExact */ - public static function setPaddingAmountExact($paddingAmountExact): void + public static function setPaddingAmountExact(null|float|int $paddingAmountExact): void { self::$paddingAmountExact = $paddingAmountExact; } diff --git a/src/PhpSpreadsheet/Shared/OLERead.php b/src/PhpSpreadsheet/Shared/OLERead.php index 6911e732c2..645dbf779e 100644 --- a/src/PhpSpreadsheet/Shared/OLERead.php +++ b/src/PhpSpreadsheet/Shared/OLERead.php @@ -154,8 +154,6 @@ public function read(string $filename): void /** * Extract binary stream data. - * - * @param ?int $stream */ public function getStream(?int $stream): ?string { diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index f1c8ea3d3e..c214b8142c 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -334,10 +334,8 @@ public static function isUTF8(string $textValue): bool /** * Formats a numeric value as a string for output in various output writers forcing * point as decimal separator in case locale is other than English. - * - * @param float|int|string $numericValue */ - public static function formatNumber($numericValue): string + public static function formatNumber(float|int|string|null $numericValue): string { if (is_float($numericValue)) { return str_replace(',', '.', (string) $numericValue); diff --git a/src/PhpSpreadsheet/Shared/Trend/BestFit.php b/src/PhpSpreadsheet/Shared/Trend/BestFit.php index 9fcbccde8f..f9dacfb8a7 100644 --- a/src/PhpSpreadsheet/Shared/Trend/BestFit.php +++ b/src/PhpSpreadsheet/Shared/Trend/BestFit.php @@ -296,10 +296,7 @@ public function getYBestFitValues(): array return $this->yBestFitValues; } - /** - * @param bool|int $const - */ - protected function calculateGoodnessOfFit(float $sumX, float $sumY, float $sumX2, float $sumY2, float $sumXY, float $meanX, float $meanY, $const): void + protected function calculateGoodnessOfFit(float $sumX, float $sumY, float $sumX2, float $sumY2, float $sumXY, float $meanX, float $meanY, bool|int $const): void { $SSres = $SScov = $SStot = $SSsex = 0.0; foreach ($this->xValues as $xKey => $xValue) { diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index eb3c6bf7b3..40ad09d9ec 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -250,11 +250,8 @@ public function discardMacros(): void /** * set ribbon XML data. - * - * @param null|mixed $target - * @param null|mixed $xmlData */ - public function setRibbonXMLData($target, $xmlData): void + public function setRibbonXMLData(mixed $target, mixed $xmlData): void { if ($target !== null && $xmlData !== null) { $this->ribbonXMLData = ['target' => $target, 'data' => $xmlData]; @@ -289,11 +286,8 @@ public function getRibbonXMLData(string $what = 'all'): null|array|string //we n /** * store binaries ribbon objects (pictures). - * - * @param null|mixed $BinObjectsNames - * @param null|mixed $BinObjectsData */ - public function setRibbonBinObjects($BinObjectsNames, $BinObjectsData): void + public function setRibbonBinObjects(mixed $BinObjectsNames, mixed $BinObjectsData): void { if ($BinObjectsNames !== null && $BinObjectsData !== null) { $this->ribbonBinObjects = ['names' => $BinObjectsNames, 'data' => $BinObjectsData]; diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index e8f4ac2ec8..78c69f0934 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -141,13 +141,12 @@ public function getBorderStyle(): string /** * Set Border style. * - * @param bool|string $style - * When passing a boolean, FALSE equates Border::BORDER_NONE + * @param bool|string $style When passing a boolean, FALSE equates Border::BORDER_NONE * and TRUE to Border::BORDER_MEDIUM * * @return $this */ - public function setBorderStyle($style): static + public function setBorderStyle(bool|string $style): static { if (empty($style)) { $style = self::BORDER_NONE; diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php index 8a4257e990..28cd94bbdb 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php @@ -222,11 +222,7 @@ public function getAxisColor(): array return $this->axisColor; } - /** - * @param null|mixed $theme - * @param null|mixed $tint - */ - public function setAxisColor(mixed $rgb, $theme = null, $tint = null): self + public function setAxisColor(mixed $rgb, mixed $theme = null, mixed $tint = null): self { $this->axisColor = [ 'rgb' => $rgb, diff --git a/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php b/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php index f927964d37..269ec3eb4c 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php @@ -253,10 +253,7 @@ public static function format(mixed $value, string $format): string return (string) $value; } - /** - * @param array|string $value - */ - private static function makeString($value): string + private static function makeString(array|string $value): string { return is_array($value) ? '' : "$value"; } diff --git a/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php b/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php index 292c1efc9d..2cd3d6d36b 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php @@ -28,10 +28,7 @@ public function __construct($separators, ...$formatBlocks) $this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks); } - /** - * @param DateTimeWizard|string $value - */ - private function mapFormatBlocks($value): string + private function mapFormatBlocks(DateTimeWizard|string $value): string { // Any date masking codes are returned as lower case values if (is_object($value)) { diff --git a/src/PhpSpreadsheet/Style/Supervisor.php b/src/PhpSpreadsheet/Style/Supervisor.php index 4b796f46f5..8388ef6cd7 100644 --- a/src/PhpSpreadsheet/Style/Supervisor.php +++ b/src/PhpSpreadsheet/Style/Supervisor.php @@ -41,11 +41,9 @@ public function __construct(bool $isSupervisor = false) /** * Bind parent. Only used for supervisor. * - * @param Spreadsheet|Supervisor $parent - * * @return $this */ - public function bindParent($parent, ?string $parentPropertyName = null) + public function bindParent(Spreadsheet|self $parent, ?string $parentPropertyName = null) { $this->parent = $parent; $this->parentPropertyName = $parentPropertyName; diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index 3e53f51ba1..1201390f85 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -233,12 +233,12 @@ public function getColumnByOffset(int $columnOffset): AutoFilter\Column * * @return $this */ - public function setColumn($columnObjectOrString): static + public function setColumn(AutoFilter\Column|string $columnObjectOrString): static { $this->evaluated = false; if ((is_string($columnObjectOrString)) && (!empty($columnObjectOrString))) { $column = $columnObjectOrString; - } elseif (is_object($columnObjectOrString) && ($columnObjectOrString instanceof AutoFilter\Column)) { + } elseif ($columnObjectOrString instanceof AutoFilter\Column) { $column = $columnObjectOrString->getColumnIndex(); } else { throw new Exception('Column is not within the autofilter range.'); @@ -748,8 +748,6 @@ private function dynamicFilterDateRange(string $dynamicRuleType, AutoFilter\Colu /** * Apply the AutoFilter rules to the AutoFilter Range. - * - * @param ?string $ruleType */ private function calculateTopTenValue(string $columnID, int $startRow, int $endRow, ?string $ruleType, mixed $ruleValue): mixed { diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index 7b3fe83afe..fb383f1417 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -793,8 +793,6 @@ public function getFirstPageNumber(): ?int /** * Set first page number. * - * @param ?int $value - * * @return $this */ public function setFirstPageNumber(?int $value): static diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index b6054fa279..9e64a24bb3 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -69,8 +69,6 @@ public function getZoomScale(): ?int * Set ZoomScale. * Valid values range from 10 to 400. * - * @param ?int $zoomScale - * * @return $this */ public function setZoomScale(?int $zoomScale): static @@ -98,8 +96,6 @@ public function getZoomScaleNormal(): ?int * Set ZoomScale. * Valid values range from 10 to 400. * - * @param ?int $zoomScaleNormal - * * @return $this */ public function setZoomScaleNormal(?int $zoomScaleNormal): static @@ -142,8 +138,6 @@ public function getView(): string * 'pageLayout' self::SHEETVIEW_PAGE_LAYOUT * 'pageBreakPreview' self::SHEETVIEW_PAGE_BREAK_PREVIEW * - * @param ?string $sheetViewType - * * @return $this */ public function setView(?string $sheetViewType): static diff --git a/src/PhpSpreadsheet/Worksheet/Table.php b/src/PhpSpreadsheet/Worksheet/Table.php index 2ffac1bc78..76cfbd1fb1 100644 --- a/src/PhpSpreadsheet/Worksheet/Table.php +++ b/src/PhpSpreadsheet/Worksheet/Table.php @@ -437,7 +437,7 @@ public function getColumnByOffset(int $columnOffset): Table\Column * @param string|Table\Column $columnObjectOrString * A simple string containing a Column ID like 'A' is permitted */ - public function setColumn($columnObjectOrString): self + public function setColumn(string|Table\Column $columnObjectOrString): self { if ((is_string($columnObjectOrString)) && (!empty($columnObjectOrString))) { $column = $columnObjectOrString; diff --git a/src/PhpSpreadsheet/Writer/Html.php b/src/PhpSpreadsheet/Writer/Html.php index 046ab94e67..4b24f63abb 100644 --- a/src/PhpSpreadsheet/Writer/Html.php +++ b/src/PhpSpreadsheet/Writer/Html.php @@ -686,7 +686,7 @@ private function writeImageInCell(Worksheet $worksheet, string $coordinates): st // width: X sets width of supplied image. // As a result, images bigger than cell will be contained and images smaller will not get stretched $html .= '' . $filedesc . ''; + . $drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px;position: absolute; z-index: 1;" />'; } } } @@ -1322,11 +1322,7 @@ private function generateRowCellDataValue(Worksheet $worksheet, Cell $cell, stri } } - /** - * @param null|Cell|string $cell - * @param array|string $cssClass - */ - private function generateRowCellData(Worksheet $worksheet, $cell, &$cssClass): string + private function generateRowCellData(Worksheet $worksheet, null|Cell|string $cell, array|string &$cssClass): string { $cellData = ' '; if ($cell instanceof Cell) { @@ -1388,11 +1384,19 @@ private function generateRowSpans(string $html, int $rowSpan, int $colSpan): str return $html; } - /** - * @param array|string $cssClass - */ - private function generateRowWriteCell(string &$html, Worksheet $worksheet, string $coordinate, string $cellType, string $cellData, int $colSpan, int $rowSpan, $cssClass, int $colNum, int $sheetIndex, int $row): void - { + private function generateRowWriteCell( + string &$html, + Worksheet $worksheet, + string $coordinate, + string $cellType, + string $cellData, + int $colSpan, + int $rowSpan, + array|string $cssClass, + int $colNum, + int $sheetIndex, + int $row + ): void { // Image? $htmlx = $this->writeImageInCell($worksheet, $coordinate); // Chart? diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 49835e9fd3..8b1cdb1af8 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -758,10 +758,7 @@ private function writeDocumentSummaryInformation(): string return $data; } - /** - * @param float|int $dataProp - */ - private function writeSummaryPropOle($dataProp, int &$dataSection_NumProps, array &$dataSection, int $sumdata, int $typdata): void + private function writeSummaryPropOle(float|int $dataProp, int &$dataSection_NumProps, array &$dataSection, int $sumdata, int $typdata): void { if ($dataProp) { $dataSection[] = [ diff --git a/src/PhpSpreadsheet/Writer/Xls/Xf.php b/src/PhpSpreadsheet/Writer/Xls/Xf.php index c3ea4dceec..2ab5a4ebca 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Xf.php +++ b/src/PhpSpreadsheet/Writer/Xls/Xf.php @@ -352,8 +352,6 @@ private static function mapTextRotation(int $textRotation): int /** * Map locked values. - * - * @param ?string $locked */ private static function mapLocked(?string $locked): int { @@ -368,8 +366,6 @@ private static function mapLocked(?string $locked): int /** * Map hidden. - * - * @param ?string $hidden */ private static function mapHidden(?string $hidden): int { diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php index 20c5e18561..17f794779b 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php @@ -1272,10 +1272,7 @@ private function writeSheetData(XMLWriter $objWriter, PhpspreadsheetWorksheet $w $objWriter->endElement(); } - /** - * @param RichText|string $cellValue - */ - private function writeCellInlineStr(XMLWriter $objWriter, string $mappedType, $cellValue): void + private function writeCellInlineStr(XMLWriter $objWriter, string $mappedType, RichText|string $cellValue): void { $objWriter->writeAttribute('t', $mappedType); if (!$cellValue instanceof RichText) { @@ -1293,10 +1290,9 @@ private function writeCellInlineStr(XMLWriter $objWriter, string $mappedType, $c } /** - * @param RichText|string $cellValue * @param string[] $flippedStringTable */ - private function writeCellString(XMLWriter $objWriter, string $mappedType, $cellValue, array $flippedStringTable): void + private function writeCellString(XMLWriter $objWriter, string $mappedType, RichText|string $cellValue, array $flippedStringTable): void { $objWriter->writeAttribute('t', $mappedType); if (!$cellValue instanceof RichText) { @@ -1306,10 +1302,7 @@ private function writeCellString(XMLWriter $objWriter, string $mappedType, $cell } } - /** - * @param float|int $cellValue - */ - private function writeCellNumeric(XMLWriter $objWriter, $cellValue): void + private function writeCellNumeric(XMLWriter $objWriter, float|int $cellValue): void { //force a decimal to be written if the type is float if (is_float($cellValue)) { diff --git a/tests/PhpSpreadsheetTests/Shared/Date2Test.php b/tests/PhpSpreadsheetTests/Shared/Date2Test.php index 687a34e230..d1cbb2346f 100644 --- a/tests/PhpSpreadsheetTests/Shared/Date2Test.php +++ b/tests/PhpSpreadsheetTests/Shared/Date2Test.php @@ -40,8 +40,6 @@ public function testInvalidType(): void /** * @dataProvider providerTimeOnly - * - * @param float|int $value */ public function testTimeOnly(int|float $expectedResult, int|float|string $value, ?string $format = null): void { diff --git a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/AutoFilterTest.php b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/AutoFilterTest.php index 7b1583d545..fc66817609 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/AutoFilterTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/AutoFilter/AutoFilterTest.php @@ -282,18 +282,6 @@ public function testSetInvalidColumnWithObject(): void $autoFilter->setColumn($invalidColumn); } - public function testSetColumnWithInvalidDataType(): void - { - $this->expectException(PhpSpreadsheetException::class); - - $sheet = $this->getSheet(); - $autoFilter = $sheet->getAutoFilter(); - $autoFilter->setRange(self::INITIAL_RANGE); - $invalidColumn = 123.456; - // @phpstan-ignore-next-line - $autoFilter->setColumn($invalidColumn); - } - public function testGetColumns(): void { $sheet = $this->getSheet(); diff --git a/tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php b/tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php index 0af783135d..20a4388e4f 100644 --- a/tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php +++ b/tests/PhpSpreadsheetTests/Worksheet/Table/TableTest.php @@ -372,16 +372,6 @@ public function testSetInvalidColumnWithObject(): void $table->setColumn($invalidColumn); } - public function testSetColumnWithInvalidDataType(): void - { - $this->expectException(PhpSpreadsheetException::class); - - $table = new Table(self::INITIAL_RANGE); - $invalidColumn = 123.456; - // @phpstan-ignore-next-line - $table->setColumn($invalidColumn); - } - public function testGetColumns(): void { $table = new Table(self::INITIAL_RANGE); From 161d82d2bc21e47dcb0396268c0f5c0bb27e1a66 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Mon, 11 Dec 2023 09:19:10 +0100 Subject: [PATCH 13/25] A few more native return types --- src/PhpSpreadsheet/Chart/DataSeries.php | 6 +++--- src/PhpSpreadsheet/Chart/Title.php | 4 +--- src/PhpSpreadsheet/Reader/Xls/Escher.php | 4 +--- src/PhpSpreadsheet/Spreadsheet.php | 4 ++-- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index a03180fdae..2d64bfbfb4 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -233,7 +233,7 @@ public function getPlotLabels(): array * * @return DataSeriesValues|false */ - public function getPlotLabelByIndex(mixed $index) + public function getPlotLabelByIndex(mixed $index): bool|DataSeriesValues { $keys = array_keys($this->plotLabel); if (in_array($index, $keys)) { @@ -258,7 +258,7 @@ public function getPlotCategories(): array * * @return DataSeriesValues|false */ - public function getPlotCategoryByIndex(mixed $index) + public function getPlotCategoryByIndex(mixed $index): bool|DataSeriesValues { $keys = array_keys($this->plotCategory); if (in_array($index, $keys)) { @@ -305,7 +305,7 @@ public function getPlotValues(): array * * @return DataSeriesValues|false */ - public function getPlotValuesByIndex(mixed $index) + public function getPlotValuesByIndex(mixed $index): bool|DataSeriesValues { $keys = array_keys($this->plotValues); if (in_array($index, $keys)) { diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index 9b657ecb1c..d225b167ee 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -35,10 +35,8 @@ public function __construct(array|RichText|string $caption = '', ?Layout $layout /** * Get caption. - * - * @return array|RichText|string */ - public function getCaption() + public function getCaption(): array|RichText|string { return $this->caption; } diff --git a/src/PhpSpreadsheet/Reader/Xls/Escher.php b/src/PhpSpreadsheet/Reader/Xls/Escher.php index edb5cabf95..b4e658eeb4 100644 --- a/src/PhpSpreadsheet/Reader/Xls/Escher.php +++ b/src/PhpSpreadsheet/Reader/Xls/Escher.php @@ -86,10 +86,8 @@ public function __construct(mixed $object) /** * Load Escher stream data. May be a partial Escher stream. - * - * @return BSE|BstoreContainer|DgContainer|DggContainer|\PhpOffice\PhpSpreadsheet\Shared\Escher|SpContainer|SpgrContainer */ - public function load(string $data) + public function load(string $data): BSE|BstoreContainer|DgContainer|DggContainer|\PhpOffice\PhpSpreadsheet\Shared\Escher|SpContainer|SpgrContainer { $this->data = $data; diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index 40ad09d9ec..b6831fd3ae 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -1082,7 +1082,7 @@ public function getCellXfByIndex(int $cellStyleIndex): Style * * @return false|Style */ - public function getCellXfByHashCode(string $hashcode) + public function getCellXfByHashCode(string $hashcode): bool|Style { foreach ($this->cellXfCollection as $cellXf) { if ($cellXf->getHashCode() === $hashcode) { @@ -1185,7 +1185,7 @@ public function getCellStyleXfByIndex(int $cellStyleIndex): Style * * @return false|Style */ - public function getCellStyleXfByHashCode(string $hashcode) + public function getCellStyleXfByHashCode(string $hashcode): bool|Style { foreach ($this->cellStyleXfCollection as $cellStyleXf) { if ($cellStyleXf->getHashCode() === $hashcode) { From f1772bf3964099054ef539213af0f15b497954aa Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Tue, 12 Dec 2023 09:13:56 +0100 Subject: [PATCH 14/25] A few more native param types --- src/PhpSpreadsheet/Calculation/Database/DAverage.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DCount.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DCountA.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DGet.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DMax.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DMin.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DProduct.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DStDev.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DStDevP.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DSum.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DVar.php | 2 +- src/PhpSpreadsheet/Calculation/Database/DVarP.php | 2 +- .../Calculation/Database/DatabaseAbstract.php | 2 +- src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php | 8 ++++---- .../Calculation/DateTimeExcel/DateValue.php | 6 +++--- src/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php | 2 +- .../Calculation/DateTimeExcel/Days360.php | 2 +- .../Calculation/DateTimeExcel/Difference.php | 2 +- .../Calculation/DateTimeExcel/Helpers.php | 2 +- src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php | 4 ++-- src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php | 8 ++++---- .../Calculation/DateTimeExcel/TimeValue.php | 2 +- src/PhpSpreadsheet/Calculation/DateTimeExcel/Week.php | 4 ++-- .../Calculation/DateTimeExcel/WorkDay.php | 2 +- .../Calculation/DateTimeExcel/YearFrac.php | 2 +- .../Calculation/Engine/ArrayArgumentHelper.php | 2 +- src/PhpSpreadsheet/Calculation/Engineering/Compare.php | 4 ++-- .../Calculation/Functions/DateTime/DateDifTest.php | 10 ---------- .../Calculation/Functions/DateTime/Days360Test.php | 10 ---------- .../Calculation/Functions/DateTime/DaysTest.php | 10 ---------- .../Calculation/Functions/MathTrig/RandArrayTest.php | 4 ++-- .../Calculation/Functions/MathTrig/SequenceTest.php | 2 +- .../Functional/ReadBlankCellsTest.php | 3 ++- .../PhpSpreadsheetTests/Functional/ReadFilterTest.php | 3 ++- .../Reader/Csv/CsvContiguousFilter.php | 2 +- .../Reader/Gnumeric/GnumericFilter.php | 2 +- .../Reader/Ods/RepeatedColumnsTest.php | 2 +- .../Reader/Xlsx/OddColumnReadFilter.php | 2 +- tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php | 2 +- 39 files changed, 50 insertions(+), 78 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Database/DAverage.php b/src/PhpSpreadsheet/Calculation/Database/DAverage.php index 1f09eb1f3f..fc4a0e3ca0 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DAverage.php +++ b/src/PhpSpreadsheet/Calculation/Database/DAverage.php @@ -30,7 +30,7 @@ class DAverage extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria): string|int|float + public static function evaluate(array $database, array|null|int|string $field, array $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 27cf02ea67..878f4cf2bd 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DCount.php +++ b/src/PhpSpreadsheet/Calculation/Database/DCount.php @@ -31,7 +31,7 @@ class DCount extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria, bool $returnError = true): string|int + public static function evaluate(array $database, array|null|int|string $field, array $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 5350c6583c..a8a640c88d 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DCountA.php +++ b/src/PhpSpreadsheet/Calculation/Database/DCountA.php @@ -30,7 +30,7 @@ class DCountA extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria): string|int + public static function evaluate(array $database, array|null|int|string $field, array $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 e79ee8de19..05ea6320b0 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DGet.php +++ b/src/PhpSpreadsheet/Calculation/Database/DGet.php @@ -30,7 +30,7 @@ class DGet extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria): null|float|int|string + public static function evaluate(array $database, array|null|int|string $field, array $criteria): null|float|int|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DMax.php b/src/PhpSpreadsheet/Calculation/Database/DMax.php index c111600c96..1f070da2f7 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DMax.php +++ b/src/PhpSpreadsheet/Calculation/Database/DMax.php @@ -31,7 +31,7 @@ class DMax extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria, bool $returnError = true): null|float|string + public static function evaluate(array $database, array|null|int|string $field, array $criteria, bool $returnError = true): null|float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DMin.php b/src/PhpSpreadsheet/Calculation/Database/DMin.php index a901601156..d72fa927c1 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DMin.php +++ b/src/PhpSpreadsheet/Calculation/Database/DMin.php @@ -31,7 +31,7 @@ class DMin extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria, bool $returnError = true): float|string|null + public static function evaluate(array $database, array|null|int|string $field, array $criteria, bool $returnError = true): float|string|null { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DProduct.php b/src/PhpSpreadsheet/Calculation/Database/DProduct.php index 67090aa05a..77574a69d3 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DProduct.php +++ b/src/PhpSpreadsheet/Calculation/Database/DProduct.php @@ -30,7 +30,7 @@ class DProduct extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria): string|float + public static function evaluate(array $database, array|null|int|string $field, array $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 93e9c0e052..b53bcb3a12 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DStDev.php +++ b/src/PhpSpreadsheet/Calculation/Database/DStDev.php @@ -31,7 +31,7 @@ class DStDev extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria): float|string + public static function evaluate(array $database, array|null|int|string $field, array $criteria): float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DStDevP.php b/src/PhpSpreadsheet/Calculation/Database/DStDevP.php index 13b80014e4..bc176dfd42 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DStDevP.php +++ b/src/PhpSpreadsheet/Calculation/Database/DStDevP.php @@ -31,7 +31,7 @@ class DStDevP extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria): float|string + public static function evaluate(array $database, array|null|int|string $field, array $criteria): float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DSum.php b/src/PhpSpreadsheet/Calculation/Database/DSum.php index 625599fce8..6cc1296177 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DSum.php +++ b/src/PhpSpreadsheet/Calculation/Database/DSum.php @@ -30,7 +30,7 @@ class DSum extends DatabaseAbstract * the column label in which you specify a condition for the * column. */ - public static function evaluate(array $database, $field, array $criteria, bool $returnNull = false): null|float|string + public static function evaluate(array $database, array|null|int|string $field, array $criteria, bool $returnNull = false): null|float|string { $field = self::fieldExtract($database, $field); if ($field === null) { diff --git a/src/PhpSpreadsheet/Calculation/Database/DVar.php b/src/PhpSpreadsheet/Calculation/Database/DVar.php index 8dd4d38867..5805806cfe 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DVar.php +++ b/src/PhpSpreadsheet/Calculation/Database/DVar.php @@ -33,7 +33,7 @@ class DVar extends DatabaseAbstract * * @return float|string (string if result is an error) */ - public static function evaluate(array $database, $field, array $criteria): string|float + public static function evaluate(array $database, array|null|int|string $field, array $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 93b3eda146..0ad61a9f26 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DVarP.php +++ b/src/PhpSpreadsheet/Calculation/Database/DVarP.php @@ -33,7 +33,7 @@ class DVarP extends DatabaseAbstract * * @return float|string (string if result is an error) */ - public static function evaluate(array $database, $field, array $criteria): string|float + public static function evaluate(array $database, array|null|int|string $field, array $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 6905323c92..3f40d475a9 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php +++ b/src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php @@ -8,7 +8,7 @@ abstract class DatabaseAbstract { - abstract public static function evaluate(array $database, null|int|string $field, array $criteria): null|float|int|string; + abstract public static function evaluate(array $database, array|null|int|string $field, array $criteria): null|float|int|string; /** * fieldExtract. diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php index b3d7f47383..9dd7f7a29b 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php @@ -27,7 +27,7 @@ class Date * A Month name or abbreviation (English only at this point) such as 'January' or 'Jan' will still be accepted, * as will a day value with a suffix (e.g. '21st' rather than simply 21); again only English language. * - * @param array|int $year The value of the year argument can include one to four digits. + * @param array|int|string $year The value of the year argument can include one to four digits. * Excel interprets the year argument according to the configured * date system: 1900 or 1904. * If year is between 0 (zero) and 1899 (inclusive), Excel adds that @@ -38,7 +38,7 @@ class Date * 2008. * If year is less than 0 or is 10000 or greater, Excel returns the * #NUM! error value. - * @param array|int $month A positive or negative integer representing the month of the year + * @param array|float|int|string $month A positive or negative integer representing the month of the year * from 1 to 12 (January to December). * If month is greater than 12, month adds that number of months to * the first month in the year specified. For example, DATE(2008,14,2) @@ -47,7 +47,7 @@ class Date * number of months, plus 1, from the first month in the year * specified. For example, DATE(2008,-3,2) returns the serial number * representing September 2, 2007. - * @param array|int $day A positive or negative integer representing the day of the month + * @param array|float|int|string $day A positive or negative integer representing the day of the month * from 1 to 31. * If day is greater than the number of days in the month specified, * day adds that number of days to the first day in the month. For @@ -63,7 +63,7 @@ class Date * If an array of numbers is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function fromYMD($year, $month, $day): mixed + public static function fromYMD(array|int|string $year, array|float|int|string $month, array|float|int|string $day): mixed { if (is_array($year) || is_array($month) || is_array($day)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $year, $month, $day); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php index 1093d732be..4daa74ab6b 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php @@ -24,7 +24,7 @@ class DateValue * Excel Function: * DATEVALUE(dateValue) * - * @param null|array|string $dateValue Text that represents a date in a Microsoft Excel date format. + * @param null|array|int|string $dateValue Text that represents a date in a Microsoft Excel date format. * For example, "1/30/2008" or "30-Jan-2008" are text strings within * quotation marks that represent dates. Using the default date * system in Excel for Windows, date_text must represent a date from @@ -39,7 +39,7 @@ class DateValue * If an array of numbers is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function fromString($dateValue): mixed + public static function fromString(null|array|string|int|bool $dateValue): mixed { if (is_array($dateValue)) { return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $dateValue); @@ -52,7 +52,7 @@ public static function fromString($dateValue): mixed $dti = new DateTimeImmutable(); $baseYear = SharedDateHelper::getExcelCalendar(); - $dateValue = trim($dateValue ?? '', '"'); + $dateValue = trim((string) $dateValue, '"'); // Strip any ordinals because they're allowed in Excel (English only) $dateValue = (string) preg_replace('/(\d)(st|nd|rd|th)([ -\/])/Ui', '$1$3', $dateValue); // Convert separators (/ . or space) to hyphens (should also handle dot used for ordinals in some countries, e.g. Denmark, Germany) diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php index a3b9745106..6c6fd3d7de 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days.php @@ -31,7 +31,7 @@ class Days * 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($endDate, $startDate) + public static function between(array|DateTimeInterface|float|int|string $endDate, array|DateTimeInterface|float|int|string $startDate): array|int|string { if (is_array($endDate) || is_array($startDate)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $endDate, $startDate); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Days360.php index 9ac9ccb664..c7e03fc0e0 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): array|string|int + public static function between(mixed $startDate = 0, mixed $endDate = 0, mixed $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/Difference.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php index daf70ad03f..199d5d85a7 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php @@ -28,7 +28,7 @@ class Difference * 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 interval(mixed $startDate, mixed $endDate, $unit = 'D') + public static function interval(mixed $startDate, mixed $endDate, array|string $unit = 'D') { if (is_array($startDate) || is_array($endDate) || is_array($unit)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $startDate, $endDate, $unit); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php index 3dd2e4bc6c..733cecb614 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php @@ -17,7 +17,7 @@ class Helpers * * @return bool TRUE if the year is a leap year, otherwise FALSE */ - public static function isLeapYear($year): bool + public static function isLeapYear(int|string $year): bool { return (($year % 4) === 0) && (($year % 100) !== 0) || (($year % 400) === 0); } diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php index 33f661ab4f..9308acc588 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php @@ -33,7 +33,7 @@ class Month * 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 adjust(mixed $dateValue, $adjustmentMonths) + public static function adjust(mixed $dateValue, array|string|bool|float|int $adjustmentMonths) { if (is_array($dateValue) || is_array($adjustmentMonths)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $adjustmentMonths); @@ -77,7 +77,7 @@ public static function adjust(mixed $dateValue, $adjustmentMonths) * 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 lastDay(mixed $dateValue, $adjustmentMonths) + public static function lastDay(mixed $dateValue, array|float|int|bool|string $adjustmentMonths): mixed { if (is_array($dateValue) || is_array($adjustmentMonths)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $adjustmentMonths); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php index defcd17357..3f8f324c97 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Time.php @@ -24,14 +24,14 @@ class Time * Excel Function: * TIME(hour,minute,second) * - * @param array|int $hour A number from 0 (zero) to 32767 representing the hour. + * @param null|array|bool|float|int|string $hour A number from 0 (zero) to 32767 representing the hour. * Any value greater than 23 will be divided by 24 and the remainder * will be treated as the hour value. For example, TIME(27,0,0) = * TIME(3,0,0) = .125 or 3:00 AM. - * @param array|int $minute A number from 0 to 32767 representing the minute. + * @param null|array|bool|float|int|string $minute A number from 0 to 32767 representing the minute. * Any value greater than 59 will be converted to hours and minutes. * For example, TIME(0,750,0) = TIME(12,30,0) = .520833 or 12:30 PM. - * @param array|int $second A number from 0 to 32767 representing the second. + * @param null|array|bool|float|int|string $second A number from 0 to 32767 representing the second. * Any value greater than 59 will be converted to hours, minutes, * and seconds. For example, TIME(0,0,2000) = TIME(0,33,22) = .023148 * or 12:33:20 AM @@ -43,7 +43,7 @@ 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 */ - public static function fromHMS($hour, $minute, $second): array|string|float|int|DateTime + public static function fromHMS(array|int|float|bool|null|string $hour, array|int|float|bool|null|string $minute, array|int|float|bool|null|string $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/TimeValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php index b5024d1731..1ebbb21f8e 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php @@ -36,7 +36,7 @@ class 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 fromString($timeValue): array|string|Datetime|int|float + public static function fromString(null|array|string|int|bool $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 6434cd735b..1d02c2073f 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(mixed $dateValue, $method = Constants::STARTWEEK_SUNDAY): array|int|string + public static function number(mixed $dateValue, array|int|string|null $method = Constants::STARTWEEK_SUNDAY): array|int|string { if (is_array($dateValue) || is_array($method)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $method); @@ -150,7 +150,7 @@ public static function isoWeekNumber(mixed $dateValue): array|int|string * 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, mixed $style = 1): array|string|int + public static function day(null|array|float|int|string|bool $dateValue, mixed $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/WorkDay.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php index f384bebe37..011f41773c 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/WorkDay.php @@ -36,7 +36,7 @@ class WorkDay * 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 date($startDate, $endDays, ...$dateArgs) + public static function date(mixed $startDate, array|int|string $endDays, mixed ...$dateArgs): mixed { if (is_array($startDate) || is_array($endDays)) { return self::evaluateArrayArgumentsSubset( diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php index 4ea431ffe5..edee3fa6e1 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(mixed $startDate, mixed $endDate, $method = 0): array|string|int|float + public static function fraction(mixed $startDate, mixed $endDate, array|int|string|null $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 29fc490234..0107f40453 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php +++ b/src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentHelper.php @@ -145,7 +145,7 @@ private function rows(array $arguments): array private function columns(array $arguments): array { return array_map( - function ($argument): int { + function (mixed $argument): int { return is_array($argument) && is_array($argument[array_keys($argument)[0]]) ? count($argument[array_keys($argument)[0]]) : 1; diff --git a/src/PhpSpreadsheet/Calculation/Engineering/Compare.php b/src/PhpSpreadsheet/Calculation/Engineering/Compare.php index 0a8c1f3b44..8b0b86a4e6 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): array|string|int + public static function DELTA(array|float|bool|string $a, array|float|bool|string $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): array|string|int * 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): array|string|int + public static function GESTEP(array|float|bool|string $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/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php index 260a563cf1..79cc6f0a74 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DateDifTest.php @@ -6,12 +6,10 @@ use DateTime; use DateTimeImmutable; -use Exception; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Days; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Difference; use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException; -use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheetTests\Calculation\Functions\FormulaArguments; use PHPUnit\Framework\TestCase; @@ -101,14 +99,6 @@ public function testDateObject(): void self::assertSame(31, Days::between($obj1, $obj2)); } - public function testNonDateObject(): void - { - $obj1 = new Exception(); - $obj2 = new DateTimeImmutable('2000-2-29'); - // @phpstan-ignore-next-line - self::assertSame(ExcelError::VALUE(), Days::between($obj1, $obj2)); - } - /** * @dataProvider providerDateDifArray */ diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php index cf78f294c8..9f8c9a6088 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/Days360Test.php @@ -6,12 +6,10 @@ use DateTime; use DateTimeImmutable; -use Exception; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Days; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Days360; use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException; -use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheetTests\Calculation\Functions\FormulaArguments; use PHPUnit\Framework\TestCase; @@ -101,14 +99,6 @@ public function testDateObject(): void self::assertSame(31, Days::between($obj1, $obj2)); } - public function testNonDateObject(): void - { - $obj1 = new Exception(); - $obj2 = new DateTimeImmutable('2000-2-29'); - // @phpstan-ignore-next-line - self::assertSame(ExcelError::VALUE(), Days::between($obj1, $obj2)); - } - /** * @dataProvider providerDays360Array */ diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php index 15e023d325..0911cf4787 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/DateTime/DaysTest.php @@ -6,11 +6,9 @@ use DateTime; use DateTimeImmutable; -use Exception; use PhpOffice\PhpSpreadsheet\Calculation\Calculation; use PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel\Days; use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalculationException; -use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheetTests\Calculation\Functions\FormulaArguments; use PHPUnit\Framework\TestCase; @@ -100,14 +98,6 @@ public function testDateObject(): void self::assertSame(31, Days::between($obj1, $obj2)); } - public function testNonDateObject(): void - { - $obj1 = new Exception(); - $obj2 = new DateTimeImmutable('2000-2-29'); - // @phpstan-ignore-next-line - self::assertSame(ExcelError::VALUE(), Days::between($obj1, $obj2)); - } - /** * @dataProvider providerDaysArray */ diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php index 57d65082c0..c44bef57d3 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/RandArrayTest.php @@ -26,7 +26,7 @@ public function testRANDARRAYInteger(): void $values = Functions::flattenArray($result); array_walk( $values, - function ($value) use ($min, $max): void { + function (mixed $value) use ($min, $max): void { self::assertIsInt($value); self::assertTrue($value >= $min && $value <= $max); } @@ -49,7 +49,7 @@ public function testRANDARRAYFloat(): void $values = Functions::flattenArray($result); array_walk( $values, - function ($value) use ($min, $max): void { + function (mixed $value) use ($min, $max): void { self::assertIsFloat($value); self::assertTrue($value >= $min && $value <= $max); } diff --git a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php index 4db230ece0..c3b1196c0d 100644 --- a/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php +++ b/tests/PhpSpreadsheetTests/Calculation/Functions/MathTrig/SequenceTest.php @@ -14,7 +14,7 @@ class SequenceTest extends AllSetupTeardown * @param mixed[] $arguments * @param mixed[]|string $expectedResult */ - public function testSEQUENCE(array $arguments, $expectedResult): void + public function testSEQUENCE(array $arguments, array|string $expectedResult): void { if (count($arguments) === 0) { $result = MatrixFunctions::sequence(); diff --git a/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php b/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php index ad1729b003..08fea3ccd3 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadBlankCellsTest.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Functional; +use PhpOffice\PhpSpreadsheet\Reader\IReader; use PhpOffice\PhpSpreadsheet\Spreadsheet; class ReadBlankCellsTest extends AbstractFunctional @@ -36,7 +37,7 @@ public function testXlsxLoadWithNoBlankCells(mixed $format): void self::assertFalse($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C2')); self::assertTrue($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('C3')); - $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function ($reader): void { + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function (IReader $reader): void { $reader->setReadEmptyCells(false); }); self::assertFalse($reloadedSpreadsheet->getActiveSheet()->getCellCollection()->has('B2')); diff --git a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php index 75c8206d0b..64f3b05495 100644 --- a/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php +++ b/tests/PhpSpreadsheetTests/Functional/ReadFilterTest.php @@ -4,6 +4,7 @@ namespace PhpOffice\PhpSpreadsheetTests\Functional; +use PhpOffice\PhpSpreadsheet\Reader\IReader; use PhpOffice\PhpSpreadsheet\Spreadsheet; class ReadFilterTest extends AbstractFunctional @@ -65,7 +66,7 @@ public function testXlsxLoadWithReadFilter(mixed $format, array $arrayData): voi $spreadsheet = new Spreadsheet(); $spreadsheet->getActiveSheet()->fromArray($arrayData, null, 'A1'); - $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function ($reader): void { + $reloadedSpreadsheet = $this->writeAndReload($spreadsheet, $format, function (IReader $reader): void { // apply filter $reader->setReadFilter(new ReadFilterFilter()); }); diff --git a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php index c6bb2ccaba..7e5d84cfff 100644 --- a/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Csv/CsvContiguousFilter.php @@ -45,7 +45,7 @@ public function filter0(int $row): bool return false; } - public function readCell($columnAddress, $row, $worksheetName = ''): bool + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { if ($this->filterType == 1) { return $this->filter1($row); diff --git a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php index b33bb086f3..60f02631ce 100644 --- a/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Gnumeric/GnumericFilter.php @@ -9,7 +9,7 @@ /** Define a Read Filter class implementing IReadFilter */ class GnumericFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = ''): bool + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return $row !== 4; } diff --git a/tests/PhpSpreadsheetTests/Reader/Ods/RepeatedColumnsTest.php b/tests/PhpSpreadsheetTests/Reader/Ods/RepeatedColumnsTest.php index 7b6e9dbb5b..55d6206ddd 100644 --- a/tests/PhpSpreadsheetTests/Reader/Ods/RepeatedColumnsTest.php +++ b/tests/PhpSpreadsheetTests/Reader/Ods/RepeatedColumnsTest.php @@ -15,7 +15,7 @@ public function testDefinedNames(): void $reader = new Ods(); $reader->setReadFilter( new class () implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = ''): bool + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return in_array($columnAddress, ['A', 'C', 'E', 'G', 'J', 'K'], true); } diff --git a/tests/PhpSpreadsheetTests/Reader/Xlsx/OddColumnReadFilter.php b/tests/PhpSpreadsheetTests/Reader/Xlsx/OddColumnReadFilter.php index f1e0c32795..c19eb12dff 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xlsx/OddColumnReadFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Xlsx/OddColumnReadFilter.php @@ -11,7 +11,7 @@ */ class OddColumnReadFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = ''): bool + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return (\ord(\substr($columnAddress, -1, 1)) % 2) === 1; } diff --git a/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php b/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php index 312550505b..c0d51b3b3e 100644 --- a/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php +++ b/tests/PhpSpreadsheetTests/Reader/Xml/XmlFilter.php @@ -9,7 +9,7 @@ /** Define a Read Filter class implementing IReadFilter */ class XmlFilter implements IReadFilter { - public function readCell($columnAddress, $row, $worksheetName = ''): bool + public function readCell(string $columnAddress, int $row, string $worksheetName = ''): bool { return $row !== 4; } From a68a54e4b9f0d991453b80c09caa1a65fd62d02e Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 3 Jan 2024 13:05:09 +0800 Subject: [PATCH 15/25] Last native param types --- src/PhpSpreadsheet/Chart/DataSeries.php | 3 +-- src/PhpSpreadsheet/Document/Properties.php | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index 2d64bfbfb4..054f088f07 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -107,14 +107,13 @@ class DataSeries /** * Create a new DataSeries. * - * @param null|mixed $plotType * @param int[] $plotOrder * @param DataSeriesValues[] $plotLabel * @param DataSeriesValues[] $plotCategory * @param DataSeriesValues[] $plotValues */ public function __construct( - $plotType = null, + null|string $plotType = null, null|string $plotGrouping = null, array $plotOrder = [], array $plotLabel = [], diff --git a/src/PhpSpreadsheet/Document/Properties.php b/src/PhpSpreadsheet/Document/Properties.php index 1459458f87..24a5065cdd 100644 --- a/src/PhpSpreadsheet/Document/Properties.php +++ b/src/PhpSpreadsheet/Document/Properties.php @@ -394,12 +394,7 @@ private function identifyPropertyType(mixed $propertyValue): string /** * Set a Custom Property. * - * @param string $propertyType - * 'i' : Integer - * 'f' : Floating Point - * 's' : String - * 'd' : Date/Time - * 'b' : Boolean + * @param ?string $propertyType see `self::VALID_PROPERTY_TYPE_LIST` * * @return $this */ From c1eafc53369ae3fc19c8bd2de39473b3730d87be Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 3 Jan 2024 20:51:53 +0800 Subject: [PATCH 16/25] Cleanup PHPDoc according to PhpStorm --- samples/Basic/16_Csv.php | 3 - .../Calculation/Database/DAverage.php | 2 +- .../Calculation/Database/DCount.php | 2 +- .../Calculation/Database/DCountA.php | 2 +- .../Calculation/Database/DGet.php | 2 +- .../Calculation/Database/DMax.php | 2 +- .../Calculation/Database/DMin.php | 2 +- .../Calculation/Database/DProduct.php | 2 +- .../Calculation/Database/DStDev.php | 2 +- .../Calculation/Database/DStDevP.php | 2 +- .../Calculation/Database/DSum.php | 2 +- .../Calculation/Database/DVar.php | 2 +- .../Calculation/Database/DVarP.php | 2 +- .../Calculation/DateTimeExcel/TimeValue.php | 8 +-- .../Engine/Operands/StructuredReference.php | 4 +- .../Calculation/ExceptionHandler.php | 2 +- .../Calculation/Financial/Amortization.php | 4 +- .../Calculation/Financial/Coupons.php | 2 +- .../Calculation/LookupRef/VLookup.php | 2 +- .../Calculation/MathTrig/Subtotal.php | 4 +- .../Calculation/Statistical/Confidence.php | 2 +- .../Statistical/Distributions/Binomial.php | 8 +-- .../Statistical/Distributions/ChiSquared.php | 4 +- .../Statistical/Distributions/LogNormal.php | 2 +- .../Statistical/Distributions/Poisson.php | 4 +- .../Distributions/StandardNormal.php | 4 +- src/PhpSpreadsheet/Chart/Chart.php | 1 - src/PhpSpreadsheet/Chart/Title.php | 4 +- src/PhpSpreadsheet/Collection/Cells.php | 5 +- src/PhpSpreadsheet/IOFactory.php | 8 +-- src/PhpSpreadsheet/Reader/Html.php | 4 +- src/PhpSpreadsheet/Reader/Xls.php | 2 +- src/PhpSpreadsheet/Reader/Xlsx/Chart.php | 60 +++---------------- .../Reader/Xml/DataValidations.php | 2 +- src/PhpSpreadsheet/Settings.php | 6 +- src/PhpSpreadsheet/Style/Alignment.php | 2 +- src/PhpSpreadsheet/Style/Border.php | 4 +- src/PhpSpreadsheet/Style/Borders.php | 2 +- src/PhpSpreadsheet/Style/Color.php | 4 +- .../CellStyleAssessor.php | 1 - src/PhpSpreadsheet/Style/Fill.php | 2 +- src/PhpSpreadsheet/Style/Font.php | 2 +- src/PhpSpreadsheet/Style/NumberFormat.php | 2 +- .../Style/NumberFormat/DateFormatter.php | 4 +- .../Style/NumberFormat/FractionFormatter.php | 2 +- .../Style/NumberFormat/NumberFormatter.php | 12 ++-- .../NumberFormat/PercentageFormatter.php | 2 +- src/PhpSpreadsheet/Style/Protection.php | 2 +- src/PhpSpreadsheet/Worksheet/AutoFilter.php | 8 +-- src/PhpSpreadsheet/Worksheet/Worksheet.php | 10 ++-- src/PhpSpreadsheet/Writer/Ods/Content.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Chart.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/Style.php | 4 -- tests/PhpSpreadsheetTests/IOFactoryTest.php | 1 + tests/PhpSpreadsheetTests/SettingsTest.php | 1 + 56 files changed, 94 insertions(+), 146 deletions(-) diff --git a/samples/Basic/16_Csv.php b/samples/Basic/16_Csv.php index 137f6469c1..381d8c79da 100644 --- a/samples/Basic/16_Csv.php +++ b/samples/Basic/16_Csv.php @@ -7,7 +7,6 @@ $spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php'; $helper->log('Write to CSV format'); -/** @var \PhpOffice\PhpSpreadsheet\Writer\Csv $writer */ $writer = new CsvWriter($spreadsheet); $writer->setDelimiter(',') ->setEnclosure('"') @@ -20,7 +19,6 @@ $helper->log('Read from CSV format'); -/** @var \PhpOffice\PhpSpreadsheet\Reader\Csv $reader */ $reader = new CsvReader(); $reader->setDelimiter(',') ->setEnclosure('"') @@ -36,7 +34,6 @@ // Write CSV $filenameCSV = $helper->getFilename(__FILE__, 'csv'); -/** @var \PhpOffice\PhpSpreadsheet\Writer\Csv $writerCSV */ $writerCSV = new CsvWriter($spreadsheetFromCSV); //$writerCSV->setExcelCompatibility(true); $writerCSV->setUseBom(true); // because of non-ASCII chars diff --git a/src/PhpSpreadsheet/Calculation/Database/DAverage.php b/src/PhpSpreadsheet/Calculation/Database/DAverage.php index fc4a0e3ca0..e54f1bb3d6 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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/DCount.php b/src/PhpSpreadsheet/Calculation/Database/DCount.php index 878f4cf2bd..fff7ab0d23 100644 --- a/src/PhpSpreadsheet/Calculation/Database/DCount.php +++ b/src/PhpSpreadsheet/Calculation/Database/DCount.php @@ -20,7 +20,7 @@ class DCount 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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/DCountA.php b/src/PhpSpreadsheet/Calculation/Database/DCountA.php index a8a640c88d..f1a68c1bef 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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/DGet.php b/src/PhpSpreadsheet/Calculation/Database/DGet.php index 05ea6320b0..dd0f006100 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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 1f070da2f7..23b95a7d4a 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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 d72fa927c1..541803dc9a 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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 77574a69d3..b60aa0dca5 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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/DStDev.php b/src/PhpSpreadsheet/Calculation/Database/DStDev.php index b53bcb3a12..dc354056a6 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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 bc176dfd42..a05d59686c 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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 6cc1296177..f9f926b017 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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 5805806cfe..33b5b56ea6 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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/DVarP.php b/src/PhpSpreadsheet/Calculation/Database/DVarP.php index 0ad61a9f26..942a4a1f6d 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 null|int|string $field Indicates which column is used in the function. Enter the + * @param null|array|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/DateTimeExcel/TimeValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php index 1ebbb21f8e..d1e9ceb6a0 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php @@ -47,7 +47,7 @@ public static function fromString(null|array|string|int|bool $timeValue): array| return ExcelError::VALUE(); } - $timeValue = trim($timeValue ?? '', '"'); + $timeValue = trim((string) $timeValue, '"'); $timeValue = str_replace(['/', '.'], '-', $timeValue); $arraySplit = preg_split('/[\/:\-\s]/', $timeValue) ?: []; @@ -59,11 +59,11 @@ public static function fromString(null|array|string|int|bool $timeValue): array| $PHPDateArray = Helpers::dateParse($timeValue); $retValue = ExcelError::VALUE(); if (Helpers::dateParseSucceeded($PHPDateArray)) { - /** @var int */ + /** @var int $hour */ $hour = $PHPDateArray['hour']; - /** @var int */ + /** @var int $minute */ $minute = $PHPDateArray['minute']; - /** @var int */ + /** @var int $second */ $second = $PHPDateArray['second']; // OpenOffice-specific code removed - it works just like Excel $excelDateValue = SharedDateHelper::formattedPHPToExcel(1900, 1, 1, $hour, $minute, $second) - 1; diff --git a/src/PhpSpreadsheet/Calculation/Engine/Operands/StructuredReference.php b/src/PhpSpreadsheet/Calculation/Engine/Operands/StructuredReference.php index 6d30e09bf9..fc2b5ea47d 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/Operands/StructuredReference.php +++ b/src/PhpSpreadsheet/Calculation/Engine/Operands/StructuredReference.php @@ -200,7 +200,6 @@ private function getRowReference(Cell $cell): string $reference = $this->adjustRowReference($columnName, $reference, $cell, $columnId); } - /** @var string $reference */ return $this->validateParsedReference(trim($reference, '[]@, ')); } @@ -305,7 +304,6 @@ private function getRowsForColumnReference(string &$reference, int $startRow, in $rowsSelected = false; foreach (self::ITEM_SPECIFIER_ROWS_SET as $rowReference) { $pattern = '/\[' . $rowReference . '\]/mui'; - /** @var string $reference */ if (preg_match($pattern, $reference) === 1) { if (($rowReference === self::ITEM_SPECIFIER_HEADERS) && ($this->table->getShowHeaderRow() === false)) { throw new Exception( @@ -316,7 +314,7 @@ private function getRowsForColumnReference(string &$reference, int $startRow, in $rowsSelected = true; $startRow = min($startRow, $this->getMinimumRow($rowReference)); $endRow = max($endRow, $this->getMaximumRow($rowReference)); - $reference = preg_replace($pattern, '', $reference); + $reference = preg_replace($pattern, '', $reference) ?? ''; } } if ($rowsSelected === false) { diff --git a/src/PhpSpreadsheet/Calculation/ExceptionHandler.php b/src/PhpSpreadsheet/Calculation/ExceptionHandler.php index 6461961a07..890da60b59 100644 --- a/src/PhpSpreadsheet/Calculation/ExceptionHandler.php +++ b/src/PhpSpreadsheet/Calculation/ExceptionHandler.php @@ -9,7 +9,7 @@ class ExceptionHandler */ public function __construct() { - /** @var callable */ + /** @var callable $callable */ $callable = [Exception::class, 'errorHandlerCallback']; set_error_handler($callable, E_ALL); } diff --git a/src/PhpSpreadsheet/Calculation/Financial/Amortization.php b/src/PhpSpreadsheet/Calculation/Financial/Amortization.php index 9c8b339bbc..f72cc34c68 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Amortization.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Amortization.php @@ -74,7 +74,7 @@ public static function AMORDEGRC( if (is_string($yearFracx)) { return $yearFracx; } - /** @var float */ + /** @var float $yearFrac */ $yearFrac = $yearFracx; $amortiseCoeff = self::getAmortizationCoefficient($rate); @@ -164,7 +164,7 @@ public static function AMORLINC( if (is_string($yearFracx)) { return $yearFracx; } - /** @var float */ + /** @var float $yearFrac */ $yearFrac = $yearFracx; if ( diff --git a/src/PhpSpreadsheet/Calculation/Financial/Coupons.php b/src/PhpSpreadsheet/Calculation/Financial/Coupons.php index 34376fe9d5..c2fcab39b1 100644 --- a/src/PhpSpreadsheet/Calculation/Financial/Coupons.php +++ b/src/PhpSpreadsheet/Calculation/Financial/Coupons.php @@ -193,7 +193,7 @@ public static function COUPDAYSNC( return $e->getMessage(); } - /** @var int */ + /** @var int $daysPerYear */ $daysPerYear = Helpers::daysPerYear(Functions::Scalar(DateTimeExcel\DateParts::year($settlement)), $basis); $next = self::couponFirstPeriodDate($settlement, $maturity, $frequency, self::PERIOD_DATE_NEXT); diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php b/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php index 92e37b16ad..247074cfdc 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php @@ -49,7 +49,7 @@ public static function lookup(mixed $lookupValue, mixed $lookupArray, mixed $ind $firstColumn = array_shift($columnKeys) ?? 1; if (!$notExactMatch) { - /** @var callable */ + /** @var callable $callable */ $callable = [self::class, 'vlookupSort']; uasort($lookupArray, $callable); } diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php b/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php index c30a42f8dc..cfced9e43f 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php @@ -52,6 +52,9 @@ function ($index) use ($cellReference): bool { ); } + /** + * @var array + */ private const CALL_FUNCTIONS = [ 1 => [Statistical\Averages::class, 'average'], // 1 and 101 [Statistical\Counts::class, 'COUNT'], // 2 and 102 @@ -114,7 +117,6 @@ public static function evaluate(mixed $functionType, ...$args): float|int|string $aArgs = self::filterFormulaArgs($cellReference, $aArgs); if (array_key_exists($subtotal, self::CALL_FUNCTIONS)) { - /** @var callable */ $call = self::CALL_FUNCTIONS[$subtotal]; return call_user_func_array($call, $aArgs); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php b/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php index d4db9eaa53..492438add9 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Confidence.php @@ -43,7 +43,7 @@ public static function CONFIDENCE(mixed $alpha, mixed $stdDev, mixed $size) if (($alpha <= 0) || ($alpha >= 1) || ($stdDev <= 0) || ($size < 1)) { return ExcelError::NAN(); } - /** @var float */ + /** @var float $temp */ $temp = Distributions\StandardNormal::inverse(1 - $alpha / 2); return Functions::scalar($temp * $stdDev / sqrt($size)); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php index 66077d255d..e2de0d7c2e 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php @@ -55,7 +55,7 @@ public static function distribution(mixed $value, mixed $trials, mixed $probabil if ($cumulative) { return self::calculateCumulativeBinomial($value, $trials, $probability); } - /** @var float */ + /** @var float $comb */ $comb = Combinations::withoutRepetition($trials, $value); return $comb * $probability ** $value @@ -107,7 +107,7 @@ public static function range(mixed $trials, mixed $probability, mixed $successes $summer = 0; for ($i = $successes; $i <= $limit; ++$i) { - /** @var float */ + /** @var float $comb */ $comb = Combinations::withoutRepetition($trials, $i); $summer += $comb * $probability ** $i * (1 - $probability) ** ($trials - $i); @@ -161,7 +161,7 @@ public static function negative(mixed $failures, mixed $successes, mixed $probab return ExcelError::NAN(); } } - /** @var float */ + /** @var float $comb */ $comb = Combinations::withoutRepetition($failures + $successes - 1, $successes - 1); return $comb @@ -220,7 +220,7 @@ private static function calculateCumulativeBinomial(int $value, int $trials, flo { $summer = 0; for ($i = 0; $i <= $value; ++$i) { - /** @var float */ + /** @var float $comb */ $comb = Combinations::withoutRepetition($trials, $i); $summer += $comb * $probability ** $i * (1 - $probability) ** ($trials - $i); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php index 3dc0b33f13..38d4bbb8d1 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php @@ -275,7 +275,7 @@ private static function gammp(int $n, float $x): float // Relative error controlled by the eps parameter private static function gser(int $n, float $x): float { - /** @var float */ + /** @var float $gln */ $gln = Gamma::ln($n / 2); $a = 0.5 * $n; $ap = $a; @@ -299,7 +299,7 @@ private static function gser(int $n, float $x): float // Relative error controlled by the eps parameter private static function gcf(int $n, float $x): float { - /** @var float */ + /** @var float $gln */ $gln = Gamma::ln($n / 2); $a = 0.5 * $n; $b = $x + 1 - $a; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php index 3fbdf0f50a..50f02e4124 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/LogNormal.php @@ -131,7 +131,7 @@ public static function inverse(mixed $probability, mixed $mean, mixed $stdDev): if ($stdDev <= 0) { return ExcelError::NAN(); } - /** @var float */ + /** @var float $inverse */ $inverse = StandardNormal::inverse($probability); return exp($mean + $stdDev * $inverse); diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php index b5727f7677..931568eef4 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Poisson.php @@ -51,14 +51,14 @@ public static function distribution(mixed $value, mixed $mean, mixed $cumulative $summer = 0; $floor = floor($value); for ($i = 0; $i <= $floor; ++$i) { - /** @var float */ + /** @var float $fact */ $fact = MathTrig\Factorial::fact($i); $summer += $mean ** $i / $fact; } return exp(0 - $mean) * $summer; } - /** @var float */ + /** @var float $fact */ $fact = MathTrig\Factorial::fact($value); return (exp(0 - $mean) * $mean ** $value) / $fact; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php index a27870158e..cb2c646f55 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/StandardNormal.php @@ -102,7 +102,7 @@ public static function gauss(mixed $value): array|string|float if (!is_numeric($value)) { return ExcelError::VALUE(); } - /** @var float */ + /** @var float $dist */ $dist = self::distribution($value, true); return $dist - 0.5; @@ -140,7 +140,7 @@ public static function zTest(mixed $dataSet, mixed $m0, mixed $sigma = null) } if ($sigma === null) { - /** @var float */ + /** @var float $sigma */ $sigma = StandardDeviations::STDEV($dataSet); } $n = count($dataSet); diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index 5d370bfc8c..32100b6c2e 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -597,7 +597,6 @@ public function render(?string $outputDestination = null): bool // Ensure that data series values are up-to-date before we render $this->refresh(); - /** @var Renderer\IRenderer */ $renderer = new $libraryName($this); return $renderer->render($outputDestination); diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index d225b167ee..9797f31366 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -9,7 +9,7 @@ class Title /** * Title Caption. * - * @var array|RichText|string + * @var array|RichText|string */ private $caption = ''; @@ -52,7 +52,7 @@ public function getCaptionText(): string } $retVal = ''; foreach ($caption as $textx) { - /** @var RichText|string */ + /** @var RichText|string $text */ $text = $textx; if ($text instanceof RichText) { $retVal .= $text->getPlainText(); diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index a51b7d1415..61efd7fdb3 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -2,7 +2,6 @@ namespace PhpOffice\PhpSpreadsheet\Collection; -use Generator; use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\Coordinate; use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException; @@ -447,9 +446,9 @@ public function __destruct() /** * Returns all known cache keys. * - * @return Generator|string[] + * @return iterable */ - private function getAllCacheKeys() + private function getAllCacheKeys(): iterable { foreach ($this->index as $coordinate => $value) { yield $this->cachePrefix . $coordinate; diff --git a/src/PhpSpreadsheet/IOFactory.php b/src/PhpSpreadsheet/IOFactory.php index b895b6e603..db8776db61 100644 --- a/src/PhpSpreadsheet/IOFactory.php +++ b/src/PhpSpreadsheet/IOFactory.php @@ -30,7 +30,7 @@ abstract class IOFactory public const WRITER_CSV = 'Csv'; public const WRITER_HTML = 'Html'; - /** @var string[] */ + /** @var array> */ private static array $readers = [ self::READER_XLSX => Reader\Xlsx::class, self::READER_XLS => Reader\Xls::class, @@ -42,7 +42,7 @@ abstract class IOFactory self::READER_CSV => Reader\Csv::class, ]; - /** @var string[] */ + /** @var array> */ private static array $writers = [ self::WRITER_XLS => Writer\Xls::class, self::WRITER_XLSX => Writer\Xlsx::class, @@ -64,7 +64,6 @@ public static function createWriter(Spreadsheet $spreadsheet, string $writerType } // Instantiate writer - /** @var IWriter */ $className = self::$writers[$writerType]; return new $className($spreadsheet); @@ -80,7 +79,6 @@ public static function createReader(string $readerType): IReader } // Instantiate reader - /** @var IReader */ $className = self::$readers[$readerType]; return new $className(); @@ -212,6 +210,8 @@ private static function getReaderTypeFromExtension(string $filename): ?string /** * Register a writer with its type and class name. + * + * @param class-string $writerClass */ public static function registerWriter(string $writerType, string $writerClass): void { diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 5841a48039..294ba38404 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -634,7 +634,7 @@ public function loadIntoExisting(string $filename, Spreadsheet $spreadsheet): Sp $lowend = "\u{80}"; $highend = "\u{10ffff}"; $regexp = "/[$lowend-$highend]/u"; - /** @var callable */ + /** @var callable $callback */ $callback = [self::class, 'replaceNonAscii']; $convert = preg_replace_callback($regexp, $callback, $convert); $loaded = ($convert === null) ? false : $dom->loadHTML($convert); @@ -743,7 +743,7 @@ public function loadFromString(string $content, ?Spreadsheet $spreadsheet = null $lowend = "\u{80}"; $highend = "\u{10ffff}"; $regexp = "/[$lowend-$highend]/u"; - /** @var callable */ + /** @var callable $callback */ $callback = [self::class, 'replaceNonAscii']; $convert = preg_replace_callback($regexp, $callback, $convert); $loaded = ($convert === null) ? false : $dom->loadHTML($convert); diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index f90d2decbc..cd3743d047 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -958,7 +958,7 @@ protected function loadSpreadsheetFromFile(string $filename): Spreadsheet $escherWorksheet = $reader->load($this->drawingData); // get all spContainers in one long array, so they can be mapped to OBJ records - /** @var SpContainer[] */ + /** @var SpContainer[] $allSpContainers */ $allSpContainers = method_exists($escherWorksheet, 'getDgContainer') ? $escherWorksheet->getDgContainer()->getSpgrContainer()->getAllSpContainers() : []; } diff --git a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php index 36ee58ea7e..7afe975409 100644 --- a/src/PhpSpreadsheet/Reader/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Reader/Xlsx/Chart.php @@ -111,7 +111,7 @@ public function readChart(SimpleXMLElement $chartElements, string $chartName): \ break; case 'roundedCorners': - /** @var bool */ + /** @var bool $roundedCorners */ $roundedCorners = self::getAttributeBoolean($chartElementsC->roundedCorners, 'val'); break; @@ -120,7 +120,7 @@ public function readChart(SimpleXMLElement $chartElements, string $chartName): \ $chartDetails = Xlsx::testSimpleXml($chartDetails); switch ($chartDetailsKey) { case 'autoTitleDeleted': - /** @var bool */ + /** @var bool $autoTitleDeleted */ $autoTitleDeleted = self::getAttributeBoolean($chartElementsC->chart->autoTitleDeleted, 'val'); break; @@ -147,7 +147,7 @@ public function readChart(SimpleXMLElement $chartElements, string $chartName): \ if (isset($possibleNoFill->gradFill->gsLst)) { foreach ($possibleNoFill->gradFill->gsLst->gs as $gradient) { $gradient = Xlsx::testSimpleXml($gradient); - /** @var float */ + /** @var float $pos */ $pos = self::getAttributeFloat($gradient, 'pos'); $gradientArray[] = [ $pos / ChartProperties::PERCENTAGE_MULTIPLIER, @@ -308,7 +308,7 @@ public function readChart(SimpleXMLElement $chartElements, string $chartName): \ break; case 'scatterChart': - /** @var string */ + /** @var string $scatterStyle */ $scatterStyle = self::getAttributeString($chartDetail->scatterStyle, 'val'); $plotSer = $this->chartDataSeries($chartDetail, $chartDetailKey); $plotSer->setPlotStyle($scatterStyle); @@ -325,7 +325,7 @@ public function readChart(SimpleXMLElement $chartElements, string $chartName): \ break; case 'radarChart': - /** @var string */ + /** @var string $radarStyle */ $radarStyle = self::getAttributeString($chartDetail->radarStyle, 'val'); $plotSer = $this->chartDataSeries($chartDetail, $chartDetailKey); $plotSer->setPlotStyle($radarStyle); @@ -626,23 +626,14 @@ private function chartDataSeries(SimpleXMLElement $chartDetail, string $plotType case 'trendline': $trendLine = new TrendLine(); $this->readLineStyle($seriesDetail, $trendLine); - /** @var ?string */ $trendLineType = self::getAttributeString($seriesDetail->trendlineType, 'val'); - /** @var ?bool */ $dispRSqr = self::getAttributeBoolean($seriesDetail->dispRSqr, 'val'); - /** @var ?bool */ $dispEq = self::getAttributeBoolean($seriesDetail->dispEq, 'val'); - /** @var ?int */ $order = self::getAttributeInteger($seriesDetail->order, 'val'); - /** @var ?int */ $period = self::getAttributeInteger($seriesDetail->period, 'val'); - /** @var ?float */ $forward = self::getAttributeFloat($seriesDetail->forward, 'val'); - /** @var ?float */ $backward = self::getAttributeFloat($seriesDetail->backward, 'val'); - /** @var ?float */ $intercept = self::getAttributeFloat($seriesDetail->intercept, 'val'); - /** @var ?string */ $name = (string) $seriesDetail->name; $trendLine->setTrendLineProperties( $trendLineType, @@ -973,31 +964,22 @@ private function parseRichText(SimpleXMLElement $titleDetailPart): RichText $defaultComplexScript = null; $defaultFontColor = null; if (isset($titleDetailPart->pPr->defRPr)) { - /** @var ?int */ $defaultFontSize = self::getAttributeInteger($titleDetailPart->pPr->defRPr, 'sz'); - /** @var ?bool */ $defaultBold = self::getAttributeBoolean($titleDetailPart->pPr->defRPr, 'b'); - /** @var ?bool */ $defaultItalic = self::getAttributeBoolean($titleDetailPart->pPr->defRPr, 'i'); - /** @var ?string */ $defaultUnderscore = self::getAttributeString($titleDetailPart->pPr->defRPr, 'u'); - /** @var ?string */ $defaultStrikethrough = self::getAttributeString($titleDetailPart->pPr->defRPr, 'strike'); - /** @var ?int */ $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::getAttributeString($titleDetailPart->pPr->defRPr->latin, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->ea)) { - /** @var ?string */ $defaultEastAsian = self::getAttributeString($titleDetailPart->pPr->defRPr->ea, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->cs)) { - /** @var ?string */ $defaultComplexScript = self::getAttributeString($titleDetailPart->pPr->defRPr->cs, 'typeface'); } if (isset($titleDetailPart->pPr->defRPr->solidFill)) { @@ -1037,18 +1019,14 @@ private function parseRichText(SimpleXMLElement $titleDetailPart): RichText // @codeCoverageIgnoreEnd } if (isset($titleDetailElement->rPr->latin)) { - /** @var ?string */ $latinName = self::getAttributeString($titleDetailElement->rPr->latin, 'typeface'); } if (isset($titleDetailElement->rPr->ea)) { - /** @var ?string */ $eastAsian = self::getAttributeString($titleDetailElement->rPr->ea, 'typeface'); } if (isset($titleDetailElement->rPr->cs)) { - /** @var ?string */ $complexScript = self::getAttributeString($titleDetailElement->rPr->cs, 'typeface'); } - /** @var ?int */ $fontSize = self::getAttributeInteger($titleDetailElement->rPr, 'sz'); // not used now, not sure it ever was, grandfathering @@ -1056,22 +1034,14 @@ private function parseRichText(SimpleXMLElement $titleDetailPart): RichText $fontColor = $this->readColor($titleDetailElement->rPr->solidFill); } - /** @var ?bool */ $bold = self::getAttributeBoolean($titleDetailElement->rPr, 'b'); - - /** @var ?bool */ $italic = self::getAttributeBoolean($titleDetailElement->rPr, 'i'); - - /** @var ?int */ $baseline = self::getAttributeInteger($titleDetailElement->rPr, 'baseline'); - - /** @var ?string */ $underscore = self::getAttributeString($titleDetailElement->rPr, 'u'); if (isset($titleDetailElement->rPr->uFill->solidFill)) { $underlineColor = $this->readColor($titleDetailElement->rPr->uFill->solidFill); } - /** @var ?string */ $strikethrough = self::getAttributeString($titleDetailElement->rPr, 'strike'); } @@ -1317,7 +1287,6 @@ private function readEffects(SimpleXMLElement $chartDetail, ?ChartProperties $ch } if (isset($sppr->effectLst->softEdge)) { - /** @var string */ $softEdgeSize = self::getAttributeString($sppr->effectLst->softEdge, 'rad'); if (is_numeric($softEdgeSize)) { $chartObject->setSoftEdges((float) ChartProperties::xmlToPoints($softEdgeSize)); @@ -1333,13 +1302,10 @@ private function readEffects(SimpleXMLElement $chartDetail, ?ChartProperties $ch } } if ($type !== '') { - /** @var string */ $blur = self::getAttributeString($sppr->effectLst->$type, 'blurRad'); $blur = is_numeric($blur) ? ChartProperties::xmlToPoints($blur) : null; - /** @var string */ $dist = self::getAttributeString($sppr->effectLst->$type, 'dist'); $dist = is_numeric($dist) ? ChartProperties::xmlToPoints($dist) : null; - /** @var string */ $direction = self::getAttributeString($sppr->effectLst->$type, 'dir'); $direction = is_numeric($direction) ? ChartProperties::xmlToAngle($direction) : null; $algn = self::getAttributeString($sppr->effectLst->$type, 'algn'); @@ -1392,14 +1358,12 @@ private function readColor(SimpleXMLElement $colorXml): array $result['type'] = $type; $result['value'] = self::getAttributeString($colorXml->$type, 'val'); if (isset($colorXml->$type->alpha)) { - /** @var 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::getAttributeString($colorXml->$type->lumMod, 'val'); if (is_numeric($brightness)) { $result['brightness'] = ChartColor::alphaFromXml($brightness); @@ -1424,16 +1388,15 @@ private function readLineStyle(SimpleXMLElement $chartDetail, ?ChartProperties $ return; } $lineWidth = null; - /** @var string */ $lineWidthTemp = self::getAttributeString($sppr->ln, 'w'); if (is_numeric($lineWidthTemp)) { $lineWidth = ChartProperties::xmlToPoints($lineWidthTemp); } - /** @var string */ + /** @var string $compoundType */ $compoundType = self::getAttributeString($sppr->ln, 'cmpd'); - /** @var string */ + /** @var string $dashType */ $dashType = self::getAttributeString($sppr->ln->prstDash, 'val'); - /** @var string */ + /** @var string $capType */ $capType = self::getAttributeString($sppr->ln, 'cap'); if (isset($sppr->ln->miter)) { $joinType = ChartProperties::LINE_STYLE_JOIN_MITER; @@ -1444,17 +1407,11 @@ private function readLineStyle(SimpleXMLElement $chartDetail, ?ChartProperties $ } $headArrowSize = 0; $endArrowSize = 0; - /** @var string */ $headArrowType = self::getAttributeString($sppr->ln->headEnd, 'type'); - /** @var string */ $headArrowWidth = self::getAttributeString($sppr->ln->headEnd, 'w'); - /** @var string */ $headArrowLength = self::getAttributeString($sppr->ln->headEnd, 'len'); - /** @var string */ $endArrowType = self::getAttributeString($sppr->ln->tailEnd, 'type'); - /** @var string */ $endArrowWidth = self::getAttributeString($sppr->ln->tailEnd, 'w'); - /** @var string */ $endArrowLength = self::getAttributeString($sppr->ln->tailEnd, 'len'); $chartObject->setLineStyleProperties( $lineWidth, @@ -1540,7 +1497,6 @@ private function setAxisProperties(SimpleXMLElement $chartDetail, ?Axis $whichAx $addAxisText = false; $axisText = new AxisText(); if (isset($children->bodyPr)) { - /** @var string */ $textRotation = self::getAttributeString($children->bodyPr, 'rot'); if (is_numeric($textRotation)) { $axisText->setRotation((int) ChartProperties::xmlToAngle($textRotation)); diff --git a/src/PhpSpreadsheet/Reader/Xml/DataValidations.php b/src/PhpSpreadsheet/Reader/Xml/DataValidations.php index 31748cb9c2..531f8c35f9 100644 --- a/src/PhpSpreadsheet/Reader/Xml/DataValidations.php +++ b/src/PhpSpreadsheet/Reader/Xml/DataValidations.php @@ -40,7 +40,7 @@ public function loadDataValidations(SimpleXMLElement $worksheet, Spreadsheet $sp { $xmlX = $worksheet->children(Namespaces::URN_EXCEL); $sheet = $spreadsheet->getActiveSheet(); - /** @var callable */ + /** @var callable $pregCallback */ $pregCallback = [$this, 'replaceR1C1']; foreach ($xmlX->DataValidation as $dataValidation) { $cells = []; diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index d32f5d9025..21a9cc80df 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -16,7 +16,7 @@ class Settings * Class name of the chart renderer used for rendering charts * eg: PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph. * - * @var ?string + * @var null|class-string */ private static ?string $chartRenderer = null; @@ -61,7 +61,7 @@ public static function getLocale(): string /** * Identify to PhpSpreadsheet the external library to use for rendering charts. * - * @param string $rendererClassName Class name of the chart renderer + * @param class-string $rendererClassName Class name of the chart renderer * eg: PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph */ public static function setChartRenderer(string $rendererClassName): void @@ -76,7 +76,7 @@ public static function setChartRenderer(string $rendererClassName): void /** * Return the Chart Rendering Library that PhpSpreadsheet is currently configured to use. * - * @return null|string Class name of the chart renderer + * @return null|class-string Class name of the chart renderer * eg: PhpOffice\PhpSpreadsheet\Chart\Renderer\JpGraph */ public static function getChartRenderer(): ?string diff --git a/src/PhpSpreadsheet/Style/Alignment.php b/src/PhpSpreadsheet/Style/Alignment.php index 6f2af7b9cf..3aed77c697 100644 --- a/src/PhpSpreadsheet/Style/Alignment.php +++ b/src/PhpSpreadsheet/Style/Alignment.php @@ -155,7 +155,7 @@ public function __construct(bool $isSupervisor = false, bool $isConditional = fa */ public function getSharedComponent(): self { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; return $parent->getSharedComponent()->getAlignment(); diff --git a/src/PhpSpreadsheet/Style/Border.php b/src/PhpSpreadsheet/Style/Border.php index 78c69f0934..07162566db 100644 --- a/src/PhpSpreadsheet/Style/Border.php +++ b/src/PhpSpreadsheet/Style/Border.php @@ -65,7 +65,7 @@ public function __construct(bool $isSupervisor = false, bool $isConditional = fa */ public function getSharedComponent(): self { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; /** @var Borders $sharedComponent */ @@ -86,7 +86,7 @@ public function getSharedComponent(): self */ public function getStyleArray(array $array): array { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; return $parent->getStyleArray([$this->parentPropertyName => $array]); diff --git a/src/PhpSpreadsheet/Style/Borders.php b/src/PhpSpreadsheet/Style/Borders.php index becb00d6b3..93a95e67aa 100644 --- a/src/PhpSpreadsheet/Style/Borders.php +++ b/src/PhpSpreadsheet/Style/Borders.php @@ -116,7 +116,7 @@ public function __construct(bool $isSupervisor = false, bool $isConditional = fa */ public function getSharedComponent(): self { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; return $parent->getSharedComponent()->getBorders(); diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index 7abcc2f1df..448ba69865 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -139,7 +139,7 @@ public function __construct(string $colorValue = self::COLOR_BLACK, bool $isSupe */ public function getSharedComponent(): self { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; /** @var Border|Fill $sharedComponent */ $sharedComponent = $parent->getSharedComponent(); @@ -159,7 +159,7 @@ public function getSharedComponent(): self */ public function getStyleArray(array $array): array { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; return $parent->getStyleArray([$this->parentPropertyName => $array]); diff --git a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php index 30f5c97296..bcf59dee86 100644 --- a/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php +++ b/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php @@ -24,7 +24,6 @@ public function __construct(Cell $cell, string $conditionalRange) public function matchConditions(array $conditionalStyles = []): Style { foreach ($conditionalStyles as $conditional) { - /** @var Conditional $conditional */ if ($this->cellMatcher->evaluateConditional($conditional) === true) { // Merging the conditional style into the base style goes in here $this->styleMerger->mergeStyle($conditional->getStyle()); diff --git a/src/PhpSpreadsheet/Style/Fill.php b/src/PhpSpreadsheet/Style/Fill.php index f45ba7b07d..9ec5d7336e 100644 --- a/src/PhpSpreadsheet/Style/Fill.php +++ b/src/PhpSpreadsheet/Style/Fill.php @@ -88,7 +88,7 @@ public function __construct(bool $isSupervisor = false, bool $isConditional = fa */ public function getSharedComponent(): self { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; return $parent->getSharedComponent()->getFill(); diff --git a/src/PhpSpreadsheet/Style/Font.php b/src/PhpSpreadsheet/Style/Font.php index f64c8c9721..a5bfbb27cd 100644 --- a/src/PhpSpreadsheet/Style/Font.php +++ b/src/PhpSpreadsheet/Style/Font.php @@ -123,7 +123,7 @@ public function __construct(bool $isSupervisor = false, bool $isConditional = fa */ public function getSharedComponent(): self { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; return $parent->getSharedComponent()->getFont(); diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 2b7b61f2bb..c97d9fe416 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -133,7 +133,7 @@ public function __construct(bool $isSupervisor = false, bool $isConditional = fa */ public function getSharedComponent(): self { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; return $parent->getSharedComponent()->getNumberFormat(); diff --git a/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php b/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php index 12f37c1251..9ba3760e40 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php @@ -125,7 +125,7 @@ public static function format(mixed $value, string $format): string // OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case; // but we don't want to change any quoted strings - /** @var callable */ + /** @var callable $callable */ $callable = [self::class, 'setLowercaseCallback']; $format = (string) preg_replace_callback('/(?:^|")([^"]*)(?:$|")/', $callable, $format); @@ -155,7 +155,7 @@ public static function format(mixed $value, string $format): string $format = implode('"', $blocks); // escape any quoted characters so that DateTime format() will render them correctly - /** @var callable */ + /** @var callable $callback */ $callback = [self::class, 'escapeQuotesCallback']; $format = (string) preg_replace_callback('/"(.*)"/U', $callback, $format); diff --git a/src/PhpSpreadsheet/Style/NumberFormat/FractionFormatter.php b/src/PhpSpreadsheet/Style/NumberFormat/FractionFormatter.php index 02944fb4b5..504e77ac69 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/FractionFormatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/FractionFormatter.php @@ -29,7 +29,7 @@ public static function format(mixed $value, string $format): string if (is_numeric($matches[2])) { $fractionDivisor = 100 / (int) $matches[2]; } else { - /** @var float */ + /** @var float $fractionDivisor */ $fractionDivisor = MathTrig\Gcd::evaluate((int) $decimalPart, $decimalDivisor); } diff --git a/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php b/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php index 269ec3eb4c..3b13e68e08 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php @@ -30,7 +30,7 @@ private static function mergeComplexNumberFormatMasks(array $numbers, array $mas private static function processComplexNumberFormatMask(mixed $number, string $mask): string { - /** @var string */ + /** @var string $result */ $result = $number; $maskingBlockCount = preg_match_all('/0+/', $mask, $maskingBlocks, PREG_OFFSET_CAPTURE); @@ -43,13 +43,13 @@ private static function processComplexNumberFormatMask(mixed $number, string $ma $divisor = 10 ** $size; $offset = $block[1]; - /** @var float */ + /** @var float $numberFloat */ $numberFloat = $number; $blockValue = sprintf("%0{$size}d", fmod($numberFloat, $divisor)); $number = floor($numberFloat / $divisor); $mask = substr_replace($mask, $blockValue, $offset, $size); } - /** @var string */ + /** @var string $numberString */ $numberString = $number; if ($number > 0) { $mask = substr_replace($mask, $numberString, $offset, 0); @@ -62,7 +62,7 @@ private static function processComplexNumberFormatMask(mixed $number, string $ma private static function complexNumberFormatMask(mixed $number, string $mask, bool $splitOnPoint = true): string { - /** @var float */ + /** @var float $numberFloat */ $numberFloat = $number; if ($splitOnPoint) { $masks = explode('.', $mask); @@ -134,7 +134,7 @@ public static function floatStringConvertScientific(string $s): string private static function formatStraightNumericValue(mixed $value, string $format, array $matches, bool $useThousands): string { - /** @var float */ + /** @var float $valueFloat */ $valueFloat = $value; $left = $matches[1]; $dec = $matches[2]; @@ -178,7 +178,7 @@ private static function formatStraightNumericValue(mixed $value, string $format, $sprintf_pattern = "%0$minWidth." . strlen($right) . 'f'; - /** @var float */ + /** @var float $valueFloat */ $valueFloat = $value; $value = sprintf($sprintf_pattern, round($valueFloat, strlen($right))); diff --git a/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php b/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php index 55b5971aa9..f07a87fa48 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php @@ -40,7 +40,7 @@ public static function format($value, string $format): string $replacement = "0{$wholePartSize}.{$decimalPartSize}"; $mask = (string) preg_replace('/[#0,]+\.?[?#0,]*/ui', "%{$replacement}f{$placeHolders}", $format); - /** @var float */ + /** @var float $valueFloat */ $valueFloat = $value; return sprintf($mask, round($valueFloat, $decimalPartSize)); diff --git a/src/PhpSpreadsheet/Style/Protection.php b/src/PhpSpreadsheet/Style/Protection.php index a39a7ff222..55a6526c88 100644 --- a/src/PhpSpreadsheet/Style/Protection.php +++ b/src/PhpSpreadsheet/Style/Protection.php @@ -47,7 +47,7 @@ public function __construct(bool $isSupervisor = false, bool $isConditional = fa */ public function getSharedComponent(): self { - /** @var Style */ + /** @var Style $parent */ $parent = $this->parent; return $parent->getSharedComponent()->getProtection(); diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter.php b/src/PhpSpreadsheet/Worksheet/AutoFilter.php index 1201390f85..7766d7d1c3 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter.php @@ -370,7 +370,7 @@ protected static function filterTestInDateGroupSet(mixed $cellValue, array $data */ protected static function filterTestInCustomDataSet(mixed $cellValue, array $ruleSet): bool { - /** @var array[] */ + /** @var array[] $dataSet */ $dataSet = $ruleSet['filterRules']; $join = $ruleSet['join']; $customRuleForBlanks = $ruleSet['customRuleForBlanks'] ?? false; @@ -383,11 +383,11 @@ protected static function filterTestInCustomDataSet(mixed $cellValue, array $rul } $returnVal = ($join == AutoFilter\Column::AUTOFILTER_COLUMN_JOIN_AND); foreach ($dataSet as $rule) { - /** @var string */ + /** @var string $ruleValue */ $ruleValue = $rule['value']; - /** @var string */ + /** @var string $ruleOperator */ $ruleOperator = $rule['operator']; - /** @var string */ + /** @var string $cellValueString */ $cellValueString = $cellValue ?? ''; $retVal = false; diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 4806370140..7ce252843e 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -493,7 +493,7 @@ public function getDefaultRowDimension(): RowDimension */ public function getColumnDimensions(): array { - /** @var callable */ + /** @var callable $callable */ $callable = [self::class, 'columnDimensionCompare']; uasort($this->columnDimensions, $callable); @@ -1604,13 +1604,13 @@ public function setBreak($coordinate, int $break, int $max = -1): static public function getBreaks(): array { $breaks = []; - /** @var callable */ + /** @var callable $compareFunction */ $compareFunction = [self::class, 'compareRowBreaks']; uksort($this->rowBreaks, $compareFunction); foreach ($this->rowBreaks as $break) { $breaks[$break->getCoordinate()] = self::BREAK_ROW; } - /** @var callable */ + /** @var callable $compareFunction */ $compareFunction = [self::class, 'compareColumnBreaks']; uksort($this->columnBreaks, $compareFunction); foreach ($this->columnBreaks as $break) { @@ -1627,7 +1627,7 @@ public function getBreaks(): array */ public function getRowBreaks(): array { - /** @var callable */ + /** @var callable $compareFunction */ $compareFunction = [self::class, 'compareRowBreaks']; uksort($this->rowBreaks, $compareFunction); @@ -1657,7 +1657,7 @@ protected static function compareColumnBreaks(string $coordinate1, string $coord */ public function getColumnBreaks(): array { - /** @var callable */ + /** @var callable $compareFunction */ $compareFunction = [self::class, 'compareColumnBreaks']; uksort($this->columnBreaks, $compareFunction); diff --git a/src/PhpSpreadsheet/Writer/Ods/Content.php b/src/PhpSpreadsheet/Writer/Ods/Content.php index fb840cbf7f..cfa1dd1b45 100644 --- a/src/PhpSpreadsheet/Writer/Ods/Content.php +++ b/src/PhpSpreadsheet/Writer/Ods/Content.php @@ -117,7 +117,7 @@ public function write(): string */ private function writeSheets(XMLWriter $objWriter): void { - $spreadsheet = $this->getParentWriter()->getSpreadsheet(); /** @var Spreadsheet $spreadsheet */ + $spreadsheet = $this->getParentWriter()->getSpreadsheet(); $sheetCount = $spreadsheet->getSheetCount(); for ($sheetIndex = 0; $sheetIndex < $sheetCount; ++$sheetIndex) { $objWriter->startElement('table:table'); diff --git a/src/PhpSpreadsheet/Writer/Xlsx.php b/src/PhpSpreadsheet/Writer/Xlsx.php index 23a24862ff..c28cdfbaba 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx.php +++ b/src/PhpSpreadsheet/Writer/Xlsx.php @@ -482,7 +482,7 @@ public function save($filename, int $flags = 0): void $zipContent['xl/media/' . $this->getDrawingHashTable()->getByIndex($i)->getIndexedFilename()] = $imageContents; } elseif ($this->getDrawingHashTable()->getByIndex($i) instanceof MemoryDrawing) { ob_start(); - /** @var callable */ + /** @var callable $callable */ $callable = $this->getDrawingHashTable()->getByIndex($i)->getRenderingFunction(); call_user_func( $callable, diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php index 6e50f23c23..e720f6e152 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Chart.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Chart.php @@ -1628,7 +1628,7 @@ private function writeShadow(XMLWriter $objWriter, Properties $xAxis): void if (empty($xAxis->getShadowProperty('effect'))) { return; } - /** @var string */ + /** @var string $effect */ $effect = $xAxis->getShadowProperty('effect'); $objWriter->startElement("a:$effect"); diff --git a/src/PhpSpreadsheet/Writer/Xlsx/Style.php b/src/PhpSpreadsheet/Writer/Xlsx/Style.php index d254664fb2..e28f07e4b0 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/Style.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/Style.php @@ -655,7 +655,6 @@ public function allFills(Spreadsheet $spreadsheet): array $aFills[] = $fill1; // The remaining fills $aStyles = $this->allStyles($spreadsheet); - /** @var \PhpOffice\PhpSpreadsheet\Style\Style $style */ foreach ($aStyles as $style) { if (!isset($aFills[$style->getFill()->getHashCode()])) { $aFills[$style->getFill()->getHashCode()] = $style->getFill(); @@ -676,7 +675,6 @@ public function allFonts(Spreadsheet $spreadsheet): array $aFonts = []; $aStyles = $this->allStyles($spreadsheet); - /** @var \PhpOffice\PhpSpreadsheet\Style\Style $style */ foreach ($aStyles as $style) { if (!isset($aFonts[$style->getFont()->getHashCode()])) { $aFonts[$style->getFont()->getHashCode()] = $style->getFont(); @@ -697,7 +695,6 @@ public function allBorders(Spreadsheet $spreadsheet): array $aBorders = []; $aStyles = $this->allStyles($spreadsheet); - /** @var \PhpOffice\PhpSpreadsheet\Style\Style $style */ foreach ($aStyles as $style) { if (!isset($aBorders[$style->getBorders()->getHashCode()])) { $aBorders[$style->getBorders()->getHashCode()] = $style->getBorders(); @@ -718,7 +715,6 @@ public function allNumberFormats(Spreadsheet $spreadsheet): array $aNumFmts = []; $aStyles = $this->allStyles($spreadsheet); - /** @var \PhpOffice\PhpSpreadsheet\Style\Style $style */ foreach ($aStyles as $style) { if ($style->getNumberFormat()->getBuiltInFormatCode() === false && !isset($aNumFmts[$style->getNumberFormat()->getHashCode()])) { $aNumFmts[$style->getNumberFormat()->getHashCode()] = $style->getNumberFormat(); diff --git a/tests/PhpSpreadsheetTests/IOFactoryTest.php b/tests/PhpSpreadsheetTests/IOFactoryTest.php index 78cbef6828..151e5e5a61 100644 --- a/tests/PhpSpreadsheetTests/IOFactoryTest.php +++ b/tests/PhpSpreadsheetTests/IOFactoryTest.php @@ -166,6 +166,7 @@ public function testRegisterInvalidWriter(): void { $this->expectException(\PhpOffice\PhpSpreadsheet\Writer\Exception::class); + // @phpstan-ignore-next-line IOFactory::registerWriter('foo', 'bar'); } diff --git a/tests/PhpSpreadsheetTests/SettingsTest.php b/tests/PhpSpreadsheetTests/SettingsTest.php index 92668c96e3..b9be009ba4 100644 --- a/tests/PhpSpreadsheetTests/SettingsTest.php +++ b/tests/PhpSpreadsheetTests/SettingsTest.php @@ -34,6 +34,7 @@ public function testInvalidChartRenderer(): void { $this->expectException(SpException::class); $this->expectExceptionMessage('Chart renderer must implement'); + // @phpstan-ignore-next-line Settings::setChartRenderer(self::class); } From aefde297dfa5eb8c837b5e1106bd2ff111668cd7 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 3 Jan 2024 21:12:55 +0800 Subject: [PATCH 17/25] More cleanup PHPDoc according to PhpStorm --- samples/Basic/26_Utf8.php | 23 +++++++------------ .../Calculation/DateTimeExcel/Month.php | 5 ++-- .../Calculation/DateTimeExcel/TimeValue.php | 3 --- .../Statistical/Distributions/GammaBase.php | 3 +-- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/samples/Basic/26_Utf8.php b/samples/Basic/26_Utf8.php index 2eeca067b6..a466b9f490 100644 --- a/samples/Basic/26_Utf8.php +++ b/samples/Basic/26_Utf8.php @@ -16,27 +16,20 @@ $helper->write($spreadsheet, __FILE__, ['Xlsx', 'Xls', 'Html']); // Export to PDF (mpdf) -function mpdfCjkWriter(Mpdf $writer): void -{ - /** @var callable */ - $callback = 'mpdfCjk'; - $writer->setEditHtmlCallback($callback); -} +$mpdfCjkWriter = function (Mpdf $writer): void { + $mpdfCjk = function (string $html): string { + $html = str_replace("'Calibri'", "'Calibri',Sun-ExtA", $html); -function mpdfCjk(string $html): string -{ - $html = str_replace("'Calibri'", "'Calibri',Sun-ExtA", $html); + return str_replace("'Times New Roman'", "'Times New Roman',Sun-ExtA", $html); + }; - return str_replace("'Times New Roman'", "'Times New Roman',Sun-ExtA", $html); -} + $writer->setEditHtmlCallback($mpdfCjk); +}; $helper->log('Write to Mpdf'); IOFactory::registerWriter('Pdf', Mpdf::class); -/** @var callable */ -$callback = 'mpdfCjkWriter'; $filename = __FILE__; -//$filename = str_replace('.php', '.mdpf.php', __FILE__); -$helper->write($spreadsheet, $filename, ['Pdf'], false, $callback); +$helper->write($spreadsheet, $filename, ['Pdf'], false, $mpdfCjkWriter); // Remove first two rows with field headers before exporting to CSV $helper->log('Removing first two heading rows for CSV export'); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php index 9308acc588..f653c2fe40 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/Month.php @@ -2,6 +2,7 @@ namespace PhpOffice\PhpSpreadsheet\Calculation\DateTimeExcel; +use DateTime; use PhpOffice\PhpSpreadsheet\Calculation\ArrayEnabled; use PhpOffice\PhpSpreadsheet\Calculation\Exception; @@ -28,12 +29,12 @@ class Month * a negative value yields a past date. * Or can be an array of adjustment values * - * @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 values is passed as the argument, then the returned result will also be an array * with the same dimensions */ - public static function adjust(mixed $dateValue, array|string|bool|float|int $adjustmentMonths) + public static function adjust(mixed $dateValue, array|string|bool|float|int $adjustmentMonths): DateTime|float|int|string|array { if (is_array($dateValue) || is_array($adjustmentMonths)) { return self::evaluateArrayArguments([self::class, __FUNCTION__], $dateValue, $adjustmentMonths); diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php index d1e9ceb6a0..5a2f2461b5 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php @@ -59,11 +59,8 @@ public static function fromString(null|array|string|int|bool $timeValue): array| $PHPDateArray = Helpers::dateParse($timeValue); $retValue = ExcelError::VALUE(); if (Helpers::dateParseSucceeded($PHPDateArray)) { - /** @var int $hour */ $hour = $PHPDateArray['hour']; - /** @var int $minute */ $minute = $PHPDateArray['minute']; - /** @var int $second */ $second = $PHPDateArray['second']; // OpenOffice-specific code removed - it works just like Excel $excelDateValue = SharedDateHelper::formattedPHPToExcel(1900, 1, 1, $hour, $minute, $second) - 1; diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php index 01901a60c5..6ce99d8be6 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/GammaBase.php @@ -17,8 +17,7 @@ abstract class GammaBase private const MAX_ITERATIONS = 256; - /** @return float|string */ - protected static function calculateDistribution(float $value, float $a, float $b, bool $cumulative) + protected static function calculateDistribution(float $value, float $a, float $b, bool $cumulative): float { if ($cumulative) { return self::incompleteGamma($a, $value / $b) / self::gammaValue($a); From 5c6c8e2e1da1a9a6f983b1594689858bf8310efe Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 3 Jan 2024 21:38:26 +0800 Subject: [PATCH 18/25] Sync most PHPDoc with actual code --- src/PhpSpreadsheet/Calculation/Calculation.php | 14 +++++++------- .../Calculation/DateTimeExcel/YearFrac.php | 2 +- .../Calculation/Engineering/ConvertUOM.php | 4 ++-- .../Calculation/LookupRef/ExcelMatch.php | 2 +- .../Calculation/LookupRef/Formula.php | 2 +- .../Calculation/LookupRef/Hyperlink.php | 2 +- .../Calculation/MathTrig/Factorial.php | 2 +- src/PhpSpreadsheet/Calculation/MathTrig/Random.php | 2 +- src/PhpSpreadsheet/Calculation/MathTrig/Round.php | 4 ++-- .../Calculation/MathTrig/SeriesSum.php | 2 +- .../Calculation/Statistical/Averages.php | 4 ++-- .../Statistical/Distributions/Binomial.php | 2 +- .../Statistical/Distributions/ChiSquared.php | 4 ++-- .../Statistical/Distributions/NewtonRaphson.php | 1 - src/PhpSpreadsheet/Calculation/Web/Service.php | 2 +- src/PhpSpreadsheet/Cell/DataType.php | 2 +- src/PhpSpreadsheet/Chart/Chart.php | 2 +- src/PhpSpreadsheet/Chart/DataSeriesValues.php | 2 -- src/PhpSpreadsheet/RichText/Run.php | 2 +- src/PhpSpreadsheet/Shared/Drawing.php | 2 +- src/PhpSpreadsheet/Shared/XMLWriter.php | 2 +- src/PhpSpreadsheet/Style/Color.php | 4 ++-- src/PhpSpreadsheet/Style/NumberFormat.php | 2 +- .../Style/NumberFormat/Formatter.php | 2 +- src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php | 2 +- src/PhpSpreadsheet/Worksheet/Column.php | 6 +++--- .../Worksheet/ColumnCellIterator.php | 4 ++-- src/PhpSpreadsheet/Worksheet/ColumnIterator.php | 4 ++-- src/PhpSpreadsheet/Worksheet/Dimension.php | 2 +- src/PhpSpreadsheet/Worksheet/Drawing.php | 2 +- src/PhpSpreadsheet/Worksheet/Row.php | 6 +++--- src/PhpSpreadsheet/Worksheet/RowCellIterator.php | 4 ++-- src/PhpSpreadsheet/Worksheet/RowIterator.php | 4 ++-- src/PhpSpreadsheet/Worksheet/Table/Column.php | 2 +- src/PhpSpreadsheet/Worksheet/Worksheet.php | 6 +++--- src/PhpSpreadsheet/Writer/Xls/Worksheet.php | 2 +- src/PhpSpreadsheet/Writer/Xlsx/StringTable.php | 2 +- 37 files changed, 56 insertions(+), 59 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Calculation.php b/src/PhpSpreadsheet/Calculation/Calculation.php index f9da3c4ea2..f6e7012bf2 100644 --- a/src/PhpSpreadsheet/Calculation/Calculation.php +++ b/src/PhpSpreadsheet/Calculation/Calculation.php @@ -3398,7 +3398,7 @@ public static function unwrapResult(mixed $value): mixed * Calculate cell value (using formula from a cell ID) * Retained for backward compatibility. * - * @param Cell $cell Cell to calculate + * @param ?Cell $cell Cell to calculate */ public function calculate(?Cell $cell = null): mixed { @@ -3412,7 +3412,7 @@ public function calculate(?Cell $cell = null): mixed /** * Calculate the value of a cell formula. * - * @param Cell $cell Cell to calculate + * @param ?Cell $cell Cell to calculate * @param bool $resetLog Flag indicating whether the debug log should be reset or not */ public function calculateCellValue(?Cell $cell = null, bool $resetLog = true): mixed @@ -3531,8 +3531,8 @@ public function parseFormula(string $formula): array|bool * Calculate the value of a formula. * * @param string $formula Formula to parse - * @param string $cellID Address of the cell to calculate - * @param Cell $cell Cell to calculate + * @param ?string $cellID Address of the cell to calculate + * @param ?Cell $cell Cell to calculate */ public function calculateFormula(string $formula, ?string $cellID = null, ?Cell $cell = null): mixed { @@ -3594,8 +3594,8 @@ public function saveValueToCache(string $cellReference, mixed $cellValue): void * Parse a cell formula and calculate its value. * * @param string $formula The formula to parse and calculate - * @param string $cellID The ID (e.g. A3) of the cell that we are calculating - * @param Cell $cell Cell to calculate + * @param ?string $cellID The ID (e.g. A3) of the cell that we are calculating + * @param ?Cell $cell Cell to calculate * @param bool $ignoreQuotePrefix If set to true, evaluate the formyla even if the referenced cell is quote prefixed */ public function _calculateFormulaValue(string $formula, ?string $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false): mixed @@ -5329,7 +5329,7 @@ protected function raiseFormulaError(string $errorMessage, int $code = 0, ?Throw * Extract range values. * * @param string $range String based range representation - * @param Worksheet $worksheet Worksheet + * @param ?Worksheet $worksheet Worksheet * @param bool $resetLog Flag indicating whether calculation log should be reset or not * * @return array Array of values in range if range contains more than one element. Otherwise, a single value is returned. diff --git a/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php b/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php index edee3fa6e1..2713754ac2 100644 --- a/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php +++ b/src/PhpSpreadsheet/Calculation/DateTimeExcel/YearFrac.php @@ -39,7 +39,7 @@ class YearFrac * 4 European 30/360 * Or can be an array of methods * - * @return array|float|string fraction of the year, or a string containing an error + * @return array|float|int|string fraction of the year, or a string containing an error * 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 */ diff --git a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php index 9be40289c7..523ff21d34 100644 --- a/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php +++ b/src/PhpSpreadsheet/Calculation/Engineering/ConvertUOM.php @@ -450,7 +450,7 @@ public static function getConversionCategories(): array * getConversionGroupUnits * 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 + * @param ?string $category The group whose units of measure you want to retrieve */ public static function getConversionCategoryUnits(?string $category = null): array { @@ -467,7 +467,7 @@ public static function getConversionCategoryUnits(?string $category = null): arr /** * getConversionGroupUnitDetails. * - * @param string $category The group whose units of measure you want to retrieve + * @param ?string $category The group whose units of measure you want to retrieve */ public static function getConversionCategoryUnitDetails(?string $category = null): array { diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php b/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php index 3372ca58b9..43e89c9b9c 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/ExcelMatch.php @@ -30,7 +30,7 @@ class ExcelMatch * @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(mixed $lookupValue, mixed $lookupArray, mixed $matchType = self::MATCHTYPE_LARGEST_VALUE): array|string|int|float { diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php b/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php index 74d4865b23..5c7f4051ca 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Formula.php @@ -12,7 +12,7 @@ class Formula * FORMULATEXT. * * @param mixed $cellReference The cell to check - * @param Cell $cell The current cell (containing this formula) + * @param ?Cell $cell The current cell (containing this formula) */ public static function text(mixed $cellReference = '', ?Cell $cell = null): string { diff --git a/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php b/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php index 63e7549d2f..30db8437ed 100644 --- a/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php +++ b/src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php @@ -16,7 +16,7 @@ class Hyperlink * * @param mixed $linkURL Expect string. Value to check, is also the value returned when no error * @param mixed $displayName Expect string. Value to return when testValue is an error condition - * @param Cell $cell The cell to set the hyperlink in + * @param ?Cell $cell The cell to set the hyperlink in * * @return mixed The value of $displayName (or $linkURL if $displayName was blank) */ diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php b/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php index 02143b07c0..7bbd4d8be3 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Factorial.php @@ -99,7 +99,7 @@ public static function factDouble($factVal): array|string|float|int * * @param mixed[] $args An array of mixed values for the Data Series * - * @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 multinomial(...$args): string|int|float { diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Random.php b/src/PhpSpreadsheet/Calculation/MathTrig/Random.php index 16f7f21c32..5d3516777a 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Random.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Random.php @@ -13,7 +13,7 @@ class Random /** * RAND. * - * @return float Random number + * @return float|int Random number */ public static function rand(): int|float { diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/Round.php b/src/PhpSpreadsheet/Calculation/MathTrig/Round.php index 21e4a34e86..2854970d75 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/Round.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/Round.php @@ -118,7 +118,7 @@ public static function down($number, $digits): array|string|float * @param mixed $number Expect float. Number to round, or can be an array of numbers * @param mixed $multiple Expect int. Multiple to which you want to round, or can be an array of numbers. * - * @return array|float|string Rounded Number, or a string containing an error + * @return array|float|int|string Rounded Number, 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 */ @@ -187,7 +187,7 @@ public static function even($number): array|string|float * * @param array|float $number Number to round, or can be an array of numbers * - * @return array|float|string Rounded Number, or a string containing an error + * @return array|float|int|string Rounded Number, 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 */ diff --git a/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php b/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php index e2da113971..bb10090124 100644 --- a/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php +++ b/src/PhpSpreadsheet/Calculation/MathTrig/SeriesSum.php @@ -20,7 +20,7 @@ class SeriesSum * @param mixed $m Step * @param mixed[] $args An array of coefficients for the Data Series * - * @return array|float|string The result, or a string containing an error + * @return array|float|int|string The result, or a string containing an error */ public static function evaluate(mixed $x, mixed $n, mixed $m, ...$args): array|string|float|int { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Averages.php b/src/PhpSpreadsheet/Calculation/Statistical/Averages.php index cd7a9f8125..998e14df5d 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Averages.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Averages.php @@ -67,7 +67,7 @@ public static function averageDeviations(mixed ...$args): string|float * * @param mixed ...$args Data values * - * @return float|string (string if result is an error) + * @return float|int|string (string if result is an error) */ public static function average(mixed ...$args): string|int|float { @@ -106,7 +106,7 @@ public static function average(mixed ...$args): string|int|float * * @param mixed ...$args Data values * - * @return float|string (string if result is an error) + * @return float|int|string (string if result is an error) */ public static function averageA(mixed ...$args): string|int|float { diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php index e2de0d7c2e..2ce3fd5a9d 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/Binomial.php @@ -78,7 +78,7 @@ public static function distribution(mixed $value, mixed $trials, mixed $probabil * If null, then this will indicate the same as the number of Successes * Or can be an array of values * - * @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|float|int|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 range(mixed $trials, mixed $probability, mixed $successes, mixed $limit = null): array|string|float|int diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php index 38d4bbb8d1..49b0dfc924 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php @@ -23,7 +23,7 @@ class ChiSquared * @param mixed $degrees Integer degrees of freedom * Or can be an array of values * - * @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|float|int|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 distributionRightTail(mixed $value, mixed $degrees): array|string|int|float @@ -65,7 +65,7 @@ public static function distributionRightTail(mixed $value, mixed $degrees): arra * @param mixed $cumulative Boolean value indicating if we want the cdf (true) or the pdf (false) * Or can be an array of values * - * @return array|float|string If an array of numbers is passed as an argument, then the returned result will also be an array + * @return array|float|int|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 distributionLeftTail(mixed $value, mixed $degrees, mixed $cumulative): array|string|int|float diff --git a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php index d1727f49d6..647c0c4659 100644 --- a/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php +++ b/src/PhpSpreadsheet/Calculation/Statistical/Distributions/NewtonRaphson.php @@ -17,7 +17,6 @@ public function __construct(callable $callback) $this->callback = $callback; } - /** @return float|string */ public function execute(float $probability): string|int|float { $xLo = 100; diff --git a/src/PhpSpreadsheet/Calculation/Web/Service.php b/src/PhpSpreadsheet/Calculation/Web/Service.php index 7d843fcdc9..558134144e 100644 --- a/src/PhpSpreadsheet/Calculation/Web/Service.php +++ b/src/PhpSpreadsheet/Calculation/Web/Service.php @@ -62,7 +62,7 @@ public static function webService(string $url): string * * @return string the url encoded output */ - public static function urlEncode(mixed $text): string|array + public static function urlEncode(mixed $text): string { if (!is_string($text)) { return ExcelError::VALUE(); diff --git a/src/PhpSpreadsheet/Cell/DataType.php b/src/PhpSpreadsheet/Cell/DataType.php index f702a1a53f..8ae11df06a 100644 --- a/src/PhpSpreadsheet/Cell/DataType.php +++ b/src/PhpSpreadsheet/Cell/DataType.php @@ -53,7 +53,7 @@ public static function getErrorCodes(): array * * @return RichText|string Sanitized value */ - public static function checkString($textValue): RichText|string|array + public static function checkString(null|RichText|string $textValue): RichText|string { if ($textValue instanceof RichText) { // TODO: Sanitize Rich-Text string (max. character count is 32,767) diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index 32100b6c2e..dded33a5ee 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -579,7 +579,7 @@ public function refresh(): void /** * Render the chart to given file (or stream). * - * @param string $outputDestination Name of the file render to + * @param ?string $outputDestination Name of the file render to * * @return bool true on success */ diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index 9e10bf97d1..c49eb5864e 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -391,8 +391,6 @@ public function multiLevelCount(): int /** * Get Series Data Values. - * - * @return mixed[] */ public function getDataValues(): ?array { diff --git a/src/PhpSpreadsheet/RichText/Run.php b/src/PhpSpreadsheet/RichText/Run.php index 6284468450..6de9579c3c 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -36,7 +36,7 @@ public function getFont(): ?Font /** * Set font. * - * @param Font $font Font + * @param ?Font $font Font * * @return $this */ diff --git a/src/PhpSpreadsheet/Shared/Drawing.php b/src/PhpSpreadsheet/Shared/Drawing.php index 6fd5058de2..4eef791196 100644 --- a/src/PhpSpreadsheet/Shared/Drawing.php +++ b/src/PhpSpreadsheet/Shared/Drawing.php @@ -11,7 +11,7 @@ class Drawing * * @param int $pixelValue Value in pixels * - * @return int Value in EMU + * @return float|int Value in EMU */ public static function pixelsToEMU(int $pixelValue): int|float { diff --git a/src/PhpSpreadsheet/Shared/XMLWriter.php b/src/PhpSpreadsheet/Shared/XMLWriter.php index c5fd1d2d94..2703e98e99 100644 --- a/src/PhpSpreadsheet/Shared/XMLWriter.php +++ b/src/PhpSpreadsheet/Shared/XMLWriter.php @@ -21,7 +21,7 @@ class XMLWriter extends \XMLWriter * Create a new XMLWriter instance. * * @param int $temporaryStorage Temporary storage location - * @param string $temporaryStorageFolder Temporary storage folder + * @param ?string $temporaryStorageFolder Temporary storage folder */ public function __construct(int $temporaryStorage = self::STORAGE_MEMORY, ?string $temporaryStorageFolder = null) { diff --git a/src/PhpSpreadsheet/Style/Color.php b/src/PhpSpreadsheet/Style/Color.php index 448ba69865..6f9db8a21d 100644 --- a/src/PhpSpreadsheet/Style/Color.php +++ b/src/PhpSpreadsheet/Style/Color.php @@ -226,7 +226,7 @@ public function getARGB(): ?string /** * Set ARGB. * - * @param string $colorValue ARGB value, or a named color + * @param ?string $colorValue ARGB value, or a named color * * @return $this */ @@ -263,7 +263,7 @@ public function getRGB(): string /** * Set RGB. * - * @param string $colorValue RGB value, or a named color + * @param ?string $colorValue RGB value, or a named color * * @return $this */ diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index c97d9fe416..5153d84de0 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -411,7 +411,7 @@ public function getHashCode(): string * @param mixed $value Value to format * @param string $format Format code: see = self::FORMAT_* for predefined values; * or can be any valid MS Excel custom format string - * @param array $callBack Callback function for additional formatting of string + * @param ?array $callBack Callback function for additional formatting of string * * @return string Formatted string */ diff --git a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php index 20c0fd4e58..d4c593ac2b 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php +++ b/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php @@ -110,7 +110,7 @@ private static function splitFormatForSectionSelection(array $sections, mixed $v * @param null|bool|float|int|RichText|string $value Value to format * @param string $format Format code: see = self::FORMAT_* for predefined values; * or can be any valid MS Excel custom format string - * @param array $callBack Callback function for additional formatting of string + * @param ?array $callBack Callback function for additional formatting of string * * @return string Formatted string */ diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index 121fb2f9b8..2f8f86c6d1 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -84,7 +84,7 @@ class Column * Create a new Column. * * @param string $column Column (e.g. A) - * @param AutoFilter $parent Autofilter for this column + * @param ?AutoFilter $parent Autofilter for this column */ public function __construct(string $column, ?AutoFilter $parent = null) { diff --git a/src/PhpSpreadsheet/Worksheet/Column.php b/src/PhpSpreadsheet/Worksheet/Column.php index 926e293260..ef4ad2dfd6 100644 --- a/src/PhpSpreadsheet/Worksheet/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Column.php @@ -41,7 +41,7 @@ public function getColumnIndex(): string * Get cell iterator. * * @param int $startRow The row number at which to start iterating - * @param int $endRow Optionally, the row number at which to stop iterating + * @param ?int $endRow Optionally, the row number at which to stop iterating */ public function getCellIterator(int $startRow = 1, ?int $endRow = null, bool $iterateOnlyExistingCells = false): ColumnCellIterator { @@ -52,7 +52,7 @@ public function getCellIterator(int $startRow = 1, ?int $endRow = null, bool $it * Get row iterator. Synonym for getCellIterator(). * * @param int $startRow The row number at which to start iterating - * @param int $endRow Optionally, the row number at which to stop iterating + * @param ?int $endRow Optionally, the row number at which to stop iterating */ public function getRowIterator(int $startRow = 1, ?int $endRow = null, bool $iterateOnlyExistingCells = false): ColumnCellIterator { @@ -76,7 +76,7 @@ public function getRowIterator(int $startRow = 1, ?int $endRow = null, bool $ite * CellIterator::TREAT_NULL_VALUE_AS_EMPTY_CELL * CellIterator::TREAT_EMPTY_STRING_AS_EMPTY_CELL * @param int $startRow The row number at which to start checking if cells are empty - * @param int $endRow Optionally, the row number at which to stop checking if cells are empty + * @param ?int $endRow Optionally, the row number at which to stop checking if cells are empty */ public function isEmpty(int $definitionOfEmptyFlags = 0, int $startRow = 1, ?int $endRow = null): bool { diff --git a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php index 11575aae40..16a007ab06 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnCellIterator.php @@ -37,7 +37,7 @@ class ColumnCellIterator extends CellIterator * @param Worksheet $worksheet The worksheet to iterate over * @param string $columnIndex The column that we want to iterate * @param int $startRow The row number at which to start iterating - * @param int $endRow Optionally, the row number at which to stop iterating + * @param ?int $endRow Optionally, the row number at which to stop iterating */ public function __construct(Worksheet $worksheet, string $columnIndex = 'A', int $startRow = 1, ?int $endRow = null, bool $iterateOnlyExistingCells = false) { @@ -69,7 +69,7 @@ public function resetStart(int $startRow = 1): static /** * (Re)Set the end row. * - * @param int $endRow The row number at which to stop iterating + * @param ?int $endRow The row number at which to stop iterating * * @return $this */ diff --git a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php index f97c4fb9f8..69939c39fa 100644 --- a/src/PhpSpreadsheet/Worksheet/ColumnIterator.php +++ b/src/PhpSpreadsheet/Worksheet/ColumnIterator.php @@ -37,7 +37,7 @@ class ColumnIterator implements NativeIterator * * @param Worksheet $worksheet The worksheet to iterate over * @param string $startColumn The column address at which to start iterating - * @param string $endColumn Optionally, the column address at which to stop iterating + * @param ?string $endColumn Optionally, the column address at which to stop iterating */ public function __construct(Worksheet $worksheet, string $startColumn = 'A', ?string $endColumn = null) { @@ -83,7 +83,7 @@ public function resetStart(string $startColumn = 'A'): static /** * (Re)Set the end column. * - * @param string $endColumn The column address at which to stop iterating + * @param ?string $endColumn The column address at which to stop iterating * * @return $this */ diff --git a/src/PhpSpreadsheet/Worksheet/Dimension.php b/src/PhpSpreadsheet/Worksheet/Dimension.php index e37538dd72..7a88f8c93d 100644 --- a/src/PhpSpreadsheet/Worksheet/Dimension.php +++ b/src/PhpSpreadsheet/Worksheet/Dimension.php @@ -29,7 +29,7 @@ abstract class Dimension /** * Create a new Dimension. * - * @param int $initialValue Numeric row index + * @param ?int $initialValue Numeric row index */ public function __construct(?int $initialValue = null) { diff --git a/src/PhpSpreadsheet/Worksheet/Drawing.php b/src/PhpSpreadsheet/Worksheet/Drawing.php index 5cb1b3993c..be02779def 100644 --- a/src/PhpSpreadsheet/Worksheet/Drawing.php +++ b/src/PhpSpreadsheet/Worksheet/Drawing.php @@ -88,7 +88,7 @@ public function getPath(): string * * @param string $path File path * @param bool $verifyFile Verify file - * @param ZipArchive $zip Zip archive instance + * @param ?ZipArchive $zip Zip archive instance * * @return $this */ diff --git a/src/PhpSpreadsheet/Worksheet/Row.php b/src/PhpSpreadsheet/Worksheet/Row.php index e9656b1b02..7ba8608159 100644 --- a/src/PhpSpreadsheet/Worksheet/Row.php +++ b/src/PhpSpreadsheet/Worksheet/Row.php @@ -41,7 +41,7 @@ public function getRowIndex(): int * Get cell iterator. * * @param string $startColumn The column address at which to start iterating - * @param string $endColumn Optionally, the column address at which to stop iterating + * @param ?string $endColumn Optionally, the column address at which to stop iterating */ public function getCellIterator(string $startColumn = 'A', ?string $endColumn = null, bool $iterateOnlyExistingCells = false): RowCellIterator { @@ -52,7 +52,7 @@ public function getCellIterator(string $startColumn = 'A', ?string $endColumn = * Get column iterator. Synonym for getCellIterator(). * * @param string $startColumn The column address at which to start iterating - * @param string $endColumn Optionally, the column address at which to stop iterating + * @param ?string $endColumn Optionally, the column address at which to stop iterating */ public function getColumnIterator(string $startColumn = 'A', ?string $endColumn = null, bool $iterateOnlyExistingCells = false): RowCellIterator { @@ -76,7 +76,7 @@ public function getColumnIterator(string $startColumn = 'A', ?string $endColumn * CellIterator::TREAT_NULL_VALUE_AS_EMPTY_CELL * CellIterator::TREAT_EMPTY_STRING_AS_EMPTY_CELL * @param string $startColumn The column address at which to start checking if cells are empty - * @param string $endColumn Optionally, the column address at which to stop checking if cells are empty + * @param ?string $endColumn Optionally, the column address at which to stop checking if cells are empty */ public function isEmpty(int $definitionOfEmptyFlags = 0, string $startColumn = 'A', ?string $endColumn = null): bool { diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index fdcfcbfb85..0e256e8679 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -37,7 +37,7 @@ class RowCellIterator extends CellIterator * @param Worksheet $worksheet The worksheet to iterate over * @param int $rowIndex The row that we want to iterate * @param string $startColumn The column address at which to start iterating - * @param string $endColumn Optionally, the column address at which to stop iterating + * @param ?string $endColumn Optionally, the column address at which to stop iterating */ public function __construct(Worksheet $worksheet, int $rowIndex = 1, string $startColumn = 'A', ?string $endColumn = null, bool $iterateOnlyExistingCells = false) { @@ -69,7 +69,7 @@ public function resetStart(string $startColumn = 'A'): static /** * (Re)Set the end column. * - * @param string $endColumn The column address at which to stop iterating + * @param ?string $endColumn The column address at which to stop iterating * * @return $this */ diff --git a/src/PhpSpreadsheet/Worksheet/RowIterator.php b/src/PhpSpreadsheet/Worksheet/RowIterator.php index 4470526146..9d42ee9813 100644 --- a/src/PhpSpreadsheet/Worksheet/RowIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowIterator.php @@ -35,7 +35,7 @@ class RowIterator implements NativeIterator * * @param Worksheet $subject The worksheet to iterate over * @param int $startRow The row number at which to start iterating - * @param int $endRow Optionally, the row number at which to stop iterating + * @param ?int $endRow Optionally, the row number at which to stop iterating */ public function __construct(Worksheet $subject, int $startRow = 1, ?int $endRow = null) { @@ -77,7 +77,7 @@ public function resetStart(int $startRow = 1): static /** * (Re)Set the end row. * - * @param int $endRow The row number at which to stop iterating + * @param ?int $endRow The row number at which to stop iterating * * @return $this */ diff --git a/src/PhpSpreadsheet/Worksheet/Table/Column.php b/src/PhpSpreadsheet/Worksheet/Table/Column.php index 56832b0c15..d037f453ea 100644 --- a/src/PhpSpreadsheet/Worksheet/Table/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Table/Column.php @@ -49,7 +49,7 @@ class Column * Create a new Column. * * @param string $column Column (e.g. A) - * @param Table $table Table for this column + * @param ?Table $table Table for this column */ public function __construct(string $column, ?Table $table = null) { diff --git a/src/PhpSpreadsheet/Worksheet/Worksheet.php b/src/PhpSpreadsheet/Worksheet/Worksheet.php index 7ce252843e..9869c1ccd4 100644 --- a/src/PhpSpreadsheet/Worksheet/Worksheet.php +++ b/src/PhpSpreadsheet/Worksheet/Worksheet.php @@ -2946,7 +2946,7 @@ public function toArray( * Get row iterator. * * @param int $startRow The row number at which to start iterating - * @param int $endRow The row number at which to stop iterating + * @param ?int $endRow The row number at which to stop iterating */ public function getRowIterator(int $startRow = 1, ?int $endRow = null): RowIterator { @@ -2957,7 +2957,7 @@ public function getRowIterator(int $startRow = 1, ?int $endRow = null): RowItera * Get column iterator. * * @param string $startColumn The column address at which to start iterating - * @param string $endColumn The column address at which to stop iterating + * @param ?string $endColumn The column address at which to stop iterating */ public function getColumnIterator(string $startColumn = 'A', ?string $endColumn = null): ColumnIterator { @@ -3026,7 +3026,7 @@ public function getHashCode(): string * Example: extractSheetTitle("A1", true) ==> ['', 'A1']; * Example: extractSheetTitle("A1:C3", true) ==> ['', 'A1:C3'] * - * @param string $range Range to extract title from + * @param ?string $range Range to extract title from * @param bool $returnRange Return range? (see example) * * @return ($range is non-empty-string ? ($returnRange is true ? array{0: string, 1: string} : string) : ($returnRange is true ? array{0: null, 1: null} : null)) diff --git a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php index c6cb00c021..0ef9f280d2 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Worksheet.php +++ b/src/PhpSpreadsheet/Writer/Xls/Worksheet.php @@ -2252,7 +2252,7 @@ public function positionImage(int $col_start, int $row_start, int $x1, int $y1, * @param int $colL Column containing upper left corner of object * @param int $dxL Distance from left side of cell * @param int $rwT Row containing top left corner of object - * @param int $dyT Distance from top of cell + * @param float|int $dyT Distance from top of cell * @param int $colR Column containing lower right corner of object * @param int $dxR Distance from right of cell * @param int $rwB Row containing bottom right corner of object diff --git a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php index c431d46c6c..98b1dddb91 100644 --- a/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php +++ b/src/PhpSpreadsheet/Writer/Xlsx/StringTable.php @@ -113,7 +113,7 @@ public function writeStringTable(array $stringTable): string /** * Write Rich Text. * - * @param string $prefix Optional Namespace prefix + * @param ?string $prefix Optional Namespace prefix */ public function writeRichText(XMLWriter $objWriter, RichText $richText, ?string $prefix = null): void { From 50f6afc6ce39a02ae959c84c4e8174136dfdb829 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Wed, 3 Jan 2024 21:52:50 +0800 Subject: [PATCH 19/25] Drop redundant property initialyzer --- ..._chunks_using_a_configurable_read_filter_(version_1).php | 4 ++-- src/PhpSpreadsheet/Chart/Chart.php | 6 +++--- src/PhpSpreadsheet/Chart/DataSeries.php | 2 +- src/PhpSpreadsheet/Chart/Title.php | 2 +- src/PhpSpreadsheet/Collection/Cells.php | 2 +- src/PhpSpreadsheet/RichText/Run.php | 2 +- src/PhpSpreadsheet/Spreadsheet.php | 6 +++--- src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php | 2 +- src/PhpSpreadsheet/Worksheet/Pane.php | 4 ++-- src/PhpSpreadsheet/Worksheet/Row.php | 2 +- src/PhpSpreadsheet/Worksheet/RowCellIterator.php | 2 +- src/PhpSpreadsheet/Worksheet/Table/Column.php | 2 +- 12 files changed, 18 insertions(+), 18 deletions(-) diff --git a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php index b72aef7afc..ae8c75b547 100644 --- a/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php +++ b/samples/Reader/11_Reading_a_workbook_in_chunks_using_a_configurable_read_filter_(version_1).php @@ -13,9 +13,9 @@ /** Define a Read Filter class implementing IReadFilter */ class ChunkReadFilter implements IReadFilter { - private int $startRow = 0; + private int $startRow; - private int $endRow = 0; + private int $endRow; /** * We expect a list of the rows that we want to read to be passed into the constructor. diff --git a/src/PhpSpreadsheet/Chart/Chart.php b/src/PhpSpreadsheet/Chart/Chart.php index dded33a5ee..f514dab662 100644 --- a/src/PhpSpreadsheet/Chart/Chart.php +++ b/src/PhpSpreadsheet/Chart/Chart.php @@ -10,7 +10,7 @@ class Chart /** * Chart Name. */ - private string $name = ''; + private string $name; /** * Worksheet. @@ -45,12 +45,12 @@ class Chart /** * Plot Visible Only. */ - private bool $plotVisibleOnly = true; + private bool $plotVisibleOnly; /** * Display Blanks as. */ - private string $displayBlanksAs = DataSeries::EMPTY_AS_GAP; + private string $displayBlanksAs; /** * Chart Asix Y as. diff --git a/src/PhpSpreadsheet/Chart/DataSeries.php b/src/PhpSpreadsheet/Chart/DataSeries.php index 054f088f07..01ea64d304 100644 --- a/src/PhpSpreadsheet/Chart/DataSeries.php +++ b/src/PhpSpreadsheet/Chart/DataSeries.php @@ -62,7 +62,7 @@ class DataSeries /** * Plot Style. */ - private ?string $plotStyle = null; + private ?string $plotStyle; /** * Order of plots in Series. diff --git a/src/PhpSpreadsheet/Chart/Title.php b/src/PhpSpreadsheet/Chart/Title.php index 9797f31366..5ae1adb22a 100644 --- a/src/PhpSpreadsheet/Chart/Title.php +++ b/src/PhpSpreadsheet/Chart/Title.php @@ -11,7 +11,7 @@ class Title * * @var array|RichText|string */ - private $caption = ''; + private $caption; /** * Allow overlay of other elements? diff --git a/src/PhpSpreadsheet/Collection/Cells.php b/src/PhpSpreadsheet/Collection/Cells.php index 61efd7fdb3..20d50df459 100644 --- a/src/PhpSpreadsheet/Collection/Cells.php +++ b/src/PhpSpreadsheet/Collection/Cells.php @@ -18,7 +18,7 @@ class Cells /** * Parent worksheet. */ - private ?Worksheet $parent = null; + private ?Worksheet $parent; /** * The currently active Cell. diff --git a/src/PhpSpreadsheet/RichText/Run.php b/src/PhpSpreadsheet/RichText/Run.php index 6de9579c3c..ad0978405d 100644 --- a/src/PhpSpreadsheet/RichText/Run.php +++ b/src/PhpSpreadsheet/RichText/Run.php @@ -11,7 +11,7 @@ class Run extends TextElement implements ITextElement * * @var ?Font */ - private ?Font $font = null; + private ?Font $font; /** * Create a new Run instance. diff --git a/src/PhpSpreadsheet/Spreadsheet.php b/src/PhpSpreadsheet/Spreadsheet.php index b6831fd3ae..a921039548 100644 --- a/src/PhpSpreadsheet/Spreadsheet.php +++ b/src/PhpSpreadsheet/Spreadsheet.php @@ -51,12 +51,12 @@ class Spreadsheet implements JsonSerializable * * @var Worksheet[] */ - private array $workSheetCollection = []; + private array $workSheetCollection; /** * Calculation Engine. */ - private ?Calculation $calculationEngine = null; + private ?Calculation $calculationEngine; /** * Active sheet index. @@ -68,7 +68,7 @@ class Spreadsheet implements JsonSerializable * * @var DefinedName[] */ - private array $definedNames = []; + private array $definedNames; /** * CellXf supervisor. diff --git a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php index 2f8f86c6d1..254c807e4c 100644 --- a/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php +++ b/src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php @@ -54,7 +54,7 @@ class Column /** * Autofilter Column Index. */ - private string $columnIndex = ''; + private string $columnIndex; /** * Autofilter Column Filter Type. diff --git a/src/PhpSpreadsheet/Worksheet/Pane.php b/src/PhpSpreadsheet/Worksheet/Pane.php index 8244b1e63e..cbf523d4d3 100644 --- a/src/PhpSpreadsheet/Worksheet/Pane.php +++ b/src/PhpSpreadsheet/Worksheet/Pane.php @@ -4,9 +4,9 @@ class Pane { - private string $sqref = ''; + private string $sqref; - private string $activeCell = ''; + private string $activeCell; private string $position; diff --git a/src/PhpSpreadsheet/Worksheet/Row.php b/src/PhpSpreadsheet/Worksheet/Row.php index 7ba8608159..49d13da52a 100644 --- a/src/PhpSpreadsheet/Worksheet/Row.php +++ b/src/PhpSpreadsheet/Worksheet/Row.php @@ -9,7 +9,7 @@ class Row /** * Row index. */ - private int $rowIndex = 0; + private int $rowIndex; /** * Create a new row. diff --git a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php index 0e256e8679..4d4901c820 100644 --- a/src/PhpSpreadsheet/Worksheet/RowCellIterator.php +++ b/src/PhpSpreadsheet/Worksheet/RowCellIterator.php @@ -19,7 +19,7 @@ class RowCellIterator extends CellIterator /** * Row index. */ - private int $rowIndex = 1; + private int $rowIndex; /** * Start position. diff --git a/src/PhpSpreadsheet/Worksheet/Table/Column.php b/src/PhpSpreadsheet/Worksheet/Table/Column.php index d037f453ea..e08ffcc6da 100644 --- a/src/PhpSpreadsheet/Worksheet/Table/Column.php +++ b/src/PhpSpreadsheet/Worksheet/Table/Column.php @@ -13,7 +13,7 @@ class Column /** * Table Column Index. */ - private string $columnIndex = ''; + private string $columnIndex; /** * Show Filter Button. From 5cc1ece805cbf1190aa1da3aae20aacec63bf011 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 4 Jan 2024 11:56:46 +0800 Subject: [PATCH 20/25] PhpStan --- phpstan-baseline.neon | 240 ------------------------------------------ phpstan.neon.dist | 3 - 2 files changed, 243 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fecf4eca6f..b93d5cdda8 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10,221 +10,6 @@ parameters: count: 1 path: samples/Basic/15_Datavalidation.php - - - message: "#^Parameter \\#6 \\$color of function imagestring expects int, int\\|false given\\.$#" - count: 1 - path: samples/Basic/25_In_memory_image.php - - - - message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: samples/Basic/39_Dropdown.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\\\|false given\\.$#" - count: 2 - path: samples/Basic/39_Dropdown.php - - - - message: "#^Parameter \\#2 \\$array of function array_map expects array, array\\\\|false given\\.$#" - count: 1 - path: samples/Basic/39_Dropdown.php - - - - message: "#^Part \\$result \\(array\\|float\\|string\\) of encapsed string cannot be cast to string\\.$#" - count: 1 - path: samples/Calculations/Engineering/Convert-Online.php - - - - message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: samples/Chart/32_Chart_read_write.php - - - - message: "#^Cannot call method getPlotArea\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 3 - path: samples/Chart/32_Chart_read_write.php - - - - message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 2 - path: samples/Chart/32_Chart_read_write.php - - - - message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" - count: 1 - path: samples/Chart/32_Chart_read_write.php - - - - message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: samples/Chart/32_Chart_read_write_HTML.php - - - - message: "#^Cannot call method getPlotArea\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 3 - path: samples/Chart/32_Chart_read_write_HTML.php - - - - message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 2 - path: samples/Chart/32_Chart_read_write_HTML.php - - - - message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" - count: 1 - path: samples/Chart/32_Chart_read_write_HTML.php - - - - message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: samples/Chart/32_Chart_read_write_PDF.php - - - - message: "#^Cannot call method getPlotArea\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 3 - path: samples/Chart/32_Chart_read_write_PDF.php - - - - message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 2 - path: samples/Chart/32_Chart_read_write_PDF.php - - - - message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" - count: 1 - path: samples/Chart/32_Chart_read_write_PDF.php - - - - message: "#^Cannot call method format\\(\\) on DateTime\\|false\\.$#" - count: 5 - path: samples/Chart/33_Chart_create_line_dateaxis.php - - - - message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: samples/Chart/35_Chart_render.php - - - - message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 2 - path: samples/Chart/35_Chart_render.php - - - - message: "#^Cannot call method render\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 1 - path: samples/Chart/35_Chart_render.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\\\|false given\\.$#" - count: 1 - path: samples/Chart/35_Chart_render.php - - - - message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" - count: 1 - path: samples/Chart/35_Chart_render.php - - - - message: "#^Argument of an invalid type array\\\\|false supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: samples/Chart/35_Chart_render33.php - - - - message: "#^Call to function in_array\\(\\) with arguments string, array\\{\\} and true will always evaluate to false\\.$#" - count: 1 - path: samples/Chart/35_Chart_render33.php - - - - message: "#^Cannot call method getTitle\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 2 - path: samples/Chart/35_Chart_render33.php - - - - message: "#^Cannot call method render\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\|false\\.$#" - count: 1 - path: samples/Chart/35_Chart_render33.php - - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, array\\\\|false given\\.$#" - count: 1 - path: samples/Chart/35_Chart_render33.php - - - - message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\|PhpOffice\\\\PhpSpreadsheet\\\\RichText\\\\RichText\\|string given\\.$#" - count: 1 - path: samples/Chart/35_Chart_render33.php - - - - message: "#^Call to method save\\(\\) on an unknown class PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Pdf\\\\Mpdf2\\.$#" - count: 1 - path: samples/Pdf/21e_UnusualFont_mpdf.php - - - - message: "#^Instantiated class PhpOffice\\\\PhpSpreadsheet\\\\Writer\\\\Pdf\\\\Mpdf2 not found\\.$#" - count: 1 - path: samples/Pdf/21e_UnusualFont_mpdf.php - - - - message: "#^Call to an undefined method PhpOffice\\\\PhpSpreadsheet\\\\Reader\\\\BaseReader\\:\\:setContiguous\\(\\)\\.$#" - count: 1 - path: samples/Reader/14_Reading_a_large_CSV_file_in_chunks_to_split_across_multiple_worksheets.php - - - - message: "#^Parameter \\#6 \\$color of function imagestring expects int, int\\|false given\\.$#" - count: 1 - path: samples/Reader/20_Reader_worksheet_hyperlink_image.php - - - - message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Accounting.php - - - - message: "#^Parameter \\#2 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Accounting constructor expects int, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Accounting.php - - - - message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Currency.php - - - - message: "#^Parameter \\#2 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Currency constructor expects int, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Currency.php - - - - message: "#^Parameter \\#1 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Number constructor expects int, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Number.php - - - - message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Number.php - - - - message: "#^Parameter \\#1 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Percentage constructor expects int, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Percentage.php - - - - message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Percentage.php - - - - message: "#^Parameter \\#1 \\$decimals of class PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Wizard\\\\Scientific constructor expects int, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Scientific.php - - - - message: "#^Parameter \\#1 \\$haystack of function str_contains expects string, float\\|int\\|string given\\.$#" - count: 1 - path: samples/Wizards/NumberFormat/Scientific.php - - message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" count: 4 @@ -505,16 +290,6 @@ parameters: count: 4 path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php - - - message: "#^Cannot call method getTokenSubType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" - count: 4 - path: src/PhpSpreadsheet/Calculation/FormulaParser.php - - - - message: "#^Cannot call method getTokenType\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\FormulaToken\\|null\\.$#" - count: 8 - path: src/PhpSpreadsheet/Calculation/FormulaParser.php - - message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" count: 4 @@ -1200,16 +975,6 @@ parameters: count: 4 path: src/PhpSpreadsheet/ReferenceHelper.php - - - message: "#^Offset 2 does not exist on array\\{int, int, int, int\\}\\|array\\{int, int\\}\\.$#" - count: 1 - path: src/PhpSpreadsheet/Worksheet/Validations.php - - - - message: "#^Offset 3 does not exist on array\\{int, int, int, int\\}\\|array\\{int, int\\}\\.$#" - count: 1 - path: src/PhpSpreadsheet/Worksheet/Validations.php - - message: "#^Argument of an invalid type array\\|null supplied for foreach, only iterables are supported\\.$#" count: 3 @@ -1229,8 +994,3 @@ parameters: message: "#^Offset 0 does not exist on array\\|null\\.$#" count: 1 path: tests/PhpSpreadsheetTests/Reader/Xlsx/Issue3767Test.php - - - - message: "#^Parameter \\#2 \\$value of function ini_set expects string, int given\\.$#" - count: 1 - path: tests/bootstrap.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 979fb1d615..e7d0eb41bc 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -26,6 +26,3 @@ parameters: # Accept a bit anything for assert methods - '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~' - '~^Variable \$helper might not be defined\.$~' - - - message: '~^Cannot call method \w+\(\) on PhpOffice\\PhpSpreadsheet\\.*\|null\.$~' - path: samples/ From a3c2ca978e93a744617ce491a8a652fa111aae18 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 4 Jan 2024 12:33:06 +0800 Subject: [PATCH 21/25] Drop redundant PHPDoc --- .../Calculation/Engine/BranchPruner.php | 2 -- src/PhpSpreadsheet/Cell/Cell.php | 8 ++------ src/PhpSpreadsheet/Chart/DataSeriesValues.php | 2 -- src/PhpSpreadsheet/Reader/Xls.php | 4 ---- src/PhpSpreadsheet/Settings.php | 2 -- src/PhpSpreadsheet/Shared/Font.php | 4 +--- src/PhpSpreadsheet/Shared/OLE/PPS.php | 10 ++-------- src/PhpSpreadsheet/Shared/OLE/PPS/Root.php | 6 ------ src/PhpSpreadsheet/Shared/StringHelper.php | 6 ------ src/PhpSpreadsheet/Worksheet/PageSetup.php | 4 ---- src/PhpSpreadsheet/Worksheet/SheetView.php | 4 ---- src/PhpSpreadsheet/Writer/Pdf.php | 2 -- src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php | 2 -- src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php | 5 +---- src/PhpSpreadsheet/Writer/Xls/Parser.php | 12 +++++------- 15 files changed, 11 insertions(+), 62 deletions(-) diff --git a/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php b/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php index 1c58d04ac9..e6dbbcbdee 100644 --- a/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php +++ b/src/PhpSpreadsheet/Calculation/Engine/BranchPruner.php @@ -15,8 +15,6 @@ class BranchPruner /** * currently pending storeKey (last item of the storeKeysStack. - * - * @var ?string */ protected ?string $pendingStoreKey = null; diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index d0fc390ff7..baf6839984 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -27,10 +27,8 @@ class Cell implements Stringable /** * Value of the cell. - * - * @var mixed */ - private $value; + private mixed $value; /** * Calculated value of the cell (used for caching) @@ -63,10 +61,8 @@ class Cell implements Stringable /** * Attributes of the formula. - * - * @var mixed */ - private $formulaAttributes; + private mixed $formulaAttributes; private IgnoredErrors $ignoredErrors; diff --git a/src/PhpSpreadsheet/Chart/DataSeriesValues.php b/src/PhpSpreadsheet/Chart/DataSeriesValues.php index 22d67d52d9..ae6bf2248a 100644 --- a/src/PhpSpreadsheet/Chart/DataSeriesValues.php +++ b/src/PhpSpreadsheet/Chart/DataSeriesValues.php @@ -24,8 +24,6 @@ class DataSeriesValues extends Properties /** * Series Data Source. - * - * @var ?string */ private ?string $dataSource; diff --git a/src/PhpSpreadsheet/Reader/Xls.php b/src/PhpSpreadsheet/Reader/Xls.php index 112da2fcb8..a54105a3b4 100644 --- a/src/PhpSpreadsheet/Reader/Xls.php +++ b/src/PhpSpreadsheet/Reader/Xls.php @@ -161,15 +161,11 @@ class Xls extends BaseReader /** * Summary Information stream data. - * - * @var ?string */ private ?string $summaryInformation = null; /** * Extended Summary Information stream data. - * - * @var ?string */ private ?string $documentSummaryInformation = null; diff --git a/src/PhpSpreadsheet/Settings.php b/src/PhpSpreadsheet/Settings.php index 50daf943ef..58d75164bb 100644 --- a/src/PhpSpreadsheet/Settings.php +++ b/src/PhpSpreadsheet/Settings.php @@ -22,8 +22,6 @@ class Settings /** * Default options for libxml loader. - * - * @var ?int */ private static ?int $libXmlLoaderOptions = null; diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index a73ba5b0f4..80fe3657c1 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -328,10 +328,8 @@ public static function getTrueTypeFontPath(): string /** * Pad amount for exact in pixels; use best guess if null. - * - * @var null|float|int */ - private static $paddingAmountExact; + private static null|float|int $paddingAmountExact; /** * Set pad amount for exact in pixels; use best guess if null. diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS.php b/src/PhpSpreadsheet/Shared/OLE/PPS.php index d5f358ce8f..564fe7ec7c 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS.php @@ -61,22 +61,16 @@ class PPS /** * A timestamp. - * - * @var float|int */ - public $Time1st; + public float|int $Time1st; /** * A timestamp. - * - * @var float|int */ - public $Time2nd; + public float|int $Time2nd; /** * Starting block (small or big) for this PPS's data inside the container. - * - * @var ?int */ public ?int $startBlock = null; diff --git a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php index b554fa11ce..64de77f40a 100644 --- a/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php +++ b/src/PhpSpreadsheet/Shared/OLE/PPS/Root.php @@ -35,14 +35,8 @@ class Root extends PPS */ private $fileHandle; - /** - * @var ?int - */ private ?int $smallBlockSize = null; - /** - * @var ?int - */ private ?int $bigBlockSize = null; /** diff --git a/src/PhpSpreadsheet/Shared/StringHelper.php b/src/PhpSpreadsheet/Shared/StringHelper.php index a055fd6d95..67fba22fee 100644 --- a/src/PhpSpreadsheet/Shared/StringHelper.php +++ b/src/PhpSpreadsheet/Shared/StringHelper.php @@ -18,15 +18,11 @@ class StringHelper /** * Decimal separator. - * - * @var ?string */ private static ?string $decimalSeparator; /** * Thousands separator. - * - * @var ?string */ private static ?string $thousandsSeparator; @@ -37,8 +33,6 @@ class StringHelper /** * Is iconv extension avalable? - * - * @var ?bool */ private static ?bool $isIconvEnabled; diff --git a/src/PhpSpreadsheet/Worksheet/PageSetup.php b/src/PhpSpreadsheet/Worksheet/PageSetup.php index fb383f1417..f8c2dd1277 100644 --- a/src/PhpSpreadsheet/Worksheet/PageSetup.php +++ b/src/PhpSpreadsheet/Worksheet/PageSetup.php @@ -166,8 +166,6 @@ class PageSetup /** * Paper size. - * - * @var ?int */ private ?int $paperSize = null; @@ -238,8 +236,6 @@ class PageSetup /** * First page number. - * - * @var ?int */ private ?int $firstPageNumber = null; diff --git a/src/PhpSpreadsheet/Worksheet/SheetView.php b/src/PhpSpreadsheet/Worksheet/SheetView.php index 9e64a24bb3..9b3b334d45 100644 --- a/src/PhpSpreadsheet/Worksheet/SheetView.php +++ b/src/PhpSpreadsheet/Worksheet/SheetView.php @@ -21,8 +21,6 @@ class SheetView * ZoomScale. * * Valid values range from 10 to 400. - * - * @var ?int */ private ?int $zoomScale = 100; @@ -30,8 +28,6 @@ class SheetView * ZoomScaleNormal. * * Valid values range from 10 to 400. - * - * @var ?int */ private ?int $zoomScaleNormal = 100; diff --git a/src/PhpSpreadsheet/Writer/Pdf.php b/src/PhpSpreadsheet/Writer/Pdf.php index 16a0ac0400..17e1905084 100644 --- a/src/PhpSpreadsheet/Writer/Pdf.php +++ b/src/PhpSpreadsheet/Writer/Pdf.php @@ -26,8 +26,6 @@ abstract class Pdf extends Html /** * Paper size (Over-ride). - * - * @var ?int */ protected ?int $paperSize = null; diff --git a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php index dc269eff92..8db570d0c8 100644 --- a/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php +++ b/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php @@ -41,8 +41,6 @@ class BIFFwriter { /** * The byte order of this architecture. 0 => little endian, 1 => big endian. - * - * @var ?int */ private static ?int $byteOrder; diff --git a/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php b/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php index b38b287a24..e5a8b1deeb 100644 --- a/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php +++ b/src/PhpSpreadsheet/Writer/Xls/ConditionalHelper.php @@ -12,10 +12,7 @@ class ConditionalHelper */ protected Parser $parser; - /** - * @var mixed - */ - protected $condition; + protected mixed $condition; protected string $cellRange; diff --git a/src/PhpSpreadsheet/Writer/Xls/Parser.php b/src/PhpSpreadsheet/Writer/Xls/Parser.php index ca87f541bc..3b078b4344 100644 --- a/src/PhpSpreadsheet/Writer/Xls/Parser.php +++ b/src/PhpSpreadsheet/Writer/Xls/Parser.php @@ -69,10 +69,8 @@ class Parser /** * The parse tree to be generated. - * - * @var array|string */ - public $parseTree; + public array|string $parseTree; /** * Array of external sheets. @@ -1127,9 +1125,9 @@ public function parse(string $formula): bool * It parses a condition. It assumes the following rule: * Cond -> Expr [(">" | "<") Expr]. * - * @return mixed The parsed ptg'd tree on success + * @return array The parsed ptg'd tree on success */ - private function condition(): mixed + private function condition(): array { $result = $this->expression(); if ($this->currentToken == '<') { @@ -1169,9 +1167,9 @@ private function condition(): mixed * -> "+" Term : Positive value * -> Error code. * - * @return mixed The parsed ptg'd tree on success + * @return array The parsed ptg'd tree on success */ - private function expression(): mixed + private function expression(): array { // If it's a string return a string node if (preg_match('/"([^"]|""){0,255}"/', $this->currentToken)) { From 83f71298ad78efe6243c10e0af90433a83c4b4c6 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 4 Jan 2024 12:34:47 +0800 Subject: [PATCH 22/25] Also forbid PHPDoc without a variable name --- bin/check-phpdoc-types | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/check-phpdoc-types b/bin/check-phpdoc-types index 43809f6b9f..7f69315faa 100755 --- a/bin/check-phpdoc-types +++ b/bin/check-phpdoc-types @@ -11,7 +11,7 @@ function checkPhpDocTypes(): void { $content = `git diff --cached` ?? `git diff` ?? `git show HEAD`; - preg_match_all('~^\+ +\* @(param|var) (mixed|string|int|float|bool|null|array|\?|\|)+ \$\w+$~m', $content, $parameters); + preg_match_all('~^\+ +\* @(param|var) (mixed|string|int|float|bool|null|array|\?|\|)+( \$\w+)?$~m', $content, $parameters); preg_match_all('~^\+ +\* @return (mixed|string|int|float|bool|null|array|void|\?|\|)+$~m', $content, $returns); $errors = [ From 332f6418e4d5314fff528f2a319801358582fa38 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 4 Jan 2024 12:50:52 +0800 Subject: [PATCH 23/25] Allow usage of getters before setters --- src/PhpSpreadsheet/Cell/Cell.php | 2 +- src/PhpSpreadsheet/Shared/Font.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PhpSpreadsheet/Cell/Cell.php b/src/PhpSpreadsheet/Cell/Cell.php index baf6839984..987e1a361e 100644 --- a/src/PhpSpreadsheet/Cell/Cell.php +++ b/src/PhpSpreadsheet/Cell/Cell.php @@ -62,7 +62,7 @@ class Cell implements Stringable /** * Attributes of the formula. */ - private mixed $formulaAttributes; + private mixed $formulaAttributes = null; private IgnoredErrors $ignoredErrors; diff --git a/src/PhpSpreadsheet/Shared/Font.php b/src/PhpSpreadsheet/Shared/Font.php index 80fe3657c1..788d725397 100644 --- a/src/PhpSpreadsheet/Shared/Font.php +++ b/src/PhpSpreadsheet/Shared/Font.php @@ -329,7 +329,7 @@ public static function getTrueTypeFontPath(): string /** * Pad amount for exact in pixels; use best guess if null. */ - private static null|float|int $paddingAmountExact; + private static null|float|int $paddingAmountExact = null; /** * Set pad amount for exact in pixels; use best guess if null. From b22fde228157b384d03d9d9f5b884bacde8d9bca Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 4 Jan 2024 13:06:59 +0800 Subject: [PATCH 24/25] Upgrade QA tools --- phpstan-baseline.neon | 5 +++++ src/PhpSpreadsheet/Helper/Sample.php | 2 +- src/PhpSpreadsheet/Writer/Xls.php | 10 +++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b93d5cdda8..24f49af632 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10,6 +10,11 @@ parameters: count: 1 path: samples/Basic/15_Datavalidation.php + - + message: "#^Strict comparison using \\=\\=\\= between mixed and null will always evaluate to false\\.$#" + count: 1 + path: src/PhpSpreadsheet/Calculation/Calculation.php + - message: "#^Cannot call method arguments\\(\\) on PhpOffice\\\\PhpSpreadsheet\\\\Calculation\\\\Engine\\\\ArrayArgumentHelper\\|null\\.$#" count: 4 diff --git a/src/PhpSpreadsheet/Helper/Sample.php b/src/PhpSpreadsheet/Helper/Sample.php index b116ca99bc..4e7728792c 100644 --- a/src/PhpSpreadsheet/Helper/Sample.php +++ b/src/PhpSpreadsheet/Helper/Sample.php @@ -188,7 +188,7 @@ public function getTemporaryFilename(string $extension = 'xlsx'): string public function log(string $message): void { $eol = $this->isCli() ? PHP_EOL : '
    '; - echo($this->isCli() ? date('H:i:s ') : '') . $message . $eol; + echo ($this->isCli() ? date('H:i:s ') : '') . $message . $eol; } /** diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 8b1cdb1af8..2bc1678633 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -730,12 +730,12 @@ private function writeDocumentSummaryInformation(): string $dataSection_Content .= $dataProp['data']['data']; $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); - /* Condition below can never be true - } elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - $dataSection_Content .= $dataProp['data']['data']; + /* Condition below can never be true + } elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) + $dataSection_Content .= $dataProp['data']['data']; - $dataSection_Content_Offset += 4 + 8; - */ + $dataSection_Content_Offset += 4 + 8; + */ } else { $dataSection_Content .= $dataProp['data']['data']; From 76c5b98b8fd4e2547ec6757b565153b03315f7b0 Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Thu, 4 Jan 2024 13:08:26 +0800 Subject: [PATCH 25/25] Drop commented code --- src/PhpSpreadsheet/Writer/Xls.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/PhpSpreadsheet/Writer/Xls.php b/src/PhpSpreadsheet/Writer/Xls.php index 2bc1678633..4a2b5ed9fa 100644 --- a/src/PhpSpreadsheet/Writer/Xls.php +++ b/src/PhpSpreadsheet/Writer/Xls.php @@ -730,12 +730,6 @@ private function writeDocumentSummaryInformation(): string $dataSection_Content .= $dataProp['data']['data']; $dataSection_Content_Offset += 4 + 4 + strlen($dataProp['data']['data']); - /* Condition below can never be true - } elseif ($dataProp['type']['data'] == 0x40) { // Filetime (64-bit value representing the number of 100-nanosecond intervals since January 1, 1601) - $dataSection_Content .= $dataProp['data']['data']; - - $dataSection_Content_Offset += 4 + 8; - */ } else { $dataSection_Content .= $dataProp['data']['data'];