Skip to content

Commit 2a9f2f5

Browse files
committed
Rector MixedTypeRector
1 parent f4c1519 commit 2a9f2f5

File tree

200 files changed

+785
-1350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+785
-1350
lines changed

src/PhpSpreadsheet/Calculation/ArrayEnabled.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ protected static function evaluateSingleArgumentArray(callable $method, array $v
4343
* and any of them can be an array argument.
4444
* Example use for:
4545
* ROUND() or DATE().
46-
*
47-
* @param mixed ...$arguments
4846
*/
49-
protected static function evaluateArrayArguments(callable $method, ...$arguments): array
47+
protected static function evaluateArrayArguments(callable $method, mixed ...$arguments): array
5048
{
5149
self::initialiseHelper($arguments);
5250
$arguments = self::$arrayArgumentHelper->arguments();
@@ -60,10 +58,8 @@ protected static function evaluateArrayArguments(callable $method, ...$arguments
6058
* Example use for:
6159
* NETWORKDAYS() or CONCATENATE(), where the last argument is a matrix (or a series of values) that need
6260
* to be treated as a such rather than as an array arguments.
63-
*
64-
* @param mixed ...$arguments
6561
*/
66-
protected static function evaluateArrayArgumentsSubset(callable $method, int $limit, ...$arguments): array
62+
protected static function evaluateArrayArgumentsSubset(callable $method, int $limit, mixed ...$arguments): array
6763
{
6864
self::initialiseHelper(array_slice($arguments, 0, $limit));
6965
$trailingArguments = array_slice($arguments, $limit);
@@ -73,10 +69,7 @@ protected static function evaluateArrayArgumentsSubset(callable $method, int $li
7369
return ArrayArgumentProcessor::processArguments(self::$arrayArgumentHelper, $method, ...$arguments);
7470
}
7571

76-
/**
77-
* @param mixed $value
78-
*/
79-
private static function testFalse($value): bool
72+
private static function testFalse(mixed $value): bool
8073
{
8174
return $value === false;
8275
}
@@ -87,10 +80,8 @@ private static function testFalse($value): bool
8780
* Example use for:
8881
* Z.TEST() or INDEX(), where the first argument 1 is a matrix that needs to be treated as a dataset
8982
* rather than as an array argument.
90-
*
91-
* @param mixed ...$arguments
9283
*/
93-
protected static function evaluateArrayArgumentsSubsetFrom(callable $method, int $start, ...$arguments): array
84+
protected static function evaluateArrayArgumentsSubsetFrom(callable $method, int $start, mixed ...$arguments): array
9485
{
9586
$arrayArgumentsSubset = array_combine(
9687
range($start, count($arguments) - $start),
@@ -114,10 +105,8 @@ protected static function evaluateArrayArgumentsSubsetFrom(callable $method, int
114105
* Example use for:
115106
* HLOOKUP() and VLOOKUP(), where argument 1 is a matrix that needs to be treated as a database
116107
* rather than as an array argument.
117-
*
118-
* @param mixed ...$arguments
119108
*/
120-
protected static function evaluateArrayArgumentsIgnore(callable $method, int $ignore, ...$arguments): array
109+
protected static function evaluateArrayArgumentsIgnore(callable $method, int $ignore, mixed ...$arguments): array
121110
{
122111
$leadingArguments = array_slice($arguments, 0, $ignore);
123112
$ignoreArgument = array_slice($arguments, $ignore, 1);

src/PhpSpreadsheet/Calculation/BinaryComparison.php

Lines changed: 8 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ private static function strcmpAllowNull($str1, $str2): int
3636
return strcmp($str1 ?? '', $str2 ?? '');
3737
}
3838

39-
/**
40-
* @param mixed $operand1
41-
* @param mixed $operand2
42-
*/
43-
public static function compare($operand1, $operand2, string $operator): bool
39+
public static function compare(mixed $operand1, mixed $operand2, string $operator): bool
4440
{
4541
// Simple validate the two operands if they are string values
4642
if (is_string($operand1) && $operand1 > '' && $operand1[0] == Calculation::FORMULA_STRING_QUOTE) {
@@ -67,11 +63,7 @@ public static function compare($operand1, $operand2, string $operator): bool
6763
return self::evaluateComparison($operand1, $operand2, $operator, $useLowercaseFirstComparison);
6864
}
6965

70-
/**
71-
* @param mixed $operand1
72-
* @param mixed $operand2
73-
*/
74-
private static function evaluateComparison($operand1, $operand2, string $operator, bool $useLowercaseFirstComparison): bool
66+
private static function evaluateComparison(mixed $operand1, mixed $operand2, string $operator, bool $useLowercaseFirstComparison): bool
7567
{
7668
return match ($operator) {
7769
'=' => self::equal($operand1, $operand2),
@@ -84,11 +76,7 @@ private static function evaluateComparison($operand1, $operand2, string $operato
8476
};
8577
}
8678

87-
/**
88-
* @param mixed $operand1
89-
* @param mixed $operand2
90-
*/
91-
private static function equal($operand1, $operand2): bool
79+
private static function equal(mixed $operand1, mixed $operand2): bool
9280
{
9381
if (is_numeric($operand1) && is_numeric($operand2)) {
9482
$result = (abs($operand1 - $operand2) < self::DELTA);
@@ -101,11 +89,7 @@ private static function equal($operand1, $operand2): bool
10189
return $result;
10290
}
10391

104-
/**
105-
* @param mixed $operand1
106-
* @param mixed $operand2
107-
*/
108-
private static function greaterThanOrEqual($operand1, $operand2, bool $useLowercaseFirstComparison): bool
92+
private static function greaterThanOrEqual(mixed $operand1, mixed $operand2, bool $useLowercaseFirstComparison): bool
10993
{
11094
if (is_numeric($operand1) && is_numeric($operand2)) {
11195
$result = ((abs($operand1 - $operand2) < self::DELTA) || ($operand1 > $operand2));
@@ -120,11 +104,7 @@ private static function greaterThanOrEqual($operand1, $operand2, bool $useLowerc
120104
return $result;
121105
}
122106

123-
/**
124-
* @param mixed $operand1
125-
* @param mixed $operand2
126-
*/
127-
private static function lessThanOrEqual($operand1, $operand2, bool $useLowercaseFirstComparison): bool
107+
private static function lessThanOrEqual(mixed $operand1, mixed $operand2, bool $useLowercaseFirstComparison): bool
128108
{
129109
if (is_numeric($operand1) && is_numeric($operand2)) {
130110
$result = ((abs($operand1 - $operand2) < self::DELTA) || ($operand1 < $operand2));
@@ -139,29 +119,17 @@ private static function lessThanOrEqual($operand1, $operand2, bool $useLowercase
139119
return $result;
140120
}
141121

142-
/**
143-
* @param mixed $operand1
144-
* @param mixed $operand2
145-
*/
146-
private static function greaterThan($operand1, $operand2, bool $useLowercaseFirstComparison): bool
122+
private static function greaterThan(mixed $operand1, mixed $operand2, bool $useLowercaseFirstComparison): bool
147123
{
148124
return self::lessThanOrEqual($operand1, $operand2, $useLowercaseFirstComparison) !== true;
149125
}
150126

151-
/**
152-
* @param mixed $operand1
153-
* @param mixed $operand2
154-
*/
155-
private static function lessThan($operand1, $operand2, bool $useLowercaseFirstComparison): bool
127+
private static function lessThan(mixed $operand1, mixed $operand2, bool $useLowercaseFirstComparison): bool
156128
{
157129
return self::greaterThanOrEqual($operand1, $operand2, $useLowercaseFirstComparison) !== true;
158130
}
159131

160-
/**
161-
* @param mixed $operand1
162-
* @param mixed $operand2
163-
*/
164-
private static function notEqual($operand1, $operand2): bool
132+
private static function notEqual(mixed $operand1, mixed $operand2): bool
165133
{
166134
return self::equal($operand1, $operand2) !== true;
167135
}

src/PhpSpreadsheet/Calculation/Calculation.php

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3105,10 +3105,8 @@ public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksh
31053105

31063106
/**
31073107
* Enable/disable calculation cache.
3108-
*
3109-
* @param mixed $enabled
31103108
*/
3111-
public function setBranchPruningEnabled($enabled): void
3109+
public function setBranchPruningEnabled(mixed $enabled): void
31123110
{
31133111
$this->branchPruningEnabled = $enabled;
31143112
$this->branchPruner = new BranchPruner($this->branchPruningEnabled);
@@ -3439,11 +3437,9 @@ public static function wrapResult(mixed $value)
34393437
/**
34403438
* Remove quotes used as a wrapper to identify string values.
34413439
*
3442-
* @param mixed $value
3443-
*
34443440
* @return mixed
34453441
*/
3446-
public static function unwrapResult($value)
3442+
public static function unwrapResult(mixed $value)
34473443
{
34483444
if (is_string($value)) {
34493445
if ((isset($value[0])) && ($value[0] == self::FORMULA_STRING_QUOTE) && (substr($value, -1) == self::FORMULA_STRING_QUOTE)) {
@@ -3637,10 +3633,7 @@ public function calculateFormula($formula, $cellID = null, ?Cell $cell = null)
36373633
return $result;
36383634
}
36393635

3640-
/**
3641-
* @param mixed $cellValue
3642-
*/
3643-
public function getValueFromCache(string $cellReference, &$cellValue): bool
3636+
public function getValueFromCache(string $cellReference, mixed &$cellValue): bool
36443637
{
36453638
$this->debugLog->writeDebugLog('Testing cache value for cell %s', $cellReference);
36463639
// Is calculation cacheing enabled?
@@ -3659,9 +3652,8 @@ public function getValueFromCache(string $cellReference, &$cellValue): bool
36593652

36603653
/**
36613654
* @param string $cellReference
3662-
* @param mixed $cellValue
36633655
*/
3664-
public function saveValueToCache($cellReference, $cellValue): void
3656+
public function saveValueToCache($cellReference, mixed $cellValue): void
36653657
{
36663658
if ($this->calculationCacheEnabled) {
36673659
$this->calculationCache[$cellReference] = $cellValue;
@@ -3759,7 +3751,7 @@ public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = n
37593751
* 1 = shrink to fit
37603752
* 2 = extend to fit
37613753
*/
3762-
private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1): array
3754+
private static function checkMatrixOperands(mixed &$operand1, mixed &$operand2, $resize = 1): array
37633755
{
37643756
// Examine each of the two operands, and turn them into an array if they aren't one already
37653757
// Note that this function should only be called if one or both of the operand is already an array
@@ -3912,7 +3904,7 @@ private static function resizeMatricesExtend(array &$matrix1, array &$matrix2, $
39123904
*
39133905
* @return mixed
39143906
*/
3915-
private function showValue($value)
3907+
private function showValue(mixed $value)
39163908
{
39173909
if ($this->debugLog->getWriteDebugLog()) {
39183910
$testArray = Functions::flattenArray($value);
@@ -3950,7 +3942,7 @@ private function showValue($value)
39503942
*
39513943
* @param mixed $value First matrix operand
39523944
*/
3953-
private function showTypeDetails($value): ?string
3945+
private function showTypeDetails(mixed $value): ?string
39543946
{
39553947
if ($this->debugLog->getWriteDebugLog()) {
39563948
$testArray = Functions::flattenArray($value);
@@ -4609,12 +4601,11 @@ private static function dataTestReference(array &$operandData)
46094601
}
46104602

46114603
/**
4612-
* @param mixed $tokens
46134604
* @param null|string $cellID
46144605
*
46154606
* @return array<int, mixed>|false
46164607
*/
4617-
private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
4608+
private function processTokenStack(mixed $tokens, $cellID = null, ?Cell $cell = null)
46184609
{
46194610
if ($tokens === false) {
46204611
return false;
@@ -5190,11 +5181,7 @@ private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null)
51905181
return $output;
51915182
}
51925183

5193-
/**
5194-
* @param mixed $operand
5195-
* @param mixed $stack
5196-
*/
5197-
private function validateBinaryOperand(&$operand, &$stack): bool
5184+
private function validateBinaryOperand(mixed &$operand, mixed &$stack): bool
51985185
{
51995186
if (is_array($operand)) {
52005187
if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) {
@@ -5232,11 +5219,7 @@ private function validateBinaryOperand(&$operand, &$stack): bool
52325219
return true;
52335220
}
52345221

5235-
/**
5236-
* @param mixed $operand1
5237-
* @param mixed $operand2
5238-
*/
5239-
private function executeArrayComparison($operand1, $operand2, string $operation, Stack &$stack, bool $recursingArrays): array
5222+
private function executeArrayComparison(mixed $operand1, mixed $operand2, string $operation, Stack &$stack, bool $recursingArrays): array
52405223
{
52415224
$result = [];
52425225
if (!is_array($operand2)) {
@@ -5275,11 +5258,7 @@ private function executeArrayComparison($operand1, $operand2, string $operation,
52755258
return $result;
52765259
}
52775260

5278-
/**
5279-
* @param mixed $operand1
5280-
* @param mixed $operand2
5281-
*/
5282-
private function executeBinaryComparisonOperation($operand1, $operand2, string $operation, Stack &$stack, bool $recursingArrays = false): array|bool
5261+
private function executeBinaryComparisonOperation(mixed $operand1, mixed $operand2, string $operation, Stack &$stack, bool $recursingArrays = false): array|bool
52835262
{
52845263
// If we're dealing with matrix operations, we want a matrix result
52855264
if ((is_array($operand1)) || (is_array($operand2))) {
@@ -5297,14 +5276,12 @@ private function executeBinaryComparisonOperation($operand1, $operand2, string $
52975276
}
52985277

52995278
/**
5300-
* @param mixed $operand1
5301-
* @param mixed $operand2
53025279
* @param string $operation
53035280
* @param Stack $stack
53045281
*
53055282
* @return bool|mixed
53065283
*/
5307-
private function executeNumericBinaryOperation($operand1, $operand2, $operation, &$stack)
5284+
private function executeNumericBinaryOperation(mixed $operand1, mixed $operand2, $operation, &$stack)
53085285
{
53095286
// Validate the two operands
53105287
if (
@@ -5740,18 +5717,15 @@ public function getSuppressFormulaErrors(): bool
57405717
return $this->suppressFormulaErrorsNew;
57415718
}
57425719

5743-
/** @param mixed $arg */
5744-
private static function doNothing($arg): bool
5720+
private static function doNothing(mixed $arg): bool
57455721
{
57465722
return (bool) $arg;
57475723
}
57485724

57495725
/**
5750-
* @param mixed $operand1
5751-
*
57525726
* @return mixed
57535727
*/
5754-
private static function boolToString($operand1)
5728+
private static function boolToString(mixed $operand1)
57555729
{
57565730
if (is_bool($operand1)) {
57575731
$operand1 = ($operand1) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE'];
@@ -5762,14 +5736,12 @@ private static function boolToString($operand1)
57625736
return $operand1;
57635737
}
57645738

5765-
/** @param mixed $operand */
5766-
private static function isNumericOrBool($operand): bool
5739+
private static function isNumericOrBool(mixed $operand): bool
57675740
{
57685741
return is_numeric($operand) || is_bool($operand);
57695742
}
57705743

5771-
/** @param mixed $operand */
5772-
private static function makeError($operand = ''): string
5744+
private static function makeError(mixed $operand = ''): string
57735745
{
57745746
return Information\ErrorValue::isError($operand) ? $operand : Information\ExcelError::VALUE();
57755747
}

src/PhpSpreadsheet/Calculation/Database/DatabaseAbstract.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract public static function evaluate($database, $field, $criteria);
3232
* represents the position of the column within the list: 1 for
3333
* the first column, 2 for the second column, and so on.
3434
*/
35-
protected static function fieldExtract(array $database, $field): ?int
35+
protected static function fieldExtract(array $database, mixed $field): ?int
3636
{
3737
$field = strtoupper(Functions::flattenSingleValue($field) ?? '');
3838
if ($field === '') {
@@ -124,10 +124,7 @@ function ($rowValue): string {
124124
return (count($rowQuery) > 1) ? 'OR(' . implode(',', $rowQuery) . ')' : ($rowQuery[0] ?? '');
125125
}
126126

127-
/**
128-
* @param mixed $criterion
129-
*/
130-
private static function buildCondition($criterion, string $criterionName): string
127+
private static function buildCondition(mixed $criterion, string $criterionName): string
131128
{
132129
$ifCondition = Functions::ifCondition($criterion);
133130

0 commit comments

Comments
 (0)