Skip to content

Commit 4b8f4e8

Browse files
committed
Upgrade Phpstan
A lot of changes since its last update, including one that I requested.
1 parent 889d26a commit 4b8f4e8

File tree

23 files changed

+47
-38
lines changed

23 files changed

+47
-38
lines changed

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/LocaleGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ protected function mapErrorCodeRows(): void
327327
foreach ($cells as $cell) {
328328
if ($cell->getValue() != '') {
329329
$this->log($cell->getRow() . ' -> ' . $cell->getValueString());
330-
$this->errorCodeMap[$cell->getValue()] = $cell->getRow();
330+
$this->errorCodeMap[$cell->getValueString()] = $cell->getRow();
331331
}
332332
}
333333
}
@@ -345,7 +345,7 @@ protected function mapFunctionNameRows(): void
345345
if ($this->isFunctionCategoryEntry($cell)) {
346346
if (!empty($cell->getValue())) {
347347
$this->log('CATEGORY: ' . $cell->getValueString());
348-
$this->functionNameMap[$cell->getValue()] = $cell->getRow();
348+
$this->functionNameMap[$cell->getValueString()] = $cell->getRow();
349349
}
350350

351351
continue;
@@ -356,7 +356,7 @@ protected function mapFunctionNameRows(): void
356356
$this->functionNameMap[($cell->getValue() ? 'TRUE' : 'FALSE')] = $cell->getRow();
357357
} else {
358358
$this->log($cell->getRow() . ' -> ' . $cell->getValueString());
359-
$this->functionNameMap[$cell->getValue()] = $cell->getRow();
359+
$this->functionNameMap[$cell->getValueString()] = $cell->getRow();
360360
}
361361
}
362362
}

