Skip to content

Commit 9a685e3

Browse files
authored
Merge branch 'master' into issue3904c
2 parents 18a5396 + d0393a2 commit 9a685e3

File tree

27 files changed

+167
-85
lines changed

27 files changed

+167
-85
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ composer require phpoffice/phpspreadsheet
3131
If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as `php-fpm` or Apache's `mod_php`, then you might want to add the following to your `composer.json` before installing:
3232
```json
3333
{
34-
"require": {
35-
"phpoffice/phpspreadsheet": "^1.28"
36-
},
3734
"config": {
3835
"platform": {
3936
"php": "8.0"

composer.lock

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

docs/index.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ composer require phpoffice/phpspreadsheet --prefer-source
5757
If you are building your installation on a development machine that is on a different PHP version to the server where it will be deployed, or if your PHP CLI version is not the same as your run-time such as `php-fpm` or Apache's `mod_php`, then you might want to add the following to your `composer.json` before installing:
5858
```json
5959
{
60-
"require": {
61-
"phpoffice/phpspreadsheet": "^1.23"
62-
},
6360
"config": {
6461
"platform": {
6562
"php": "8.0"

phpstan-baseline.neon

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: "#^Binary operation \"/\" between float and array\\|float\\|int\\|string results in an error\\.$#"
5-
count: 1
6-
path: src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php

src/PhpSpreadsheet/Calculation/DateTimeExcel/TimeValue.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TimeValue
2525
* Excel Function:
2626
* TIMEVALUE(timeValue)
2727
*
28-
* @param null|array|bool|int|string $timeValue A text string that represents a time in any one of the Microsoft
28+
* @param null|array|bool|float|int|string $timeValue A text string that represents a time in any one of the Microsoft
2929
* Excel time formats; for example, "6:45 PM" and "18:45" text strings
3030
* within quotation marks that represent time.
3131
* Date information in time_text is ignored.
@@ -36,7 +36,7 @@ class TimeValue
3636
* If an array of numbers is passed as the argument, then the returned result will also be an array
3737
* with the same dimensions
3838
*/
39-
public static function fromString(null|array|string|int|bool $timeValue): array|string|Datetime|int|float
39+
public static function fromString(null|array|string|int|bool|float $timeValue): array|string|Datetime|int|float
4040
{
4141
if (is_array($timeValue)) {
4242
return self::evaluateSingleArgumentArray([self::class, __FUNCTION__], $timeValue);

src/PhpSpreadsheet/Calculation/MathTrig/Combinations.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ public static function withoutRepetition(mixed $numObjs, mixed $numInSet): array
4040
return $e->getMessage();
4141
}
4242

43-
return round(Factorial::fact($numObjs) / Factorial::fact($numObjs - $numInSet)) / Factorial::fact($numInSet); // @phpstan-ignore-line
43+
/** @var float */
44+
$quotient = Factorial::fact($numObjs);
45+
/** @var float */
46+
$divisor1 = Factorial::fact($numObjs - $numInSet);
47+
/** @var float */
48+
$divisor2 = Factorial::fact($numInSet);
49+
50+
return round($quotient / ($divisor1 * $divisor2));
4451
}
4552

4653
/**
@@ -84,8 +91,13 @@ public static function withRepetition(mixed $numObjs, mixed $numInSet): array|in
8491
return $e->getMessage();
8592
}
8693

87-
return round(
88-
Factorial::fact($numObjs + $numInSet - 1) / Factorial::fact($numObjs - 1) // @phpstan-ignore-line
89-
) / Factorial::fact($numInSet);
94+
/** @var float */
95+
$quotient = Factorial::fact($numObjs + $numInSet - 1);
96+
/** @var float */
97+
$divisor1 = Factorial::fact($numObjs - 1);
98+
/** @var float */
99+
$divisor2 = Factorial::fact($numInSet);
100+
101+
return round($quotient / ($divisor1 * $divisor2));
90102
}
91103
}

src/PhpSpreadsheet/Calculation/Statistical/Permutations.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ public static function PERMUT(mixed $numObjs, mixed $numInSet)
4646
if ($numObjs < $numInSet) {
4747
return ExcelError::NAN();
4848
}
49+
/** @var float|int|string */
4950
$result1 = MathTrig\Factorial::fact($numObjs);
5051
if (is_string($result1)) {
5152
return $result1;
5253
}
54+
/** @var float|int|string */
5355
$result2 = MathTrig\Factorial::fact($numObjs - $numInSet);
5456
if (is_string($result2)) {
5557
return $result2;
5658
}
57-
// phpstan thinks result1 and result2 can be arrays; they can't.
58-
$result = round($result1 / $result2); // @phpstan-ignore-line
59+
$result = round($result1 / $result2);
5960

6061
return IntOrFloat::evaluate($result);
6162
}

