Skip to content

Commit

Permalink
Type all interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Dec 9, 2023
1 parent 92b5ab8 commit bdbb0a4
Show file tree
Hide file tree
Showing 50 changed files with 397 additions and 227 deletions.
225 changes: 225 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ includes:
parameters:
level: 8
paths:
- samples/
- src/
- tests/
excludePaths:
Expand All @@ -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/
2 changes: 1 addition & 1 deletion samples/Autofilter/10_Autofilter_selection_2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion samples/Basic/24_Readfilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 1 addition & 5 deletions samples/Basic/39_Dropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions samples/Chart/33_Chart_create_line_dateaxis.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
null, // plotDirection
null, // smooth line
false, // smooth line
DataSeries::STYLE_SMOOTHMARKER // plotStyle
);

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/Chart/33_Chart_create_radar.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
null, // plotDirection
null, // smooth line
false, // smooth line
DataSeries::STYLE_MARKER // plotStyle
);

Expand Down
2 changes: 1 addition & 1 deletion samples/Chart/33_Chart_create_scatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
null, // plotDirection
null, // smooth line
false, // smooth line
DataSeries::STYLE_LINEMARKER // plotStyle
);

Expand Down
4 changes: 2 additions & 2 deletions samples/Chart/33_Chart_create_scatter2.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/Chart/33_Chart_create_scatter4.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
null, // plotDirection
null, // smooth line
false, // smooth line
DataSeries::STYLE_LINEMARKER // plotStyle
);

Expand Down
6 changes: 3 additions & 3 deletions samples/Chart/33_Chart_create_scatter5_trendlines.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
null, // plotDirection
null, // smooth line
false, // smooth line
DataSeries::STYLE_SMOOTHMARKER // plotStyle
);

Expand Down Expand Up @@ -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
Expand All @@ -231,7 +231,7 @@
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
null, // plotDirection
null, // smooth line
false, // smooth line
DataSeries::STYLE_SMOOTHMARKER // plotStyle
);

Expand Down
Loading

0 comments on commit bdbb0a4

Please sign in to comment.