mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-08-30 03:59:11 +00:00
Upgrade Phpstan
A lot of changes since its last update, including one that I requested.
This commit is contained in:
Generated
+6
-6
@@ -1803,16 +1803,16 @@
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan",
|
||||
"version": "2.1.21",
|
||||
"version": "2.1.23",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpstan/phpstan.git",
|
||||
"reference": "1ccf445757458c06a04eb3f803603cb118fe5fa6"
|
||||
"reference": "a34502adbbd5c2366b5a97679848a5ace4f6f2f5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/1ccf445757458c06a04eb3f803603cb118fe5fa6",
|
||||
"reference": "1ccf445757458c06a04eb3f803603cb118fe5fa6",
|
||||
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/a34502adbbd5c2366b5a97679848a5ace4f6f2f5",
|
||||
"reference": "a34502adbbd5c2366b5a97679848a5ace4f6f2f5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1857,7 +1857,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2025-07-28T19:35:08+00:00"
|
||||
"time": "2025-09-10T11:42:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpstan/phpstan-deprecation-rules",
|
||||
@@ -5664,7 +5664,7 @@
|
||||
"ext-zip": "*",
|
||||
"ext-zlib": "*"
|
||||
},
|
||||
"platform-dev": [],
|
||||
"platform-dev": {},
|
||||
"platform-overrides": {
|
||||
"php": "8.1.99"
|
||||
},
|
||||
|
||||
@@ -327,7 +327,7 @@ class LocaleGenerator
|
||||
foreach ($cells as $cell) {
|
||||
if ($cell->getValue() != '') {
|
||||
$this->log($cell->getRow() . ' -> ' . $cell->getValueString());
|
||||
$this->errorCodeMap[$cell->getValue()] = $cell->getRow();
|
||||
$this->errorCodeMap[$cell->getValueString()] = $cell->getRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -345,7 +345,7 @@ class LocaleGenerator
|
||||
if ($this->isFunctionCategoryEntry($cell)) {
|
||||
if (!empty($cell->getValue())) {
|
||||
$this->log('CATEGORY: ' . $cell->getValueString());
|
||||
$this->functionNameMap[$cell->getValue()] = $cell->getRow();
|
||||
$this->functionNameMap[$cell->getValueString()] = $cell->getRow();
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -356,7 +356,7 @@ class LocaleGenerator
|
||||
$this->functionNameMap[($cell->getValue() ? 'TRUE' : 'FALSE')] = $cell->getRow();
|
||||
} else {
|
||||
$this->log($cell->getRow() . ' -> ' . $cell->getValueString());
|
||||
$this->functionNameMap[$cell->getValue()] = $cell->getRow();
|
||||
$this->functionNameMap[$cell->getValueString()] = $cell->getRow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ if (isset($_POST['submit'])) {
|
||||
$helper->log('Unrecognized currency symbol');
|
||||
} else {
|
||||
try {
|
||||
$negative = $negatives[$_POST['negative']] ?? CurrencyNegative::minus;
|
||||
$negative = $negatives[$_POST['negative']] ?? CurrencyNegative::minus; //* @phpstan-ignore-line
|
||||
$wizard = new Wizard\Currency($_POST['currency'], (int) $_POST['decimals'], isset($_POST['thousands']), (bool) $_POST['position']);
|
||||
$wizard->setNegative($negative);
|
||||
$mask = $wizard->format();
|
||||
@@ -118,7 +118,7 @@ if (isset($_POST['submit'])) {
|
||||
. ', Wizard\Currency::' . (((bool) $_POST['position']) ? 'LEADING_SYMBOL' : 'TRAILING_SYMBOL')
|
||||
. ');'
|
||||
);
|
||||
$helper->log('$wizard->setNegative(' . $negativesString[$_POST['negative']] . ');');
|
||||
$helper->log('$wizard->setNegative(' . $negativesString[$_POST['negative']] . ');'); //* @phpstan-ignore-line
|
||||
$helper->log('$mask = $wizard->format();');
|
||||
$helper->log('<br />echo (string) $mask;');
|
||||
$helper->log('<hr /><b>Mask:</b><br />');
|
||||
|
||||
@@ -1699,7 +1699,7 @@ class Calculation extends CalculationLocale
|
||||
return $this->raiseFormulaError($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
} elseif (!is_numeric($token) && !is_object($token) && isset($token, self::BINARY_OPERATORS[$token])) {
|
||||
} elseif (!is_numeric($token) && !is_object($token) && isset($token, self::BINARY_OPERATORS[$token])) { //* @phpstan-ignore-line
|
||||
// if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack
|
||||
// We must have two operands, error if we don't
|
||||
$operand2Data = $stack->pop();
|
||||
@@ -2879,6 +2879,7 @@ class Calculation extends CalculationLocale
|
||||
if ($stack->count() > 0) {
|
||||
$o2 = $stack->last();
|
||||
if ($o2) {
|
||||
/** @var array{value: string} $o2 */
|
||||
if (isset(self::CALCULATION_OPERATORS[$o2['value']])) {
|
||||
$retVal = (self::OPERATOR_PRECEDENCE[$opCharacter] ?? 0) <= self::OPERATOR_PRECEDENCE[$o2['value']];
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class ArrayArgumentProcessor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $matrixIndexes
|
||||
* @param array<int|string> $matrixIndexes
|
||||
*
|
||||
* @return mixed[]
|
||||
*/
|
||||
|
||||
@@ -21,8 +21,10 @@ class CyclicReferenceStack
|
||||
|
||||
/**
|
||||
* Push a new entry onto the stack.
|
||||
*
|
||||
* @param int|string $value The value to test
|
||||
*/
|
||||
public function push(mixed $value): void
|
||||
public function push($value): void
|
||||
{
|
||||
$this->stack[$value] = $value;
|
||||
}
|
||||
@@ -38,9 +40,9 @@ class CyclicReferenceStack
|
||||
/**
|
||||
* Test to see if a specified entry exists on the stack.
|
||||
*
|
||||
* @param mixed $value The value to test
|
||||
* @param int|string $value The value to test
|
||||
*/
|
||||
public function onStack(mixed $value): bool
|
||||
public function onStack($value): bool
|
||||
{
|
||||
return isset($this->stack[$value]);
|
||||
}
|
||||
|
||||
@@ -135,14 +135,14 @@ class Matrix
|
||||
return self::extractRowValue($matrix, $rowKeys, $rowNum);
|
||||
}
|
||||
|
||||
$columnNum = $columnKeys[--$columnNum];
|
||||
$columnNum = $columnKeys[--$columnNum]; //* @phpstan-ignore-line
|
||||
if ($rowNum === 0) {
|
||||
return array_map(
|
||||
fn ($value): array => [$value],
|
||||
array_column($matrix, $columnNum)
|
||||
);
|
||||
}
|
||||
$rowNum = $rowKeys[--$rowNum];
|
||||
$rowNum = $rowKeys[--$rowNum]; //* @phpstan-ignore-line
|
||||
/** @var mixed[][] $matrix */
|
||||
|
||||
return $matrix[$rowNum][$columnNum];
|
||||
@@ -159,7 +159,7 @@ class Matrix
|
||||
}
|
||||
|
||||
$rowNum = $rowKeys[--$rowNum];
|
||||
$row = $matrix[$rowNum];
|
||||
$row = $matrix[$rowNum]; //* @phpstan-ignore-line
|
||||
if (is_array($row)) {
|
||||
return [$rowNum => $row];
|
||||
}
|
||||
|
||||
@@ -335,6 +335,7 @@ class Sort extends LookupRefValidations
|
||||
// Building a new array in the correct (sorted) order works; but may be memory heavy for larger arrays
|
||||
$sortedArray = [];
|
||||
foreach ($sortVector as $index) {
|
||||
/** @var int|string $index */
|
||||
$sortedArray[] = $sortArray[$index];
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class Arabic
|
||||
/**
|
||||
* Recursively calculate the arabic value of a roman numeral.
|
||||
*
|
||||
* @param mixed[] $roman
|
||||
* @param string[] $roman
|
||||
*/
|
||||
private static function calculateArabic(array $roman, int &$sum = 0, int $subtract = 0): int
|
||||
{
|
||||
|
||||
@@ -163,7 +163,7 @@ class Averages extends AggregateBase
|
||||
sort($aArgs, SORT_NUMERIC);
|
||||
$valueCount = $valueCount / 2;
|
||||
if ($valueCount == floor($valueCount)) {
|
||||
$returnValue = ($aArgs[$valueCount--] + $aArgs[$valueCount]) / 2;
|
||||
$returnValue = ($aArgs[$valueCount--] + $aArgs[$valueCount]) / 2; //* @phpstan-ignore-line
|
||||
} else {
|
||||
$valueCount = (int) floor($valueCount);
|
||||
$returnValue = $aArgs[$valueCount];
|
||||
@@ -243,7 +243,7 @@ class Averages extends AggregateBase
|
||||
$maxfreqkey = $key;
|
||||
$maxfreqdatum = $datum;
|
||||
} elseif ($freq == $maxfreq) {
|
||||
if ($frequencyArray[$key]['index'] < $frequencyArray[$maxfreqkey]['index']) {
|
||||
if ($frequencyArray[$key]['index'] < $frequencyArray[$maxfreqkey]['index']) { //* @phpstan-ignore-line
|
||||
$maxfreqkey = $key;
|
||||
$maxfreqdatum = $datum;
|
||||
}
|
||||
|
||||
@@ -333,16 +333,12 @@ class DataSeriesValues extends Properties
|
||||
* Method for validating hex color.
|
||||
*
|
||||
* @param string $color value for color
|
||||
*
|
||||
* @return bool true if validation was successful
|
||||
*/
|
||||
private function validateColor(string $color): bool
|
||||
private function validateColor(string $color): void
|
||||
{
|
||||
if (!preg_match('/^[a-f0-9]{6}$/i', $color)) {
|
||||
throw new Exception(sprintf('Invalid hex color for chart series (color: "%s")', $color));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,7 +140,7 @@ class Xls extends XlsBase
|
||||
/**
|
||||
* REF structures. Only applies to BIFF8.
|
||||
*
|
||||
* @var mixed[][]
|
||||
* @var array<int, array{'externalBookIndex': int, 'firstSheetIndex': int, 'lastSheetIndex': int}>
|
||||
*/
|
||||
protected array $ref;
|
||||
|
||||
@@ -2022,8 +2022,8 @@ class Xls extends XlsBase
|
||||
|
||||
// repeated option flags
|
||||
// OpenOffice.org documentation 5.21
|
||||
$option = ord($recordData[$pos]);
|
||||
/** @var int $pos */
|
||||
$option = ord($recordData[$pos]);
|
||||
++$pos;
|
||||
|
||||
/** @var int $limitpos */
|
||||
|
||||
@@ -549,6 +549,7 @@ class LoadSpreadsheet extends Xls
|
||||
foreach ($xls->sharedFormulaParts as $cell => $baseCell) {
|
||||
/** @var int $row */
|
||||
[$column, $row] = Coordinate::coordinateFromString($cell);
|
||||
/** @var string $baseCell */
|
||||
if ($xls->getReadFilter()->readCell($column, $row, $xls->phpSheet->getTitle())) {
|
||||
/** @var string */
|
||||
$temp = $xls->sharedFormulas[$baseCell];
|
||||
|
||||
@@ -1079,7 +1079,8 @@ class Xlsx extends BaseReader
|
||||
$childNode = $node->addChild('formula1');
|
||||
if ($childNode !== null) { // null should never happen
|
||||
// see https://github.com/phpstan/phpstan/issues/8236
|
||||
$childNode[0] = (string) $item->formula1->children(Namespaces::DATA_VALIDATIONS2)->f; // @phpstan-ignore-line
|
||||
// resolved with Phpstan 2.1.23
|
||||
$childNode[0] = (string) $item->formula1->children(Namespaces::DATA_VALIDATIONS2)->f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ class Border extends StyleBase
|
||||
}
|
||||
}
|
||||
|
||||
/** @var int|string $borderPosition */
|
||||
if ($borderPosition) {
|
||||
$style['borders'][$borderPosition] = $thisBorder;
|
||||
} elseif ($diagonalDirection) {
|
||||
@@ -99,6 +100,7 @@ class Border extends StyleBase
|
||||
/** @return mixed[] */
|
||||
protected function parsePosition(string $borderStyleValue, string $diagonalDirection): array
|
||||
{
|
||||
// TODO diagonalDirection seems to return int not string
|
||||
$borderStyleValue = strtolower($borderStyleValue);
|
||||
|
||||
if (in_array($borderStyleValue, self::BORDER_POSITIONS)) {
|
||||
|
||||
@@ -15,7 +15,7 @@ class NumberFormat extends StyleBase
|
||||
$toFormats = ['-', ' '];
|
||||
|
||||
foreach ($styleAttributes as $styleAttributeKey => $styleAttributeValue) {
|
||||
$styleAttributeValue = str_replace($fromFormats, $toFormats, $styleAttributeValue);
|
||||
$styleAttributeValue = str_replace($fromFormats, $toFormats, (string) $styleAttributeValue);
|
||||
|
||||
switch ($styleAttributeValue) {
|
||||
case 'Short Date':
|
||||
|
||||
@@ -400,6 +400,7 @@ class Style extends Supervisor
|
||||
}
|
||||
|
||||
// Find existing style by hash.
|
||||
/** @var string $styleHash */
|
||||
$existingStyle = self::$cachedStyles['styleByHash'][$styleHash] ?? null;
|
||||
|
||||
if (!$existingStyle) {
|
||||
|
||||
@@ -274,7 +274,8 @@ class Rule
|
||||
throw new PhpSpreadsheetException('Invalid rule value for column AutoFilter Rule.');
|
||||
}
|
||||
// Set the dateTime grouping that we've anticipated
|
||||
$this->setGrouping(self::DATE_TIME_GROUPS[$grouping]);
|
||||
// I have no idea what Phpstan is complaining about below
|
||||
$this->setGrouping(self::DATE_TIME_GROUPS[$grouping]); // @phpstan-ignore-line
|
||||
}
|
||||
$this->value = $value;
|
||||
|
||||
|
||||
@@ -3005,6 +3005,7 @@ class Worksheet
|
||||
|
||||
// Loop through rows
|
||||
foreach ($this->rangeToArrayYieldRows($range, $nullValue, $calculateFormulas, $formatData, $returnCellRef, $ignoreHidden, $reduceArrays) as $rowRef => $rowArray) {
|
||||
/** @var int $rowRef */
|
||||
$returnValue[$rowRef] = $rowArray;
|
||||
}
|
||||
|
||||
@@ -3040,6 +3041,7 @@ class Worksheet
|
||||
foreach ($parts as $part) {
|
||||
// Loop through rows
|
||||
foreach ($this->rangeToArrayYieldRows($part, $nullValue, $calculateFormulas, $formatData, $returnCellRef, $ignoreHidden, $reduceArrays) as $rowRef => $rowArray) {
|
||||
/** @var int $rowRef */
|
||||
$returnValue[$rowRef] = $rowArray;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2093,6 +2093,7 @@ class Html extends BaseWriter
|
||||
// For each of the omitted rows we found above, the affected rowspans should be subtracted by 1
|
||||
if (isset($this->isSpannedRow[$sheetIndex])) {
|
||||
foreach ($this->isSpannedRow[$sheetIndex] as $rowIndex) {
|
||||
/** @var int $rowIndex */
|
||||
$adjustedBaseCells = [];
|
||||
$c = -1;
|
||||
$e = $countColumns - 1;
|
||||
|
||||
@@ -35,6 +35,7 @@ class StringTable extends WriterPart
|
||||
foreach ($worksheet->getCellCollection()->getCoordinates() as $coordinate) {
|
||||
/** @var Cell $cell */
|
||||
$cell = $worksheet->getCellCollection()->get($coordinate);
|
||||
/** @var null|int|RichText|string */
|
||||
$cellValue = $cell->getValue();
|
||||
if (
|
||||
!is_object($cellValue)
|
||||
|
||||
@@ -7,8 +7,7 @@ use PHPUnit\Framework\TestCase;
|
||||
|
||||
class Issue1449Test extends TestCase
|
||||
{
|
||||
/** @var bool */
|
||||
private $skipTests = true;
|
||||
protected bool $skipTests = true;
|
||||
|
||||
public function testDeleteColumns(): void
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@ class GnumericStylesTest extends TestCase
|
||||
foreach ($expected as $key => $val) {
|
||||
$covered[$key] = 0;
|
||||
}
|
||||
/** @var mixed[][] */
|
||||
$tests = $this->providerBorderStyle();
|
||||
foreach ($tests as $test) {
|
||||
$covered[$test[0]] = 1;
|
||||
@@ -88,7 +87,6 @@ class GnumericStylesTest extends TestCase
|
||||
foreach ($expected as $key => $val) {
|
||||
$covered[$key] = 0;
|
||||
}
|
||||
/** @var mixed[][] */
|
||||
$tests = $this->providerHorizontal();
|
||||
foreach ($tests as $test) {
|
||||
$covered[$test[0]] = 1;
|
||||
@@ -117,7 +115,6 @@ class GnumericStylesTest extends TestCase
|
||||
foreach ($expected as $key => $val) {
|
||||
$covered[$key] = 0;
|
||||
}
|
||||
/** @var mixed[][] */
|
||||
$tests = $this->providerUnderline();
|
||||
foreach ($tests as $test) {
|
||||
$covered[$test[0]] = 1;
|
||||
@@ -185,6 +182,7 @@ class GnumericStylesTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/** @return array<int, array{0: string, 1:string}> */
|
||||
public static function providerBorderStyle(): array
|
||||
{
|
||||
return [
|
||||
@@ -205,7 +203,7 @@ class GnumericStylesTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/** @return string[][] */
|
||||
/** @return array<int, array{0: string, 1:string}> */
|
||||
public static function providerFillType(): array
|
||||
{
|
||||
return [
|
||||
@@ -230,6 +228,7 @@ class GnumericStylesTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<int, array{0: string, 1:string}> */
|
||||
public static function providerHorizontal(): array
|
||||
{
|
||||
return [
|
||||
@@ -243,6 +242,7 @@ class GnumericStylesTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<int, array{0: string, 1:string}> */
|
||||
public static function providerUnderline(): array
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user