Skip to content

Commit 5c94de3

Browse files
committed
More Phpstan Level 10 Prep - Readers
Also upgrade Phpstan.
1 parent c886276 commit 5c94de3

Some content is hidden

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

73 files changed

+714
-232
lines changed

composer.lock

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

phpstan-baseline.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
parameters:
2-
ignoreErrors:
2+
ignoreErrors: []

src/PhpSpreadsheet/Cell/AdvancedValueBinder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function bindValue(Cell $cell, mixed $value = null): bool
110110
return parent::bindValue($cell, $value);
111111
}
112112

113-
/** @param array{0: non-falsy-string, 1: ?string, 2: numeric-string, 3: numeric-string, 4: numeric-string} $matches */
113+
/** @param array{0: string, 1: ?string, 2: numeric-string, 3: numeric-string, 4: numeric-string} $matches */
114114
protected function setImproperFraction(array $matches, Cell $cell): bool
115115
{
116116
// Convert value to number
@@ -131,7 +131,7 @@ protected function setImproperFraction(array $matches, Cell $cell): bool
131131
return true;
132132
}
133133

134-
/** @param array{0: non-falsy-string, 1: ?string, 2: numeric-string, 3: numeric-string} $matches */
134+
/** @param array{0: string, 1: ?string, 2: numeric-string, 3: numeric-string} $matches */
135135
protected function setProperFraction(array $matches, Cell $cell): bool
136136
{
137137
// Convert value to number

src/PhpSpreadsheet/Cell/Cell.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,9 @@ public function getCalculatedValue(bool $resetLog = true): mixed
497497
if (isset($matches[3])) {
498498
$minCol = $matches[1];
499499
$minRow = (int) $matches[2];
500-
// https://github.com/phpstan/phpstan/issues/11602
501-
$maxCol = $matches[4]; // @phpstan-ignore-line
500+
$maxCol = $matches[4];
502501
++$maxCol;
503-
$maxRow = (int) $matches[5]; // @phpstan-ignore-line
502+
$maxRow = (int) $matches[5];
504503
for ($row = $minRow; $row <= $maxRow; ++$row) {
505504
for ($col = $minCol; $col !== $maxCol; ++$col) {
506505
if ("$col$row" !== $coordinate) {

src/PhpSpreadsheet/Chart/ChartColor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ChartColor
2222
private ?int $brightness = null;
2323

2424
/**
25-
* @param string|string[] $value
25+
* @param array{value: ?string, alpha: null|int|string, brightness?: null|int|string, type: ?string}|string $value
2626
*/
2727
public function __construct($value = '', ?int $alpha = null, ?string $type = null, ?int $brightness = null)
2828
{
@@ -114,6 +114,7 @@ public function setColorProperties(?string $color, null|float|int|string $alpha
114114
return $this;
115115
}
116116

117+
/** @param array{value: ?string, alpha: null|int|string, brightness?: null|int|string, type: ?string} $color */
117118
public function setColorPropertiesArray(array $color): self
118119
{
119120
return $this->setColorProperties(

src/PhpSpreadsheet/Chart/Properties.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public static function xmlToTenthOfPercent(string $value): float
177177
return ((float) $value) / self::PERCENTAGE_MULTIPLIER;
178178
}
179179

180+
/** @return array{type: ?string, value: ?string, alpha: ?int} */
180181
protected function setColorProperties(?string $color, null|float|int|string $alpha, ?string $colorType): array
181182
{
182183
return [
@@ -506,11 +507,14 @@ public function getSoftEdgesSize(): ?float
506507
return $this->softEdges['size'];
507508
}
508509

510+
/** @param null|array{value?: ?string, alpha?: null|int|string, brightness?: null|int|string, type?: ?string}|float|string $value */
509511
public function setShadowProperty(string $propertyName, mixed $value): self
510512
{
511513
$this->activateObject();
512514
if ($propertyName === 'color' && is_array($value)) {
513-
$this->shadowColor->setColorPropertiesArray($value);
515+
/** @var array{value: ?string, alpha: null|int|string, brightness?: null|int|string, type: ?string} */
516+
$valuex = $value;
517+
$this->shadowColor->setColorPropertiesArray($valuex);
514518
} else {
515519
$this->shadowProperties[$propertyName] = $value;
516520
}

src/PhpSpreadsheet/Helper/Html.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ class Html
557557
/** @var callable[] */
558558
protected array $endTagCallbacks;
559559

560+
/** @var mixed[] */
560561
private array $stack = [];
561562

562563
public string $stringData = '';
@@ -711,7 +712,10 @@ private function rgbToColour(string $rgbValue): string
711712

712713
public static function colourNameLookup(string $colorName): string
713714
{
714-
return static::COLOUR_MAP[$colorName] ?? '';
715+
/** @var string[] */
716+
$temp = static::COLOUR_MAP;
717+
718+
return $temp[$colorName] ?? '';
715719
}
716720

717721
protected function startFontTag(DOMElement $tag): void

src/PhpSpreadsheet/Helper/Sample.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ public function titles(string $category, string $functionName, ?string $descript
241241
: $this->log(sprintf('Function: %s() - %s.', rtrim($functionName, '()'), rtrim($description, '.')));
242242
}
243243

244+
/** @param mixed[][] $matrix */
244245
public function displayGrid(array $matrix): void
245246
{
246247
$renderer = new TextGrid($matrix, $this->isCli());

src/PhpSpreadsheet/Helper/TextGrid.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ class TextGrid
88
{
99
private bool $isCli;
1010

11+
/** @var mixed[][] */
1112
protected array $matrix;
1213

14+
/** @var int[] */
1315
protected array $rows;
1416

17+
/** @var string[] */
1518
protected array $columns;
1619

1720
private string $gridDisplay;
@@ -22,6 +25,7 @@ class TextGrid
2225

2326
private bool $columnHeaders = true;
2427

28+
/** @param mixed[][] $matrix */
2529
public function __construct(array $matrix, bool $isCli = true, bool $rowDividers = false, bool $rowHeaders = true, bool $columnHeaders = true)
2630
{
2731
$this->rows = array_keys($matrix);
@@ -63,6 +67,7 @@ public function render(): string
6367
return $this->gridDisplay;
6468
}
6569

70+
/** @param int[] $columnWidths */
6671
private function renderRows(int $maxRowLength, array $columnWidths): void
6772
{
6873
foreach ($this->matrix as $row => $rowData) {
@@ -77,6 +82,10 @@ private function renderRows(int $maxRowLength, array $columnWidths): void
7782
}
7883
}
7984

85+
/**
86+
* @param mixed[] $rowData
87+
* @param int[] $columnWidths
88+
*/
8089
private function renderCells(array $rowData, array $columnWidths): void
8190
{
8291
foreach ($rowData as $column => $cell) {
@@ -87,6 +96,7 @@ private function renderCells(array $rowData, array $columnWidths): void
8796
}
8897
}
8998

99+
/** @param int[] $columnWidths */
90100
private function renderColumnHeader(int $maxRowLength, array &$columnWidths): void
91101
{
92102
if (!$this->columnHeaders) {
@@ -95,6 +105,7 @@ private function renderColumnHeader(int $maxRowLength, array &$columnWidths): vo
95105
return;
96106
}
97107
foreach ($this->columns as $column => $reference) {
108+
/** @var string $reference */
98109
$columnWidths[$column] = max($columnWidths[$column], $this->strlen($reference));
99110
}
100111
if ($this->rowHeaders) {
@@ -109,13 +120,15 @@ private function renderColumnHeader(int $maxRowLength, array &$columnWidths): vo
109120
$this->gridDisplay .= str_repeat(' ', $maxRowLength + 2);
110121
}
111122
foreach ($this->columns as $column => $reference) {
123+
/** @var scalar $reference */
112124
$this->gridDisplay .= '| ' . str_pad((string) $reference, $columnWidths[$column] + 1, ' ');
113125
}
114126
$this->gridDisplay .= '|' . PHP_EOL;
115127

116128
$this->renderFooter($maxRowLength, $columnWidths);
117129
}
118130

131+
/** @param int[] $columnWidths */
119132
private function renderFooter(int $maxRowLength, array $columnWidths): void
120133
{
121134
if ($this->rowHeaders) {
@@ -128,6 +141,7 @@ private function renderFooter(int $maxRowLength, array $columnWidths): void
128141
$this->gridDisplay .= '+' . PHP_EOL;
129142
}
130143

144+
/** @return int[] */
131145
private function getColumnWidths(): array
132146
{
133147
$columnCount = count($this->matrix, COUNT_RECURSIVE) / count($this->matrix);
@@ -139,6 +153,7 @@ private function getColumnWidths(): array
139153
return $columnWidths;
140154
}
141155

156+
/** @param mixed[] $columnData */
142157
private function getColumnWidth(array $columnData): int
143158
{
144159
$columnWidth = 0;

src/PhpSpreadsheet/IOFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ public static function load(string $filename, int $flags = 0, ?array $readers =
116116

117117
/**
118118
* Identify file type using automatic IReader resolution.
119+
*
120+
* @param string[] $readers
119121
*/
120122
public static function identify(string $filename, ?array $readers = null, bool $fullClassName = false): string
121123
{

0 commit comments

Comments
 (0)