Skip to content

Commit d51bf5f

Browse files
authored
Merge pull request #4429 from oleibman/stan2lv909
Phpstan Level 9: Last
2 parents b8bba64 + 7fb9a5a commit d51bf5f

File tree

20 files changed

+80
-317
lines changed

20 files changed

+80
-317
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.

phpstan-baseline.neon

Lines changed: 0 additions & 269 deletions
Original file line numberDiff line numberDiff line change
@@ -1,271 +1,2 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: '#^Method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\Hyperlink\:\:set\(\) should return string but returns mixed\.$#'
5-
identifier: return.type
6-
count: 1
7-
path: src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php
8-
9-
-
10-
message: '#^Parameter \#1 \$string of function trim expects string, mixed given\.$#'
11-
identifier: argument.type
12-
count: 2
13-
path: src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php
14-
15-
-
16-
message: '#^Parameter \#1 \$tooltip of method PhpOffice\\PhpSpreadsheet\\Cell\\Hyperlink\:\:setTooltip\(\) expects string, mixed given\.$#'
17-
identifier: argument.type
18-
count: 1
19-
path: src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php
20-
21-
-
22-
message: '#^Parameter \#1 \$url of method PhpOffice\\PhpSpreadsheet\\Cell\\Hyperlink\:\:setUrl\(\) expects string, mixed given\.$#'
23-
identifier: argument.type
24-
count: 1
25-
path: src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php
26-
27-
-
28-
message: '#^Parameter \#1 \$lookupVector of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\Lookup\:\:verifyLookupValues\(\) expects array, mixed given\.$#'
29-
identifier: argument.type
30-
count: 1
31-
path: src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php
32-
33-
-
34-
message: '#^Parameter \#1 \$resultVector of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\Lookup\:\:verifyResultVector\(\) expects array, mixed given\.$#'
35-
identifier: argument.type
36-
count: 1
37-
path: src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php
38-
39-
-
40-
message: '#^Parameter \#2 \$resultVector of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\Lookup\:\:verifyLookupValues\(\) expects array, mixed given\.$#'
41-
identifier: argument.type
42-
count: 1
43-
path: src/PhpSpreadsheet/Calculation/LookupRef/Lookup.php
44-
45-
-
46-
message: '#^Parameter \#1 \$message of class PhpOffice\\PhpSpreadsheet\\Calculation\\Exception constructor expects string, mixed given\.$#'
47-
identifier: argument.type
48-
count: 1
49-
path: src/PhpSpreadsheet/Calculation/LookupRef/LookupRefValidations.php
50-
51-
-
52-
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
53-
identifier: foreach.nonIterable
54-
count: 1
55-
path: src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php
56-
57-
-
58-
message: '#^Cannot access offset int\|string on mixed\.$#'
59-
identifier: offsetAccess.nonOffsetAccessible
60-
count: 1
61-
path: src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php
62-
63-
-
64-
message: '#^Parameter \#1 \$array of function array_keys expects array, mixed given\.$#'
65-
identifier: argument.type
66-
count: 1
67-
path: src/PhpSpreadsheet/Calculation/LookupRef/Matrix.php
68-
69-
-
70-
message: '#^Binary operation "\+\=" between int and mixed results in an error\.$#'
71-
identifier: assignOp.invalid
72-
count: 1
73-
path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php
74-
75-
-
76-
message: '#^Binary operation "\+\=" between mixed and int results in an error\.$#'
77-
identifier: assignOp.invalid
78-
count: 1
79-
path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php
80-
81-
-
82-
message: '#^Binary operation "\-" between mixed and 1 results in an error\.$#'
83-
identifier: binaryOp.invalid
84-
count: 1
85-
path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php
86-
87-
-
88-
message: '#^Cannot cast mixed to int\.$#'
89-
identifier: cast.int
90-
count: 4
91-
path: src/PhpSpreadsheet/Calculation/LookupRef/Offset.php
92-
93-
-
94-
message: '#^Parameter \#1 \$sortIndex of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\Sort\:\:validateArrayArgumentsForSort\(\) expects array, mixed given\.$#'
95-
identifier: argument.type
96-
count: 1
97-
path: src/PhpSpreadsheet/Calculation/LookupRef/Sort.php
98-
99-
-
100-
message: '#^Parameter \#3 \$sortOrder of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\Sort\:\:sortByColumn\(\) expects array\<int\>, mixed given\.$#'
101-
identifier: argument.type
102-
count: 1
103-
path: src/PhpSpreadsheet/Calculation/LookupRef/Sort.php
104-
105-
-
106-
message: '#^Parameter \#3 \$sortOrder of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\Sort\:\:sortByRow\(\) expects array\<int\>, mixed given\.$#'
107-
identifier: argument.type
108-
count: 1
109-
path: src/PhpSpreadsheet/Calculation/LookupRef/Sort.php
110-
111-
-
112-
message: '#^Cannot access offset \(int\|string\) on mixed\.$#'
113-
identifier: offsetAccess.nonOffsetAccessible
114-
count: 1
115-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
116-
117-
-
118-
message: '#^Cannot access offset int on mixed\.$#'
119-
identifier: offsetAccess.nonOffsetAccessible
120-
count: 1
121-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
122-
123-
-
124-
message: '#^Cannot access offset int\|string\|null on mixed\.$#'
125-
identifier: offsetAccess.nonOffsetAccessible
126-
count: 1
127-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
128-
129-
-
130-
message: '#^Cannot cast mixed to string\.$#'
131-
identifier: cast.string
132-
count: 1
133-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
134-
135-
-
136-
message: '#^Parameter \#1 \$array of function array_keys expects array, mixed given\.$#'
137-
identifier: argument.type
138-
count: 1
139-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
140-
141-
-
142-
message: '#^Parameter \#1 \$array of function uasort expects TArray of array\<TKey of int\|string, mixed\>, mixed given\.$#'
143-
identifier: argument.type
144-
count: 1
145-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
146-
147-
-
148-
message: '#^Parameter \#1 \$lookup_array of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\LookupBase\:\:validateIndexLookup\(\) expects array, mixed given\.$#'
149-
identifier: argument.type
150-
count: 1
151-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
152-
153-
-
154-
message: '#^Parameter \#2 \$index_number of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\LookupBase\:\:validateIndexLookup\(\) expects float\|int\|string, mixed given\.$#'
155-
identifier: argument.type
156-
count: 1
157-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
158-
159-
-
160-
message: '#^Parameter \#2 \$lookupArray of static method PhpOffice\\PhpSpreadsheet\\Calculation\\LookupRef\\VLookup\:\:vLookupSearch\(\) expects array, mixed given\.$#'
161-
identifier: argument.type
162-
count: 1
163-
path: src/PhpSpreadsheet/Calculation/LookupRef/VLookup.php
164-
165-
-
166-
message: '#^Cannot call method getWorksheet\(\) on mixed\.$#'
167-
identifier: method.nonObject
168-
count: 4
169-
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
170-
171-
-
172-
message: '#^Method PhpOffice\\PhpSpreadsheet\\Calculation\\MathTrig\\Subtotal\:\:evaluate\(\) should return float\|int\|string but returns mixed\.$#'
173-
identifier: return.type
174-
count: 1
175-
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
176-
177-
-
178-
message: '#^Parameter \#1 \$array of function array_filter expects array, mixed given\.$#'
179-
identifier: argument.type
180-
count: 2
181-
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
182-
183-
-
184-
message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#'
185-
identifier: argument.type
186-
count: 2
187-
path: src/PhpSpreadsheet/Calculation/MathTrig/Subtotal.php
188-
189-
-
190-
message: '#^Binary operation "\+\=" between \(float\|int\) and mixed results in an error\.$#'
191-
identifier: assignOp.invalid
192-
count: 1
193-
path: src/PhpSpreadsheet/Calculation/Statistical/Averages.php
194-
195-
-
196-
message: '#^Binary operation "\-" between mixed and float\|int\|string results in an error\.$#'
197-
identifier: binaryOp.invalid
198-
count: 1
199-
path: src/PhpSpreadsheet/Calculation/Statistical/Averages.php
200-
201-
-
202-
message: '#^Parameter \#2 \$condition of static method PhpOffice\\PhpSpreadsheet\\Calculation\\Statistical\\Conditional\:\:AVERAGEIF\(\) expects array\|string\|null, mixed given\.$#'
203-
identifier: argument.type
204-
count: 1
205-
path: src/PhpSpreadsheet/Calculation/Statistical/Conditional.php
206-
207-
-
208-
message: '#^Method PhpOffice\\PhpSpreadsheet\\Calculation\\Statistical\\Confidence\:\:CONFIDENCE\(\) should return array\|float\|string but returns mixed\.$#'
209-
identifier: return.type
210-
count: 1
211-
path: src/PhpSpreadsheet/Calculation/Statistical/Confidence.php
212-
213-
-
214-
message: '#^Method PhpOffice\\PhpSpreadsheet\\Calculation\\Statistical\\Distributions\\ChiSquared\:\:test\(\) should return float\|string but returns mixed\.$#'
215-
identifier: return.type
216-
count: 1
217-
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php
218-
219-
-
220-
message: '#^Parameter \#1 \$value of function count expects array\|Countable, mixed given\.$#'
221-
identifier: argument.type
222-
count: 1
223-
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/ChiSquared.php
224-
225-
-
226-
message: '#^Binary operation "\*" between 2 and mixed results in an error\.$#'
227-
identifier: binaryOp.invalid
228-
count: 2
229-
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php
230-
231-
-
232-
message: '#^Binary operation "\+" between 1 and mixed results in an error\.$#'
233-
identifier: binaryOp.invalid
234-
count: 1
235-
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php
236-
237-
-
238-
message: '#^Binary operation "\-" between 1 and mixed results in an error\.$#'
239-
identifier: binaryOp.invalid
240-
count: 1
241-
path: src/PhpSpreadsheet/Calculation/Statistical/Distributions/Fisher.php
242-
243-
-
244-
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
245-
identifier: foreach.nonIterable
246-
count: 1
247-
path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php
248-
249-
-
250-
message: '#^Parameter \#1 \$yValues of static method PhpOffice\\PhpSpreadsheet\\Calculation\\Statistical\\Trends\:\:validateTrendArrays\(\) expects array, mixed given\.$#'
251-
identifier: argument.type
252-
count: 9
253-
path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php
254-
255-
-
256-
message: '#^Parameter \#2 \$xValues of static method PhpOffice\\PhpSpreadsheet\\Calculation\\Statistical\\Trends\:\:validateTrendArrays\(\) expects array, mixed given\.$#'
257-
identifier: argument.type
258-
count: 9
259-
path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php
260-
261-
-
262-
message: '#^Parameter \#2 \$yValues of static method PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\Trend\:\:calculate\(\) expects array, mixed given\.$#'
263-
identifier: argument.type
264-
count: 9
265-
path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php
266-
267-
-
268-
message: '#^Parameter \#3 \$xValues of static method PhpOffice\\PhpSpreadsheet\\Shared\\Trend\\Trend\:\:calculate\(\) expects array, mixed given\.$#'
269-
identifier: argument.type
270-
count: 9
271-
path: src/PhpSpreadsheet/Calculation/Statistical/Trends.php

