Phpstan and Php8 Phase 1 (#2428)

As configured, Phpstan running under Php7 reports no errors. However, running under Php8, it reports 218 (!) errors. The vast majority of these are due to two reasons:
- renaming parameters in Php builtin functions in preparation for named parameters.
- using the new class `GdImage` rather than type `resource` as the argument type for many image-based functions.

Regardless of the cause, this will be a problem sooner or later. This PR is an attempt to get ahead of that problem. It tweaks only the Phpstan configuration files, without changing any PhpSpreadsheet code. Php7 continues to report no errors, and the number of errors for Php8 is reduced to 13. Although those 13 can also be tweaked, there is a case to be made that code corrections might be better in at least some of those instances. I will attend to those as one or more PRs after this one.

Because this involves no changes to code, and because Phpstan baseline is a common cause of merge difficulties, I will probably merge this in a day or two, more quickly than I customarily do.
This commit is contained in:
oleibman 2021-12-03 07:37:51 -08:00 committed by GitHub
parent 580c741c8e
commit f0791aec7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 124 additions and 88 deletions

View File

@ -221,27 +221,27 @@ parameters:
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Parameter \\#1 \\$str of function preg_quote expects string, int\\|string given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function preg_quote expects string, int\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Parameter \\#1 \\$str of function strtoupper expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function strtoupper expects string, mixed given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, int\\|string given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, int\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 3 count: 3
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, null given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, null given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Calculation/Calculation.php path: src/PhpSpreadsheet/Calculation/Calculation.php
@ -516,12 +516,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php path: src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php
- -
message: "#^Parameter \\#1 \\$input of function array_keys expects array, mixed given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_keys expects array, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php path: src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php
- -
message: "#^Parameter \\#1 \\$str of function strtoupper expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function strtoupper expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php path: src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php
@ -556,7 +556,7 @@ parameters:
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Date.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
@ -566,7 +566,7 @@ parameters:
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php path: src/PhpSpreadsheet/Calculation/DateTimeExcel/DateValue.php
- -
message: "#^Parameter \\#1 \\$str of function strtoupper expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function strtoupper expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Difference.php
@ -576,12 +576,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php path: src/PhpSpreadsheet/Calculation/DateTimeExcel/Helpers.php
- -
message: "#^Parameter \\#1 \\$x of function fmod expects float, mixed given\\.$#" message: "#^Parameter \\#1 \\$(x|num1) of function fmod expects float, mixed given\\.$#"
count: 3 count: 3
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeParts.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php path: src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php
@ -756,12 +756,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php
- -
message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\<0, 281474976710655\\>\\|string given\\.$#" message: "#^Parameter \\#1 \\$num(ber)? of function floor expects float(\\|int)?, float\\|int\\<0, 281474976710655\\>\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php
- -
message: "#^Parameter \\#1 \\$number of function floor expects float, float\\|int\\|string given\\.$#" message: "#^Parameter \\#1 \\$num(ber)? of function floor expects float(\\|int)?, float\\|int\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php path: src/PhpSpreadsheet/Calculation/Engineering/BitWise.php
@ -986,12 +986,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php
- -
message: "#^Parameter \\#1 \\$number of function floor expects float, mixed given\\.$#" message: "#^Parameter \\#1 \\$num(ber)? of function floor expects float(\\|int)?, mixed given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php
- -
message: "#^Parameter \\#1 \\$x of function fmod expects float, mixed given\\.$#" message: "#^Parameter \\#1 \\$(x|num1) of function fmod expects float, mixed given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php path: src/PhpSpreadsheet/Calculation/Financial/Dollar.php
@ -1276,12 +1276,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/LookupRef/Helpers.php path: src/PhpSpreadsheet/Calculation/LookupRef/Helpers.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/Helpers.php path: src/PhpSpreadsheet/Calculation/LookupRef/Helpers.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php path: src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php
@ -1391,7 +1391,7 @@ parameters:
path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php
@ -1411,17 +1411,17 @@ parameters:
path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php
- -
message: "#^Parameter \\#1 \\$low of function range expects float\\|int\\|string, string\\|null given\\.$#" message: "#^Parameter \\#1 \\$(low|start) of function range expects float\\|int\\|string, string\\|null given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php
- -
message: "#^Parameter \\#2 \\$high of function range expects float\\|int\\|string, string\\|null given\\.$#" message: "#^Parameter \\#2 \\$(high|end) of function range expects float\\|int\\|string, string\\|null given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, mixed given\\.$#"
count: 3 count: 3
path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php path: src/PhpSpreadsheet/Calculation/LookupRef/RowColumnInformation.php
@ -1486,12 +1486,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
- -
message: "#^Parameter \\#1 \\$array_arg of function uasort expects array, mixed given\\.$#" message: "#^Parameter \\#1 \\$array(_arg)? of function uasort expects array, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
- -
message: "#^Parameter \\#1 \\$input of function array_keys expects array, mixed given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_keys expects array, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
@ -1561,12 +1561,12 @@ parameters:
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
- -
message: "#^Parameter \\#1 \\$input of function array_filter expects array, mixed given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_filter expects array, mixed given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, mixed given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
@ -1766,7 +1766,7 @@ parameters:
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php
- -
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" message: "#^Parameter \\#1 \\$(var|value) of function count expects array\\|Countable, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php
@ -1931,7 +1931,7 @@ parameters:
path: src/PhpSpreadsheet/Calculation/TextData.php path: src/PhpSpreadsheet/Calculation/TextData.php
- -
message: "#^Parameter \\#1 \\$glue of function implode expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$(glue|separator) of function implode expects (array\\|)?string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/TextData/Concatenate.php path: src/PhpSpreadsheet/Calculation/TextData/Concatenate.php
@ -1961,7 +1961,7 @@ parameters:
path: src/PhpSpreadsheet/Calculation/TextData/Format.php path: src/PhpSpreadsheet/Calculation/TextData/Format.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Calculation/TextData/Format.php path: src/PhpSpreadsheet/Calculation/TextData/Format.php
@ -2136,17 +2136,17 @@ parameters:
path: src/PhpSpreadsheet/Cell/Coordinate.php path: src/PhpSpreadsheet/Cell/Coordinate.php
- -
message: "#^Parameter \\#1 \\$input of function array_chunk expects array, array\\<int, string\\>\\|false given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_chunk expects array, array\\<int, string\\>\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Cell/Coordinate.php path: src/PhpSpreadsheet/Cell/Coordinate.php
- -
message: "#^Parameter \\#1 \\$str of function strtoupper expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function strtoupper expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Cell/Coordinate.php path: src/PhpSpreadsheet/Cell/Coordinate.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, array\\<int, string\\>\\|string given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, array\\<int, string\\>\\|string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Cell/Coordinate.php path: src/PhpSpreadsheet/Cell/Coordinate.php
@ -2171,7 +2171,7 @@ parameters:
path: src/PhpSpreadsheet/Cell/DataType.php path: src/PhpSpreadsheet/Cell/DataType.php
- -
message: "#^Parameter \\#1 \\$str of function strtolower expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function strtolower expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Cell/DataValidator.php path: src/PhpSpreadsheet/Cell/DataValidator.php
@ -2181,7 +2181,7 @@ parameters:
path: src/PhpSpreadsheet/Cell/DefaultValueBinder.php path: src/PhpSpreadsheet/Cell/DefaultValueBinder.php
- -
message: "#^Parameter \\#1 \\$str of function ltrim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function ltrim expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Cell/DefaultValueBinder.php path: src/PhpSpreadsheet/Cell/DefaultValueBinder.php
@ -2466,17 +2466,17 @@ parameters:
path: src/PhpSpreadsheet/Chart/DataSeriesValues.php path: src/PhpSpreadsheet/Chart/DataSeriesValues.php
- -
message: "#^Parameter \\#1 \\$input of function array_values expects array, mixed given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_values expects array, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Chart/DataSeriesValues.php path: src/PhpSpreadsheet/Chart/DataSeriesValues.php
- -
message: "#^Parameter \\#1 \\$stack of function array_shift expects array, mixed given\\.$#" message: "#^Parameter \\#1 \\$(stack|array) of function array_shift expects array, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Chart/DataSeriesValues.php path: src/PhpSpreadsheet/Chart/DataSeriesValues.php
- -
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" message: "#^Parameter \\#1 \\$(var|value) of function count expects array\\|Countable, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Chart/DataSeriesValues.php path: src/PhpSpreadsheet/Chart/DataSeriesValues.php
@ -3046,7 +3046,7 @@ parameters:
path: src/PhpSpreadsheet/Helper/Html.php path: src/PhpSpreadsheet/Helper/Html.php
- -
message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, array\\{\\$this\\(PhpOffice\\\\PhpSpreadsheet\\\\Helper\\\\Html\\), mixed\\} given\\.$#" message: "#^Parameter \\#1 \\$(function|callback) of function call_user_func expects callable\\(\\)\\: mixed, array\\{\\$this\\(PhpOffice\\\\PhpSpreadsheet\\\\Helper\\\\Html\\), mixed\\} given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Helper/Html.php path: src/PhpSpreadsheet/Helper/Html.php
@ -3211,7 +3211,7 @@ parameters:
path: src/PhpSpreadsheet/Reader/Gnumeric.php path: src/PhpSpreadsheet/Reader/Gnumeric.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Gnumeric.php path: src/PhpSpreadsheet/Reader/Gnumeric.php
@ -3561,7 +3561,7 @@ parameters:
path: src/PhpSpreadsheet/Reader/Xls.php path: src/PhpSpreadsheet/Reader/Xls.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Reader/Xls.php path: src/PhpSpreadsheet/Reader/Xls.php
@ -3571,7 +3571,7 @@ parameters:
path: src/PhpSpreadsheet/Reader/Xls.php path: src/PhpSpreadsheet/Reader/Xls.php
- -
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, mixed given\\.$#" message: "#^Parameter \\#1 \\$(var|value) of function count expects array\\|Countable, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xls.php path: src/PhpSpreadsheet/Reader/Xls.php
@ -3701,7 +3701,7 @@ parameters:
path: src/PhpSpreadsheet/Reader/Xls/MD5.php path: src/PhpSpreadsheet/Reader/Xls/MD5.php
- -
message: "#^Parameter \\#1 \\$input of function array_values expects array, array\\|false given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_values expects array, array\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xls/MD5.php path: src/PhpSpreadsheet/Reader/Xls/MD5.php
@ -3991,7 +3991,7 @@ parameters:
path: src/PhpSpreadsheet/Reader/Xlsx.php path: src/PhpSpreadsheet/Reader/Xlsx.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Reader/Xlsx.php path: src/PhpSpreadsheet/Reader/Xlsx.php
@ -4611,37 +4611,37 @@ parameters:
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Drawing\\:\\:imagecreatefrombmp\\(\\) should return GdImage\\|resource but returns resource\\|false\\.$#" message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Drawing\\:\\:imagecreatefrombmp\\(\\) should return GdImage\\|resource but returns (GdImage|resource)\\|false\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$fp of function feof expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$(fp|stream) of function feof expects resource, resource\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$fp of function fread expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$(fp|stream) of function fread expects resource, resource\\|false given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagecolorallocate expects (GdImage|resource), (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$im of function imagesetpixel expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagesetpixel expects (GdImage|resource), (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#1 \\$x_size of function imagecreatetruecolor expects int, float\\|int given\\.$#" message: "#^Parameter \\#1 \\$(x_size|width) of function imagecreatetruecolor expects int, float\\|int given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#2 \\$data of function unpack expects string, string\\|false given\\.$#" message: "#^Parameter \\#2 \\$(data|string) of function unpack expects string, string\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
@ -4651,7 +4651,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#2 \\$y_size of function imagecreatetruecolor expects int, float\\|int given\\.$#" message: "#^Parameter \\#2 \\$(y_size|height) of function imagecreatetruecolor expects int, float\\|int given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
@ -4671,7 +4671,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
- -
message: "#^Parameter \\#4 \\$col of function imagesetpixel expects int, int\\|false given\\.$#" message: "#^Parameter \\#4 \\$col(or)? of function imagesetpixel expects int, int\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Drawing.php path: src/PhpSpreadsheet/Shared/Drawing.php
@ -4881,7 +4881,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/JAMA/Matrix.php path: src/PhpSpreadsheet/Shared/JAMA/Matrix.php
- -
message: "#^Parameter \\#1 \\$str of function trim expects string, float\\|int given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function trim expects string, float\\|int given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/JAMA/Matrix.php path: src/PhpSpreadsheet/Shared/JAMA/Matrix.php
@ -4986,7 +4986,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/OLE.php path: src/PhpSpreadsheet/Shared/OLE.php
- -
message: "#^Parameter \\#2 \\$data of function unpack expects string, string\\|false given\\.$#" message: "#^Parameter \\#2 \\$(data|string) of function unpack expects string, string\\|false given\\.$#"
count: 3 count: 3
path: src/PhpSpreadsheet/Shared/OLE.php path: src/PhpSpreadsheet/Shared/OLE.php
@ -5026,7 +5026,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/OLE.php path: src/PhpSpreadsheet/Shared/OLE.php
- -
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, string given\\.$#" message: "#^Parameter \\#1 \\$(var|value) of function count expects array\\|Countable, string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php path: src/PhpSpreadsheet/Shared/OLE/ChainedBlockStream.php
@ -5396,7 +5396,7 @@ parameters:
path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php
- -
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, float given\\.$#" message: "#^Parameter \\#2 \\.\\.\\.\\$(args|arrays) of function array_merge expects array, float given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php
@ -5811,7 +5811,7 @@ parameters:
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, string\\|null given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
@ -6071,7 +6071,7 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/PageSetup.php path: src/PhpSpreadsheet/Worksheet/PageSetup.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, string\\|null given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, string\\|null given\\.$#"
count: 5 count: 5
path: src/PhpSpreadsheet/Worksheet/PageSetup.php path: src/PhpSpreadsheet/Worksheet/PageSetup.php
@ -6176,7 +6176,7 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
- -
message: "#^Parameter \\#1 \\$input of function array_splice expects array, ArrayObject\\<int, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\> given\\.$#" message: "#^Parameter \\#1 \\$(input|string|array) of function array_splice expects array, ArrayObject\\<int, PhpOffice\\\\PhpSpreadsheet\\\\Chart\\\\Chart\\> given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
@ -6201,7 +6201,7 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
- -
message: "#^Parameter \\#1 \\$str of function strtoupper expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function strtoupper expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
@ -6216,7 +6216,7 @@ parameters:
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
- -
message: "#^Parameter \\#2 \\$start of function substr expects int, int\\<0, max\\>\\|false given\\.$#" message: "#^Parameter \\#2 \\$(start|offset) of function substr expects int, int(\\<0, max\\>)?\\|false given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Worksheet/Worksheet.php path: src/PhpSpreadsheet/Worksheet/Worksheet.php
@ -6546,12 +6546,12 @@ parameters:
path: src/PhpSpreadsheet/Writer/Html.php path: src/PhpSpreadsheet/Writer/Html.php
- -
message: "#^Parameter \\#1 \\$im of function imagepng expects resource, GdImage\\|resource given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagepng expects (GdImage|resource), GdImage\\|resource given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Html.php path: src/PhpSpreadsheet/Writer/Html.php
- -
message: "#^Parameter \\#1 \\$str of function base64_encode expects string, string\\|false given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function base64_encode expects string, string\\|false given\\.$#"
count: 2 count: 2
path: src/PhpSpreadsheet/Writer/Html.php path: src/PhpSpreadsheet/Writer/Html.php
@ -6701,12 +6701,12 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls.php path: src/PhpSpreadsheet/Writer/Xls.php
- -
message: "#^Parameter \\#1 \\$im of function imagepng expects resource, GdImage\\|resource given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagepng expects (GdImage|resource), GdImage\\|resource given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls.php path: src/PhpSpreadsheet/Writer/Xls.php
- -
message: "#^Parameter \\#1 \\$im of function imagepng expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagepng expects (GdImage|resource), (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls.php path: src/PhpSpreadsheet/Writer/Xls.php
@ -6841,7 +6841,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls/Parser.php path: src/PhpSpreadsheet/Writer/Xls/Parser.php
- -
message: "#^Parameter \\#1 \\$str of function strrev expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function strrev expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Parser.php path: src/PhpSpreadsheet/Writer/Xls/Parser.php
@ -6861,7 +6861,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls/Parser.php path: src/PhpSpreadsheet/Writer/Xls/Parser.php
- -
message: "#^Parameter \\#2 \\$str of function explode expects string, mixed given\\.$#" message: "#^Parameter \\#2 \\$str(ing)? of function explode expects string, mixed given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Parser.php path: src/PhpSpreadsheet/Writer/Xls/Parser.php
@ -6991,7 +6991,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
- -
message: "#^Parameter \\#1 \\$im of function imagecolorat expects resource, GdImage\\|resource given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagecolorat expects (GdImage|resource), GdImage\\|resource given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
@ -7006,12 +7006,12 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
- -
message: "#^Parameter \\#2 \\$col of function imagecolorsforindex expects int, int\\|false given\\.$#" message: "#^Parameter \\#2 \\$col(or)? of function imagecolorsforindex expects int, int\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
- -
message: "#^Parameter \\#2 \\$data of function unpack expects string, string\\|false given\\.$#" message: "#^Parameter \\#2 \\$(data|string) of function unpack expects string, string\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
@ -7021,7 +7021,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
- -
message: "#^Parameter \\#2 \\$pieces of function implode expects array, array\\<int, string\\>\\|false given\\.$#" message: "#^Parameter \\#2 \\$(pieces|array) of function implode expects array(\\|null)?, array\\<int, string\\>\\|false given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php path: src/PhpSpreadsheet/Writer/Xls/Worksheet.php
@ -7126,7 +7126,7 @@ parameters:
path: src/PhpSpreadsheet/Writer/Xlsx.php path: src/PhpSpreadsheet/Writer/Xlsx.php
- -
message: "#^Parameter \\#1 \\$function of function call_user_func expects callable\\(\\)\\: mixed, string given\\.$#" message: "#^Parameter \\#1 \\$(function|callback) of function call_user_func expects callable\\(\\)\\: mixed, string given\\.$#"
count: 1 count: 1
path: src/PhpSpreadsheet/Writer/Xlsx.php path: src/PhpSpreadsheet/Writer/Xlsx.php
@ -8466,22 +8466,22 @@ parameters:
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
- -
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagecolorallocate expects (GdImage|resource), (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
- -
message: "#^Parameter \\#1 \\$im of function imagestring expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagestring expects (GdImage|resource), (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
- -
message: "#^Parameter \\#1 \\$value of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\MemoryDrawing\\:\\:setImageResource\\(\\) expects GdImage\\|resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$value of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\MemoryDrawing\\:\\:setImageResource\\(\\) expects GdImage\\|resource, (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
- -
message: "#^Parameter \\#6 \\$col of function imagestring expects int, int\\|false given\\.$#" message: "#^Parameter \\#6 \\$col(or)? of function imagestring expects int, int\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php path: tests/PhpSpreadsheetTests/Functional/DrawingImageHyperlinkTest.php
@ -8511,7 +8511,7 @@ parameters:
path: tests/PhpSpreadsheetTests/Functional/StreamTest.php path: tests/PhpSpreadsheetTests/Functional/StreamTest.php
- -
message: "#^Parameter \\#1 \\$fp of function fstat expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$(fp|stream) of function fstat expects resource, resource\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Functional/StreamTest.php path: tests/PhpSpreadsheetTests/Functional/StreamTest.php
@ -8586,7 +8586,7 @@ parameters:
path: tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php path: tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php
- -
message: "#^Parameter \\#1 \\$str of function strrev expects string, mixed given\\.$#" message: "#^Parameter \\#1 \\$str(ing)? of function strrev expects string, mixed given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php path: tests/PhpSpreadsheetTests/Reader/Security/XmlScannerTest.php
@ -8821,22 +8821,22 @@ parameters:
path: tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php path: tests/PhpSpreadsheetTests/Worksheet/AutoFilter/DateGroupTest.php
- -
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagecolorallocate expects (resource|GdImage), (resource|GdImage)\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
- -
message: "#^Parameter \\#1 \\$im of function imagestring expects resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$im(age)? of function imagestring expects (resource|GdImage), (resource|GdImage)\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
- -
message: "#^Parameter \\#1 \\$value of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\MemoryDrawing\\:\\:setImageResource\\(\\) expects GdImage\\|resource, resource\\|false given\\.$#" message: "#^Parameter \\#1 \\$value of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\MemoryDrawing\\:\\:setImageResource\\(\\) expects GdImage\\|resource, (GdImage|resource)\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
- -
message: "#^Parameter \\#6 \\$col of function imagestring expects int, int\\|false given\\.$#" message: "#^Parameter \\#6 \\$col(or)? of function imagestring expects int, int\\|false given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php path: tests/PhpSpreadsheetTests/Worksheet/DrawingTest.php
@ -8931,7 +8931,7 @@ parameters:
path: tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php path: tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php
- -
message: "#^Parameter \\#1 \\$input of function array_keys expects array, mixed given\\.$#" message: "#^Parameter \\#1 \\$(input|array) of function array_keys expects array, mixed given\\.$#"
count: 1 count: 1
path: tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php path: tests/PhpSpreadsheetTests/Writer/Xls/WorkbookTest.php

39
phpstan-conditional.php Normal file
View File

@ -0,0 +1,39 @@
<?php
$config = [];
if (PHP_VERSION_ID < 80000) {
// Change of signature in PHP 8.0
$config['parameters']['ignoreErrors'][] = [
'message' => '~^Method .* has invalid return type GdImage\.$~',
'path' => __DIR__ . '/src/PhpSpreadsheet/Shared/Drawing.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '~^Property .* has unknown class GdImage as its type\.$~',
'path' => __DIR__ . '/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '~^Method .* has invalid return type GdImage\.$~',
'path' => __DIR__ . '/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '~^Parameter .* of method .* has invalid type GdImage\.$~',
'path' => __DIR__ . '/src/PhpSpreadsheet/Worksheet/MemoryDrawing.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '~^Class GdImage not found\.$~',
'path' => __DIR__ . '/src/PhpSpreadsheet/Writer/Xls/Worksheet.php',
'count' => 1,
];
$config['parameters']['ignoreErrors'][] = [
'message' => '~^Parameter .* of method .* has invalid type GdImage\.$~',
'path' => __DIR__ . '/src/PhpSpreadsheet/Writer/Xls/Worksheet.php',
'count' => 1,
];
}
return $config;

View File

@ -1,5 +1,6 @@
includes: includes:
- phpstan-baseline.neon - phpstan-baseline.neon
- phpstan-conditional.php
- vendor/phpstan/phpstan-phpunit/extension.neon - vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon - vendor/phpstan/phpstan-phpunit/rules.neon
@ -12,12 +13,8 @@ parameters:
processTimeout: 300.0 processTimeout: 300.0
checkMissingIterableValueType: false checkMissingIterableValueType: false
ignoreErrors: ignoreErrors:
- '~^Class GdImage not found\.$~' - '~^Parameter \#1 \$im(age)? of function (imagedestroy|imageistruecolor|imagealphablending|imagesavealpha|imagecolortransparent|imagecolorsforindex|imagesavealpha|imagesx|imagesy) expects (GdImage|resource), GdImage\|resource given\.$~'
- '~^Method .* has invalid return type GdImage\.$~' - '~^Parameter \#2 \$src_im(age)? of function imagecopy expects (GdImage|resource), GdImage\|resource given\.$~'
- '~^Property .* has unknown class GdImage as its type\.$~'
- '~^Parameter .* of method .* has invalid type GdImage\.$~'
- '~^Parameter \#1 \$im of function (imagedestroy|imageistruecolor|imagealphablending|imagesavealpha|imagecolortransparent|imagecolorsforindex|imagesavealpha|imagesx|imagesy) expects resource, GdImage\|resource given\.$~'
- '~^Parameter \#2 \$src_im of function imagecopy expects resource, GdImage\|resource given\.$~'
# Accept a bit anything for assert methods # Accept a bit anything for assert methods
- '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~' - '~^Parameter \#2 .* of static method PHPUnit\\Framework\\Assert\:\:assert\w+\(\) expects .*, .* given\.$~'
- '~^Method PhpOffice\\PhpSpreadsheetTests\\.*\:\:test.*\(\) has parameter \$args with no type specified\.$~' - '~^Method PhpOffice\\PhpSpreadsheetTests\\.*\:\:test.*\(\) has parameter \$args with no type specified\.$~'