From c303df24081430dccdcdd294a50a4330a345b512 Mon Sep 17 00:00:00 2001
From: Adrien Crivelli <adrien.crivelli@gmail.com>
Date: Sat, 9 Dec 2023 16:30:22 +0100
Subject: [PATCH] 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\\<int, string\\>\\|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\\<int, string\\>\\|false given\\.$#"
+			count: 2
+			path: samples/Basic/39_Dropdown.php
+
+		-
+			message: "#^Parameter \\#2 \\$array of function array_map expects array, array\\<int, string\\>\\|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\\<int, string\\>\\|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\\<int, string\\>\\|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\\<int, string\\>\\|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\\<int, string\\>\\|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\\<int, string\\>\\|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\\<int, string\\>\\|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\\<int, string\\>\\|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
         </body>
         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<string, null|string>
      */
-    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