samples/Wizards/NumberFormat/Accounting.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
<?php
22

33
use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException;
4-
use PhpOffice\PhpSpreadsheet\Helper\Sample;
54
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
65
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
76
use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;
87

98
require __DIR__ . '/../Header.php';
109

11-
$helper = new Sample();
1210
if ($helper->isCli()) {
1311
$helper->log('This example should only be run from a Web Browser' . PHP_EOL);
1412

@@ -60,7 +58,7 @@
6058
<div class="mb-3 row">
6159
<label for="position" class="col-sm-2 col-form-label">Currency Position</label>
6260
<div class="col-sm-10">
63-
<input name="position" type="radio" value="1" <?php echo ((isset($_POST['position']) === false) || (isset($_POST['position']) && $_POST['position'] === '1')) ? 'checked' : ''; ?>>Leading
61+
<input name="position" type="radio" value="1" <?php echo ((isset($_POST['position']) === false) || ($_POST['position'] === '1')) ? 'checked' : ''; ?>>Leading
6462
<input name="position" type="radio" value="0" <?php echo (isset($_POST['position']) && $_POST['position'] === '0') ? 'checked' : ''; ?>>Trailing
6563
</div>
6664
</div>

samples/Wizards/NumberFormat/Currency.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
use PhpOffice\PhpSpreadsheet\Exception as SpreadsheetException;
4-
use PhpOffice\PhpSpreadsheet\Helper\Sample;
54
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
65
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
76
use PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;
@@ -10,7 +9,6 @@
109

1110
require __DIR__ . '/../Header.php';
1211

13-
$helper = new Sample();
1412
if ($helper->isCli()) {
1513
$helper->log('This example should only be run from a Web Browser' . PHP_EOL);
1614

@@ -75,7 +73,7 @@
7573
<div class="mb-3 row">
7674
<label for="position" class="col-sm-2 col-form-label">Currency Position</label>
7775
<div class="col-sm-10">
78-
<input name="position" type="radio" value="1" <?php echo ((isset($_POST['position']) === false) || (isset($_POST['position']) && $_POST['position'] === '1')) ? 'checked' : ''; ?>>Leading
76+
<input name="position" type="radio" value="1" <?php echo ((isset($_POST['position']) === false) || ($_POST['position'] === '1')) ? 'checked' : ''; ?>>Leading
7977
<input name="position" type="radio" value="0" <?php echo (isset($_POST['position']) && $_POST['position'] === '0') ? 'checked' : ''; ?>>Trailing
8078
</div>
8179
</div>

src/PhpSpreadsheet/Calculation/LookupRef/Hyperlink.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
66
use PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;
77
use PhpOffice\PhpSpreadsheet\Cell\Cell;
8+
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
89

910
class Hyperlink
1011
{
@@ -22,18 +23,23 @@ class Hyperlink
2223
*/
2324
public static function set(mixed $linkURL = '', mixed $displayName = null, ?Cell $cell = null): string
2425
{
25-
$linkURL = ($linkURL === null) ? '' : Functions::flattenSingleValue($linkURL);
26+
$linkURL = ($linkURL === null) ? '' : StringHelper::convertToString(Functions::flattenSingleValue($linkURL));
2627
$displayName = ($displayName === null) ? '' : Functions::flattenSingleValue($displayName);
2728

2829
if ((!is_object($cell)) || (trim($linkURL) == '')) {
2930
return ExcelError::REF();
3031
}
3132

32-
if ((is_object($displayName)) || trim($displayName) == '') {
33+
if (is_object($displayName)) {
34+
$displayName = $linkURL;
35+
}
36+
$displayName = StringHelper::convertToString($displayName);
37+
if (trim($displayName) === '') {
3338
$displayName = $linkURL;
3439
}
3540

36-
$cell->getHyperlink()->setUrl($linkURL);
41+
$cell->getHyperlink()
42+
->setUrl($linkURL);
3743
$cell->getHyperlink()->setTooltip($displayName);
3844

3945
return $displayName;

0 commit comments

Comments
 (0)