src/PhpSpreadsheet/Calculation/Statistical/Trends.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public static function FORECAST(mixed $xValue, array $yValues, array $xValues)
148148
* @param mixed[] $newValues Values of X for which we want to find Y
149149
* @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not
150150
*
151-
* @return float[]
151+
* @return array<int, array<int, array<int, float>>>
152152
*/
153153
public static function GROWTH(array $yValues, array $xValues = [], array $newValues = [], mixed $const = true): array
154154
{
@@ -167,7 +167,7 @@ public static function GROWTH(array $yValues, array $xValues = [], array $newVal
167167
$returnArray[0][] = [$bestFitExponential->getValueOfYForX($xValue)];
168168
}
169169

170-
return $returnArray; //* @phpstan-ignore-line
170+
return $returnArray;
171171
}
172172

173173
/**
@@ -401,7 +401,7 @@ public static function STEYX(array $yValues, array $xValues): float|string
401401
* @param mixed[] $newValues Values of X for which we want to find Y
402402
* @param mixed $const A logical (boolean) value specifying whether to force the intersect to equal 0 or not
403403
*
404-
* @return float[]
404+
* @return array<int, array<int, array<int, float>>>
405405
*/
406406
public static function TREND(array $yValues, array $xValues = [], array $newValues = [], mixed $const = true): array
407407
{
@@ -420,6 +420,6 @@ public static function TREND(array $yValues, array $xValues = [], array $newValu
420420
$returnArray[0][] = [$bestFitLinear->getValueOfYForX($xValue)];
421421
}
422422

423-
return $returnArray; //* @phpstan-ignore-line
423+
return $returnArray;
424424
}
425425
}

src/PhpSpreadsheet/Calculation/TextData/Format.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ public static function TEXTFORMAT(mixed $value, mixed $format): array|string
126126
$format = Helpers::extractString($format);
127127

128128
if (!is_numeric($value) && Date::isDateTimeFormatCode($format)) {
129-
// @phpstan-ignore-next-line
130-
$value = DateTimeExcel\DateValue::fromString($value) + DateTimeExcel\TimeValue::fromString($value);
129+
$value1 = DateTimeExcel\DateValue::fromString($value);
130+
$value2 = DateTimeExcel\TimeValue::fromString($value);
131+
$value = (is_numeric($value1) && is_numeric($value2)) ? ($value1 + $value2) : (is_numeric($value1) ? $value2 : $value1);
131132
}
132133

133134
return (string) NumberFormat::toFormattedString($value, $format);

src/PhpSpreadsheet/Cell/AdvancedValueBinder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ public function bindValue(Cell $cell, mixed $value = null): bool
6363
// Convert value to number
6464
$sign = ($matches['PrefixedSign'] ?? $matches['PrefixedSign2'] ?? $matches['PostfixedSign']) ?? null;
6565
$currencyCode = $matches['PrefixedCurrency'] ?? $matches['PostfixedCurrency'];
66-
$value = (float) ($sign . trim(str_replace([$decimalSeparatorNoPreg, $currencyCode, ' ', '-'], ['.', '', '', ''], preg_replace('/(\d)' . $thousandsSeparator . '(\d)/u', '$1$2', $value)))); // @phpstan-ignore-line
66+
/** @var string */
67+
$temp = str_replace([$decimalSeparatorNoPreg, $currencyCode, ' ', '-'], ['.', '', '', ''], preg_replace('/(\d)' . $thousandsSeparator . '(\d)/u', '$1$2', $value));
68+
$value = (float) ($sign . trim($temp));
6769

6870
return $this->setCurrency($value, $cell, $currencyCode ?? '');
6971
}

0 commit comments

Comments
 (0)