Changes Required For Phpstan 1.4.5 (#2549)
Dependabot pushed Phpstan 1.4.4 and then 1.4.5 (PR #2548). Because of some incompatible error messages between the current and new release, changes are required in order to be compatible with current and new releases.
This commit is contained in:
parent
454c01be51
commit
59ae5e20b5
|
|
@ -66,7 +66,7 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Calculation/Calculation.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset int on mixed\\.$#"
|
||||
message: "#^Cannot access offset int(<0, max>)? on mixed\\.$#"
|
||||
count: 16
|
||||
path: src/PhpSpreadsheet/Calculation/Calculation.php
|
||||
|
||||
|
|
@ -1461,7 +1461,7 @@ parameters:
|
|||
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(<T>)?, mixed given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
|
||||
|
||||
|
|
@ -1471,7 +1471,7 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$callback of function uasort expects callable\\(mixed, mixed\\)\\: int, array\\{'self', 'vlookupSort'\\} given\\.$#"
|
||||
message: "#^Parameter \\#2 \\$callback of function uasort expects callable\\((mixed|T), (mixed|T)\\)\\: int, array\\{'self', 'vlookupSort'\\} given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
|
||||
|
||||
|
|
@ -5205,11 +5205,6 @@ parameters:
|
|||
count: 1
|
||||
path: src/PhpSpreadsheet/Shared/StringHelper.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:\\$isIconvEnabled \\(bool\\) in isset\\(\\) is not nullable\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Shared/StringHelper.php
|
||||
|
||||
-
|
||||
message: "#^Static property PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:\\$thousandsSeparator \\(string\\) in isset\\(\\) is not nullable\\.$#"
|
||||
count: 1
|
||||
|
|
@ -5365,11 +5360,6 @@ parameters:
|
|||
count: 1
|
||||
path: src/PhpSpreadsheet/Shared/Trend/PolynomialBestFit.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\Trend\\\\BestFit\\>\\) does not accept object\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Shared/Trend/Trend.php
|
||||
|
||||
-
|
||||
message: "#^Call to an undefined method object\\:\\:getGoodnessOfFit\\(\\)\\.$#"
|
||||
count: 1
|
||||
|
|
@ -5705,16 +5695,6 @@ parameters:
|
|||
count: 1
|
||||
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(\\)\\: mixed, array\\{'self', 'escapeQuotesCallback'\\} given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(\\)\\: mixed, array\\{'self', 'setLowercaseCallback'\\} given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$replace of function str_replace expects array\\|string, int given\\.$#"
|
||||
count: 1
|
||||
|
|
@ -5730,11 +5710,6 @@ parameters:
|
|||
count: 1
|
||||
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#3 \\$subject of function preg_replace_callback expects array\\|string, string\\|null given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
|
||||
|
||||
-
|
||||
message: "#^Method PhpOffice\\\\PhpSpreadsheet\\\\Style\\\\NumberFormat\\\\Formatter\\:\\:splitFormat\\(\\) has no return type specified\\.$#"
|
||||
count: 1
|
||||
|
|
@ -5890,11 +5865,6 @@ parameters:
|
|||
count: 1
|
||||
path: src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php
|
||||
|
||||
-
|
||||
message: "#^Array \\(array\\<PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\AutoFilter\\\\Column\\\\Rule\\>\\) does not accept mixed\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Worksheet/AutoFilter/Column.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method setParent\\(\\) on mixed\\.$#"
|
||||
count: 1
|
||||
|
|
@ -6076,7 +6046,7 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$row of method PhpOffice\\\\PhpSpreadsheet\\\\Collection\\\\Cells\\:\\:removeRow\\(\\) expects string, int given\\.$#"
|
||||
message: "#^Parameter \\#1 \\$row of method PhpOffice\\\\PhpSpreadsheet\\\\Collection\\\\Cells\\:\\:removeRow\\(\\) expects string, int(<1, max>)? given\\.$#"
|
||||
count: 2
|
||||
path: src/PhpSpreadsheet/Worksheet/Worksheet.php
|
||||
|
||||
|
|
@ -7026,7 +6996,7 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Writer/Xlsx.php
|
||||
|
||||
-
|
||||
message: "#^Cannot access offset int on mixed\\.$#"
|
||||
message: "#^Cannot access offset int(<0, max>)? on mixed\\.$#"
|
||||
count: 2
|
||||
path: src/PhpSpreadsheet/Writer/Xlsx/Chart.php
|
||||
|
||||
|
|
@ -7191,7 +7161,7 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Writer/Xlsx/DocProps.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$index of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:getChartByIndex\\(\\) expects string, int given\\.$#"
|
||||
message: "#^Parameter \\#1 \\$index of method PhpOffice\\\\PhpSpreadsheet\\\\Worksheet\\\\Worksheet\\:\\:getChartByIndex\\(\\) expects string, int(<0, max>)? given\\.$#"
|
||||
count: 1
|
||||
path: src/PhpSpreadsheet/Writer/Xlsx/Drawing.php
|
||||
|
||||
|
|
@ -7431,7 +7401,7 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
||||
|
||||
-
|
||||
message: "#^Offset int on array\\<string, non\\-empty\\-array\\<int, string\\>\\> in isset\\(\\) does not exist\\.$#"
|
||||
message: "#^Offset int(<1, max>)? on array\\<string, non\\-empty\\-array\\<int, string\\>\\> in isset\\(\\) does not exist\\.$#"
|
||||
count: 2
|
||||
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
||||
|
||||
|
|
@ -7466,18 +7436,8 @@ parameters:
|
|||
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, int given\\.$#"
|
||||
count: 19
|
||||
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, int\\<0, max\\> given\\.$#"
|
||||
count: 3
|
||||
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, int\\<1, max\\> given\\.$#"
|
||||
count: 7
|
||||
message: "#^Parameter \\#2 \\$value of method XMLWriter\\:\\:writeAttribute\\(\\) expects string, (int|int\\<(0|1), max\\>) given\\.$#"
|
||||
count: 27
|
||||
path: src/PhpSpreadsheet/Writer/Xlsx/Worksheet.php
|
||||
|
||||
-
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ if (PHP_VERSION_ID < 80000) {
|
|||
];
|
||||
// Erroneous analysis by Phpstan before PHP8 - mb_strlen does not return false
|
||||
$config['parameters']['ignoreErrors'][] = [
|
||||
'message' => '#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:countCharacters\\(\\) should return int but returns int\\|false\\.$#',
|
||||
'message' => '#^Method PhpOffice\\\\PhpSpreadsheet\\\\Shared\\\\StringHelper\\:\\:countCharacters\\(\\) should return int but returns int(<0, max>)?\\|false\\.$#',
|
||||
'path' => __DIR__ . '/src/PhpSpreadsheet/Shared/StringHelper.php',
|
||||
'count' => 1,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class Coupons
|
|||
case FinancialConstants::BASIS_DAYS_PER_YEAR_ACTUAL:
|
||||
// Actual/actual
|
||||
if ($frequency == FinancialConstants::FREQUENCY_ANNUAL) {
|
||||
$daysPerYear = Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
|
||||
$daysPerYear = (int) Helpers::daysPerYear(DateTimeExcel\DateParts::year($settlement), $basis);
|
||||
|
||||
return $daysPerYear / $frequency;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class Averages extends AggregateBase
|
|||
$aArgs = Functions::flattenArrayIndexed($args);
|
||||
|
||||
// Return value
|
||||
$returnValue = 0;
|
||||
$returnValue = 0.0;
|
||||
|
||||
$aMean = self::average(...$args);
|
||||
if ($aMean === Functions::DIV0()) {
|
||||
|
|
|
|||
|
|
@ -7912,4 +7912,17 @@ class Xls extends BaseReader
|
|||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Phpstan 1.4.4 complains that this property is never read.
|
||||
* So, we might be able to get rid of it altogether.
|
||||
* For now, however, this function makes it readable,
|
||||
* which satisfies Phpstan.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function getMapCellStyleXfIndex(): array
|
||||
{
|
||||
return $this->mapCellStyleXfIndex;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ class EigenvalueDecomposition
|
|||
$norm = 0.0;
|
||||
|
||||
for ($i = 0; $i < $nn; ++$i) {
|
||||
if (($i < $low) || ($i > $high)) {
|
||||
if ($i > $high) {
|
||||
$this->d[$i] = $this->H[$i][$i];
|
||||
$this->e[$i] = 0.0;
|
||||
}
|
||||
|
|
@ -762,7 +762,7 @@ class EigenvalueDecomposition
|
|||
|
||||
// Vectors of isolated roots
|
||||
for ($i = 0; $i < $nn; ++$i) {
|
||||
if ($i < $low | $i > $high) {
|
||||
if ($i > $high) {
|
||||
for ($j = $i; $j < $nn; ++$j) {
|
||||
$this->V[$i][$j] = $this->H[$i][$j];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,12 +71,12 @@ class Root extends PPS
|
|||
$this->fileHandle = $fileHandle;
|
||||
|
||||
// Initial Setting for saving
|
||||
$this->bigBlockSize = 2 ** (
|
||||
$this->bigBlockSize = (int) (2 ** (
|
||||
(isset($this->bigBlockSize)) ? self::adjust2($this->bigBlockSize) : 9
|
||||
);
|
||||
$this->smallBlockSize = 2 ** (
|
||||
));
|
||||
$this->smallBlockSize = (int) (2 ** (
|
||||
(isset($this->smallBlockSize)) ? self::adjust2($this->smallBlockSize) : 6
|
||||
);
|
||||
));
|
||||
|
||||
// Make an array of PPS's (for Save)
|
||||
$aList = [];
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class StringHelper
|
|||
/**
|
||||
* Is iconv extension avalable?
|
||||
*
|
||||
* @var bool
|
||||
* @var ?bool
|
||||
*/
|
||||
private static $isIconvEnabled;
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class Trend
|
|||
case self::TREND_POWER:
|
||||
if (!isset(self::$trendCache[$key])) {
|
||||
$className = '\PhpOffice\PhpSpreadsheet\Shared\Trend\\' . $trendType . 'BestFit';
|
||||
// @phpstan-ignore-next-line
|
||||
self::$trendCache[$key] = new $className($yValues, $xValues, $const);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ class Spreadsheet
|
|||
break;
|
||||
case 'target':
|
||||
case 'data':
|
||||
if (is_array($this->ribbonXMLData) && isset($this->ribbonXMLData[$what])) {
|
||||
if (is_array($this->ribbonXMLData)) {
|
||||
$returnData = $this->ribbonXMLData[$what];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,11 +76,13 @@ class DateFormatter
|
|||
// general syntax: [$<Currency string>-<language info>]
|
||||
// language info is in hexadecimal
|
||||
// strip off chinese part like [DBNum1][$-804]
|
||||
$format = preg_replace('/^(\[DBNum\d\])*(\[\$[^\]]*\])/i', '', $format);
|
||||
$format = preg_replace('/^(\[DBNum\d\])*(\[\$[^\]]*\])/i', '', $format) ?? '';
|
||||
|
||||
// OpenOffice.org uses upper-case number formats, e.g. 'YYYY', convert to lower-case;
|
||||
// but we don't want to change any quoted strings
|
||||
$format = preg_replace_callback('/(?:^|")([^"]*)(?:$|")/', ['self', 'setLowercaseCallback'], $format);
|
||||
/** @var callable */
|
||||
$callable = ['self', 'setLowercaseCallback'];
|
||||
$format = preg_replace_callback('/(?:^|")([^"]*)(?:$|")/', $callable, $format);
|
||||
|
||||
// Only process the non-quoted blocks for date format characters
|
||||
$blocks = explode('"', $format);
|
||||
|
|
@ -106,7 +108,9 @@ class DateFormatter
|
|||
$format = implode('"', $blocks);
|
||||
|
||||
// escape any quoted characters so that DateTime format() will render them correctly
|
||||
$format = preg_replace_callback('/"(.*)"/U', ['self', 'escapeQuotesCallback'], $format);
|
||||
/** @var callable */
|
||||
$callback = ['self', 'escapeQuotesCallback'];
|
||||
$format = preg_replace_callback('/"(.*)"/U', $callback, $format);
|
||||
|
||||
$dateObj = Date::excelToDateTimeObject($value);
|
||||
// If the colon preceding minute had been quoted, as happens in
|
||||
|
|
|
|||
|
|
@ -78,9 +78,7 @@ class Style extends Supervisor
|
|||
* @see Style::applyFromArray()
|
||||
* @see Style::getHashCode()
|
||||
*
|
||||
* @phpstan-var null|array{styleByHash: array<string, Style>, hashByObjId: array<int, string>}
|
||||
*
|
||||
* @var array<string, array>
|
||||
* @var ?array<string, array>
|
||||
*/
|
||||
private static $cachedStyles;
|
||||
|
||||
|
|
|
|||
|
|
@ -394,6 +394,7 @@ class Column
|
|||
foreach ($value as $k => $v) {
|
||||
$cloned = clone $v;
|
||||
$cloned->setParent($this); // attach the new cloned Rule to this new cloned Autofilter Cloned object
|
||||
// @phpstan-ignore-next-line
|
||||
$this->ruleset[$k] = $cloned;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -205,10 +205,10 @@ class Worksheet extends WriterPart
|
|||
|
||||
// Zoom scales
|
||||
if ($worksheet->getSheetView()->getZoomScale() != 100) {
|
||||
$objWriter->writeAttribute('zoomScale', $worksheet->getSheetView()->getZoomScale());
|
||||
$objWriter->writeAttribute('zoomScale', (string) $worksheet->getSheetView()->getZoomScale());
|
||||
}
|
||||
if ($worksheet->getSheetView()->getZoomScaleNormal() != 100) {
|
||||
$objWriter->writeAttribute('zoomScaleNormal', $worksheet->getSheetView()->getZoomScaleNormal());
|
||||
$objWriter->writeAttribute('zoomScaleNormal', (string) $worksheet->getSheetView()->getZoomScaleNormal());
|
||||
}
|
||||
|
||||
// Show zeros (Excel also writes this attribute only if set to false)
|
||||
|
|
|
|||
Loading…
Reference in New Issue