samples/Wizards/NumberFormat/Currency.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
$helper->log('Unrecognized currency symbol');
105105
} else {
106106
try {
107-
$negative = $negatives[$_POST['negative']] ?? CurrencyNegative::minus;
107+
$negative = $negatives[$_POST['negative']] ?? CurrencyNegative::minus; //* @phpstan-ignore-line
108108
$wizard = new Wizard\Currency($_POST['currency'], (int) $_POST['decimals'], isset($_POST['thousands']), (bool) $_POST['position']);
109109
$wizard->setNegative($negative);
110110
$mask = $wizard->format();
@@ -118,7 +118,7 @@
118118
. ', Wizard\Currency::' . (((bool) $_POST['position']) ? 'LEADING_SYMBOL' : 'TRAILING_SYMBOL')
119119
. ');'
120120
);
121-
$helper->log('$wizard->setNegative(' . $negativesString[$_POST['negative']] . ');');
121+
$helper->log('$wizard->setNegative(' . $negativesString[$_POST['negative']] . ');'); //* @phpstan-ignore-line
122122
$helper->log('$mask = $wizard->format();');
123123
$helper->log('<br />echo (string) $mask;');
124124
$helper->log('<hr /><b>Mask:</b><br />');

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ private function processTokenStack(false|array $tokens, ?string $cellID = null,
16991699
return $this->raiseFormulaError($e->getMessage(), $e->getCode(), $e);
17001700
}
17011701
}
1702-
} elseif (!is_numeric($token) && !is_object($token) && isset($token, self::BINARY_OPERATORS[$token])) {
1702+
} elseif (!is_numeric($token) && !is_object($token) && isset($token, self::BINARY_OPERATORS[$token])) { //* @phpstan-ignore-line
17031703
// 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
17041704
// We must have two operands, error if we don't
17051705
$operand2Data = $stack->pop();
@@ -2879,6 +2879,7 @@ private static function swapOperands(Stack $stack, string $opCharacter): bool
28792879
if ($stack->count() > 0) {
28802880
$o2 = $stack->last();
28812881
if ($o2) {
2882+
/** @var array{value: string} $o2 */
28822883
if (isset(self::CALCULATION_OPERATORS[$o2['value']])) {
28832884
$retVal = (self::OPERATOR_PRECEDENCE[$opCharacter] ?? 0) <= self::OPERATOR_PRECEDENCE[$o2['value']];
28842885
}

src/PhpSpreadsheet/Calculation/Engine/ArrayArgumentProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private static function evaluateVectorMatrixPair(callable $method, array $matrix
102102
}
103103

104104
/**
105-
* @param mixed[] $matrixIndexes
105+
* @param array<int|string> $matrixIndexes
106106
*
107107
* @return mixed[]
108108
*/

src/PhpSpreadsheet/Calculation/Engine/CyclicReferenceStack.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ public function count(): int
2121

2222
/**
2323
* Push a new entry onto the stack.
24+
*
25+
* @param int|string $value The value to test
2426
*/
25-
public function push(mixed $value): void
27+
public function push($value): void
2628
{
2729
$this->stack[$value] = $value;
2830
}
@@ -38,9 +40,9 @@ public function pop(): mixed
3840
/**
3941
* Test to see if a specified entry exists on the stack.
4042
*
41-
* @param mixed $value The value to test
43+
* @param int|string $value The value to test
4244
*/
43-
public function onStack(mixed $value): bool
45+
public function onStack($value): bool
4446
{
4547
return isset($this->stack[$value]);
4648
}

src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ public static function index(mixed $matrix, mixed $rowNum = 0, mixed $columnNum
135135
return self::extractRowValue($matrix, $rowKeys, $rowNum);
136136
}
137137

138-
$columnNum = $columnKeys[--$columnNum];
138+
$columnNum = $columnKeys[--$columnNum]; //* @phpstan-ignore-line
139139
if ($rowNum === 0) {
140140
return array_map(
141141
fn ($value): array => [$value],
142142
array_column($matrix, $columnNum)
143143
);
144144
}
145-
$rowNum = $rowKeys[--$rowNum];
145+
$rowNum = $rowKeys[--$rowNum]; //* @phpstan-ignore-line
146146
/** @var mixed[][] $matrix */
147147

148148
return $matrix[$rowNum][$columnNum];
@@ -159,7 +159,7 @@ private static function extractRowValue(array $matrix, array $rowKeys, int $rowN
159159
}
160160

161161
$rowNum = $rowKeys[--$rowNum];
162-
$row = $matrix[$rowNum];
162+
$row = $matrix[$rowNum]; //* @phpstan-ignore-line
163163
if (is_array($row)) {
164164
return [$rowNum => $row];
165165
}

src/PhpSpreadsheet/Calculation/LookupRef/Sort.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ private static function sortLookupArrayFromVector(array $sortArray, array $sortV
335335
// Building a new array in the correct (sorted) order works; but may be memory heavy for larger arrays
336336
$sortedArray = [];
337337
foreach ($sortVector as $index) {
338+
/** @var int|string $index */
338339
$sortedArray[] = $sortArray[$index];
339340
}
340341

src/PhpSpreadsheet/Calculation/MathTrig/Arabic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Arabic
2323
/**
2424
* Recursively calculate the arabic value of a roman numeral.
2525
*
26-
* @param mixed[] $roman
26+
* @param string[] $roman
2727
*/
2828
private static function calculateArabic(array $roman, int &$sum = 0, int $subtract = 0): int
2929
{

src/PhpSpreadsheet/Calculation/Statistical/Averages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static function median(mixed ...$args): float|string
163163
sort($aArgs, SORT_NUMERIC);
164164
$valueCount = $valueCount / 2;
165165
if ($valueCount == floor($valueCount)) {
166-
$returnValue = ($aArgs[$valueCount--] + $aArgs[$valueCount]) / 2;
166+
$returnValue = ($aArgs[$valueCount--] + $aArgs[$valueCount]) / 2; //* @phpstan-ignore-line
167167
} else {
168168
$valueCount = (int) floor($valueCount);
169169
$returnValue = $aArgs[$valueCount];
@@ -243,7 +243,7 @@ private static function modeCalc(array $data): float|string
243243
$maxfreqkey = $key;
244244
$maxfreqdatum = $datum;
245245
} elseif ($freq == $maxfreq) {
246-
if ($frequencyArray[$key]['index'] < $frequencyArray[$maxfreqkey]['index']) {
246+
if ($frequencyArray[$key]['index'] < $frequencyArray[$maxfreqkey]['index']) { //* @phpstan-ignore-line
247247
$maxfreqkey = $key;
248248
$maxfreqdatum = $datum;
249249
}

0 commit comments

Comments
 (0)