Skip to content

Commit a83e9fb

Browse files
authored
Merge pull request #3873 from PHPOffice/powerkiki
Remove all `mixed` in param type where reasonable (except Calculcation/)
2 parents 5faaf26 + b9901c3 commit a83e9fb

28 files changed

+80
-89
lines changed

CHANGELOG.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org).
77

88
## Unreleased - TBD
99

10-
### MINOR BREAKING CHANGE
10+
### BREAKING CHANGE
1111

12-
- Typing was strengthened by leveraging native typing. While this should not change any behavior, it might need minor
13-
adaption of your code if you use static analysis tools such as PHPStan or
14-
Psalm. [PR #3718](https://github.com/PHPOffice/PhpSpreadsheet/pull/3718)
12+
- Typing was strengthened by leveraging native typing. This should not change any behavior. However, if you implement
13+
any interfaces or inherit from any classes, you will need to adapt your typing accordingly. If you use static analysis
14+
tools such as PHPStan or Psalm, new errors might be found. If you find actual bugs because of the new typing, please
15+
open a PR that fixes it with a **detailed** explanation of the reason. We'll try to merge and release typing-related
16+
fixes quickly in the coming days. [PR #3718](https://github.com/PHPOffice/PhpSpreadsheet/pull/3718)
17+
- All deprecated things have been removed, for details, see [816b91d0b4](https://github.com/PHPOffice/PhpSpreadsheet/commit/816b91d0b4a0c7285a9e3fc88c58f7730d922044)
1518

1619
### Added
1720

@@ -33,7 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
3336

3437
### Changed
3538

36-
- Drop support for PHP 7.4, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support [PR #3713](https://github.com/PHPOffice/PhpSpreadsheet/pull/3713)
39+
- **Drop support for PHP 7.4**, according to https://phpspreadsheet.readthedocs.io/en/latest/#php-version-support [PR #3713](https://github.com/PHPOffice/PhpSpreadsheet/pull/3713)
3740
- RLM Added to NumberFormatter Currency. This happens depending on release of ICU which Php is using (it does not yet happen with any official release). PhpSpreadsheet will continue to use the value returned by Php, but a method is added to keep the result unchanged from release to release. [Issue #3571](https://github.com/PHPOffice/PhpSpreadsheet/issues/3571) [PR #3640](https://github.com/PHPOffice/PhpSpreadsheet/pull/3640)
3841
- `toFormattedString` will now always return a string. This was introduced with 1.28.0, but was not properly documented at the time. This can affect the results of `toArray`, `namedRangeToArray`, and `rangeToArray`. [PR #3304](https://github.com/PHPOffice/PhpSpreadsheet/pull/3304)
3942
- Value of constants FORMAT_CURRENCY_EUR and FORMAT_CURRENCY_USD was changed in 1.28.0, but was not properly documented at the time. [Issue #3577](https://github.com/PHPOffice/PhpSpreadsheet/issues/3577)

src/PhpSpreadsheet/Cell/AdvancedValueBinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
1717
* @param Cell $cell Cell to bind value to
1818
* @param mixed $value Value to bind in cell
1919
*/
20-
public function bindValue(Cell $cell, $value = null): bool
20+
public function bindValue(Cell $cell, mixed $value = null): bool
2121
{
2222
if ($value === null) {
2323
return parent::bindValue($cell, $value);

src/PhpSpreadsheet/Cell/CellAddress.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ public function __destruct()
3434
* @phpstan-assert int|numeric-string $columnId
3535
* @phpstan-assert int|numeric-string $rowId
3636
*/
37-
private static function validateColumnAndRow(mixed $columnId, mixed $rowId): void
37+
private static function validateColumnAndRow(int|string $columnId, int|string $rowId): void
3838
{
3939
if (!is_numeric($columnId) || $columnId <= 0 || !is_numeric($rowId) || $rowId <= 0) {
4040
throw new Exception('Row and Column Ids must be positive integer values');
4141
}
4242
}
4343

44-
public static function fromColumnAndRow(mixed $columnId, mixed $rowId, ?Worksheet $worksheet = null): self
44+
public static function fromColumnAndRow(int|string $columnId, int|string $rowId, ?Worksheet $worksheet = null): self
4545
{
4646
self::validateColumnAndRow($columnId, $rowId);
4747

48-
return new self(Coordinate::stringFromColumnIndex($columnId) . ((string) $rowId), $worksheet);
48+
return new self(Coordinate::stringFromColumnIndex($columnId) . $rowId, $worksheet);
4949
}
5050

5151
public static function fromColumnRowArray(array $array, ?Worksheet $worksheet = null): self
@@ -55,7 +55,7 @@ public static function fromColumnRowArray(array $array, ?Worksheet $worksheet =
5555
return self::fromColumnAndRow($columnId, $rowId, $worksheet);
5656
}
5757

58-
public static function fromCellAddress(mixed $cellAddress, ?Worksheet $worksheet = null): self
58+
public static function fromCellAddress(string $cellAddress, ?Worksheet $worksheet = null): self
5959
{
6060
return new self($cellAddress, $worksheet);
6161
}

src/PhpSpreadsheet/Cell/DefaultValueBinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class DefaultValueBinder implements IValueBinder
1616
* @param Cell $cell Cell to bind value to
1717
* @param mixed $value Value to bind in cell
1818
*/
19-
public function bindValue(Cell $cell, $value): bool
19+
public function bindValue(Cell $cell, mixed $value): bool
2020
{
2121
// sanitize UTF-8 strings
2222
if (is_string($value)) {

src/PhpSpreadsheet/Cell/StringValueBinder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function setConversionForAllValueTypes(bool $suppressConversion = false):
6767
* @param Cell $cell Cell to bind value to
6868
* @param mixed $value Value to bind in cell
6969
*/
70-
public function bindValue(Cell $cell, $value): bool
70+
public function bindValue(Cell $cell, mixed $value): bool
7171
{
7272
if (is_object($value)) {
7373
return $this->bindObjectValue($cell, $value);

src/PhpSpreadsheet/Chart/Axis.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ public function __construct()
112112
/**
113113
* Get Series Data Type.
114114
*/
115-
public function setAxisNumberProperties(mixed $format_code, ?bool $numeric = null, int $sourceLinked = 0): void
115+
public function setAxisNumberProperties(string $format_code, ?bool $numeric = null, int $sourceLinked = 0): void
116116
{
117-
$format = (string) $format_code;
117+
$format = $format_code;
118118
$this->axisNumber['format'] = $format;
119119
$this->axisNumber['source_linked'] = $sourceLinked;
120120
if (is_bool($numeric)) {

src/PhpSpreadsheet/Chart/Chart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class Chart
126126
* Create a new Chart.
127127
* majorGridlines and minorGridlines are deprecated, moved to Axis.
128128
*/
129-
public function __construct(mixed $name, ?Title $title = null, ?Legend $legend = null, ?PlotArea $plotArea = null, mixed $plotVisibleOnly = true, string $displayBlanksAs = DataSeries::EMPTY_AS_GAP, ?Title $xAxisLabel = null, ?Title $yAxisLabel = null, ?Axis $xAxis = null, ?Axis $yAxis = null, ?GridLines $majorGridlines = null, ?GridLines $minorGridlines = null)
129+
public function __construct(string $name, ?Title $title = null, ?Legend $legend = null, ?PlotArea $plotArea = null, bool $plotVisibleOnly = true, string $displayBlanksAs = DataSeries::EMPTY_AS_GAP, ?Title $xAxisLabel = null, ?Title $yAxisLabel = null, ?Axis $xAxis = null, ?Axis $yAxis = null, ?GridLines $majorGridlines = null, ?GridLines $minorGridlines = null)
130130
{
131131
$this->name = $name;
132132
$this->title = $title;

src/PhpSpreadsheet/Chart/DataSeries.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public function getPlotLabels(): array
232232
*
233233
* @return DataSeriesValues|false
234234
*/
235-
public function getPlotLabelByIndex(mixed $index): bool|DataSeriesValues
235+
public function getPlotLabelByIndex(int $index): bool|DataSeriesValues
236236
{
237237
$keys = array_keys($this->plotLabel);
238238
if (in_array($index, $keys)) {
@@ -257,7 +257,7 @@ public function getPlotCategories(): array
257257
*
258258
* @return DataSeriesValues|false
259259
*/
260-
public function getPlotCategoryByIndex(mixed $index): bool|DataSeriesValues
260+
public function getPlotCategoryByIndex(int $index): bool|DataSeriesValues
261261
{
262262
$keys = array_keys($this->plotCategory);
263263
if (in_array($index, $keys)) {
@@ -304,7 +304,7 @@ public function getPlotValues(): array
304304
*
305305
* @return DataSeriesValues|false
306306
*/
307-
public function getPlotValuesByIndex(mixed $index): bool|DataSeriesValues
307+
public function getPlotValuesByIndex(int $index): bool|DataSeriesValues
308308
{
309309
$keys = array_keys($this->plotValues);
310310
if (in_array($index, $keys)) {

src/PhpSpreadsheet/Chart/PlotArea.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getPlotGroup(): array
8888
/**
8989
* Get Plot Series by Index.
9090
*/
91-
public function getPlotGroupByIndex(mixed $index): DataSeries
91+
public function getPlotGroupByIndex(int $index): DataSeries
9292
{
9393
return $this->plotSeries[$index];
9494
}

src/PhpSpreadsheet/Chart/Properties.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ protected function getShadowPresetsMap(int $presetsOption): array
403403
/**
404404
* Get value of array element.
405405
*/
406-
protected function getArrayElementsValue(mixed $properties, mixed $elements): mixed
406+
protected function getArrayElementsValue(array $properties, array|int|string $elements): mixed
407407
{
408408
$reference = &$properties;
409409
if (!is_array($elements)) {

0 commit comments

Comments
 (0)