Skip to content

Commit 06ddcfb

Browse files
committed
Phpstan Level 9 - Part 4 of Many
Mostly Calculation/Calculation.
1 parent 74dca30 commit 06ddcfb

File tree

3 files changed

+67
-367
lines changed

3 files changed

+67
-367
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 330 deletions
Original file line numberDiff line numberDiff line change
@@ -1,323 +1,5 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: '#^Parameter \#1 \$str1 of static method PhpOffice\\PhpSpreadsheet\\Calculation\\BinaryComparison\:\:strcmpAllowNull\(\) expects string\|null, mixed given\.$#'
5-
identifier: argument.type
6-
count: 3
7-
path: src/PhpSpreadsheet/Calculation/BinaryComparison.php
8-
9-
-
10-
message: '#^Parameter \#1 \$str1 of static method PhpOffice\\PhpSpreadsheet\\Calculation\\BinaryComparison\:\:strcmpLowercaseFirst\(\) expects string\|null, mixed given\.$#'
11-
identifier: argument.type
12-
count: 2
13-
path: src/PhpSpreadsheet/Calculation/BinaryComparison.php
14-
15-
-
16-
message: '#^Parameter \#2 \$str2 of static method PhpOffice\\PhpSpreadsheet\\Calculation\\BinaryComparison\:\:strcmpAllowNull\(\) expects string\|null, mixed given\.$#'
17-
identifier: argument.type
18-
count: 3
19-
path: src/PhpSpreadsheet/Calculation/BinaryComparison.php
20-
21-
-
22-
message: '#^Parameter \#2 \$str2 of static method PhpOffice\\PhpSpreadsheet\\Calculation\\BinaryComparison\:\:strcmpLowercaseFirst\(\) expects string\|null, mixed given\.$#'
23-
identifier: argument.type
24-
count: 2
25-
path: src/PhpSpreadsheet/Calculation/BinaryComparison.php
26-
27-
-
28-
message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#'
29-
identifier: foreach.nonIterable
30-
count: 4
31-
path: src/PhpSpreadsheet/Calculation/Calculation.php
32-
33-
-
34-
message: '#^Binary operation "\*" between mixed and mixed results in an error\.$#'
35-
identifier: binaryOp.invalid
36-
count: 1
37-
path: src/PhpSpreadsheet/Calculation/Calculation.php
38-
39-
-
40-
message: '#^Binary operation "\*\*" between mixed and mixed results in an error\.$#'
41-
identifier: binaryOp.invalid
42-
count: 2
43-
path: src/PhpSpreadsheet/Calculation/Calculation.php
44-
45-
-
46-
message: '#^Binary operation "\*\=" between mixed and \-1\|0\.01 results in an error\.$#'
47-
identifier: assignOp.invalid
48-
count: 1
49-
path: src/PhpSpreadsheet/Calculation/Calculation.php
50-
51-
-
52-
message: '#^Binary operation "\*\=" between mixed and mixed results in an error\.$#'
53-
identifier: assignOp.invalid
54-
count: 1
55-
path: src/PhpSpreadsheet/Calculation/Calculation.php
56-
57-
-
58-
message: '#^Binary operation "\+" between mixed and 1 results in an error\.$#'
59-
identifier: binaryOp.invalid
60-
count: 2
61-
path: src/PhpSpreadsheet/Calculation/Calculation.php
62-
63-
-
64-
message: '#^Binary operation "\+" between mixed and mixed results in an error\.$#'
65-
identifier: binaryOp.invalid
66-
count: 1
67-
path: src/PhpSpreadsheet/Calculation/Calculation.php
68-
69-
-
70-
message: '#^Binary operation "\+\=" between mixed and mixed results in an error\.$#'
71-
identifier: assignOp.invalid
72-
count: 1
73-
path: src/PhpSpreadsheet/Calculation/Calculation.php
74-
75-
-
76-
message: '#^Binary operation "\-" between mixed and mixed results in an error\.$#'
77-
identifier: binaryOp.invalid
78-
count: 1
79-
path: src/PhpSpreadsheet/Calculation/Calculation.php
80-
81-
-
82-
message: '#^Binary operation "\-\=" between mixed and mixed results in an error\.$#'
83-
identifier: assignOp.invalid
84-
count: 1
85-
path: src/PhpSpreadsheet/Calculation/Calculation.php
86-
87-
-
88-
message: '#^Binary operation "\." between ''Pruned branch \(only…'' and mixed results in an error\.$#'
89-
identifier: binaryOp.invalid
90-
count: 2
91-
path: src/PhpSpreadsheet/Calculation/Calculation.php
92-
93-
-
94-
message: '#^Binary operation "\." between ''a '' and mixed results in an error\.$#'
95-
identifier: binaryOp.invalid
96-
count: 1
97-
path: src/PhpSpreadsheet/Calculation/Calculation.php
98-
99-
-
100-
message: '#^Binary operation "\." between ''a boolean with a…''\|''a floating point…''\|''a matrix with a…''\|''a string with a…''\|''an integer number…'' and mixed results in an error\.$#'
101-
identifier: binaryOp.invalid
102-
count: 1
103-
path: src/PhpSpreadsheet/Calculation/Calculation.php
104-
105-
-
106-
message: '#^Binary operation "\." between ''onlyIf\-'' and mixed results in an error\.$#'
107-
identifier: binaryOp.invalid
108-
count: 4
109-
path: src/PhpSpreadsheet/Calculation/Calculation.php
110-
111-
-
112-
message: '#^Binary operation "\." between ''onlyIfNot\-'' and mixed results in an error\.$#'
113-
identifier: binaryOp.invalid
114-
count: 4
115-
path: src/PhpSpreadsheet/Calculation/Calculation.php
116-
117-
-
118-
message: '#^Binary operation "\." between mixed and mixed results in an error\.$#'
119-
identifier: binaryOp.invalid
120-
count: 2
121-
path: src/PhpSpreadsheet/Calculation/Calculation.php
122-
123-
-
124-
message: '#^Binary operation "\." between non\-falsy\-string and mixed results in an error\.$#'
125-
identifier: binaryOp.invalid
126-
count: 2
127-
path: src/PhpSpreadsheet/Calculation/Calculation.php
128-
129-
-
130-
message: '#^Binary operation "/" between mixed and mixed results in an error\.$#'
131-
identifier: binaryOp.invalid
132-
count: 1
133-
path: src/PhpSpreadsheet/Calculation/Calculation.php
134-
135-
-
136-
message: '#^Binary operation "/\=" between mixed and mixed results in an error\.$#'
137-
identifier: assignOp.invalid
138-
count: 1
139-
path: src/PhpSpreadsheet/Calculation/Calculation.php
140-
141-
-
142-
message: '#^Cannot access offset ''onlyIf'' on mixed\.$#'
143-
identifier: offsetAccess.nonOffsetAccessible
144-
count: 1
145-
path: src/PhpSpreadsheet/Calculation/Calculation.php
146-
147-
-
148-
message: '#^Cannot access offset ''onlyIfNot'' on mixed\.$#'
149-
identifier: offsetAccess.nonOffsetAccessible
150-
count: 1
151-
path: src/PhpSpreadsheet/Calculation/Calculation.php
152-
153-
-
154-
message: '#^Cannot access offset ''reference'' on mixed\.$#'
155-
identifier: offsetAccess.nonOffsetAccessible
156-
count: 3
157-
path: src/PhpSpreadsheet/Calculation/Calculation.php
158-
159-
-
160-
message: '#^Cannot access offset ''storeKey'' on mixed\.$#'
161-
identifier: offsetAccess.nonOffsetAccessible
162-
count: 1
163-
path: src/PhpSpreadsheet/Calculation/Calculation.php
164-
165-
-
166-
message: '#^Cannot access offset ''type'' on mixed\.$#'
167-
identifier: offsetAccess.nonOffsetAccessible
168-
count: 3
169-
path: src/PhpSpreadsheet/Calculation/Calculation.php
170-
171-
-
172-
message: '#^Cannot access offset ''value'' on mixed\.$#'
173-
identifier: offsetAccess.nonOffsetAccessible
174-
count: 1
175-
path: src/PhpSpreadsheet/Calculation/Calculation.php
176-
177-
-
178-
message: '#^Cannot access offset \(float\|int\) on mixed\.$#'
179-
identifier: offsetAccess.nonOffsetAccessible
180-
count: 1
181-
path: src/PhpSpreadsheet/Calculation/Calculation.php
182-
183-
-
184-
message: '#^Cannot access offset \(int\|string\) on mixed\.$#'
185-
identifier: offsetAccess.nonOffsetAccessible
186-
count: 2
187-
path: src/PhpSpreadsheet/Calculation/Calculation.php
188-
189-
-
190-
message: '#^Cannot access offset 0 on mixed\.$#'
191-
identifier: offsetAccess.nonOffsetAccessible
192-
count: 4
193-
path: src/PhpSpreadsheet/Calculation/Calculation.php
194-
195-
-
196-
message: '#^Cannot access offset int\<0, max\> on mixed\.$#'
197-
identifier: offsetAccess.nonOffsetAccessible
198-
count: 41
199-
path: src/PhpSpreadsheet/Calculation/Calculation.php
200-
201-
-
202-
message: '#^Cannot access offset mixed on mixed\.$#'
203-
identifier: offsetAccess.nonOffsetAccessible
204-
count: 2
205-
path: src/PhpSpreadsheet/Calculation/Calculation.php
206-
207-
-
208-
message: '#^Cannot call method push\(\) on mixed\.$#'
209-
identifier: method.nonObject
210-
count: 4
211-
path: src/PhpSpreadsheet/Calculation/Calculation.php
212-
213-
-
214-
message: '#^Method PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation\:\:makeError\(\) should return string but returns mixed\.$#'
215-
identifier: return.type
216-
count: 1
217-
path: src/PhpSpreadsheet/Calculation/Calculation.php
218-
219-
-
220-
message: '#^Parameter \#1 \$array of function array_intersect_key expects array, mixed given\.$#'
221-
identifier: argument.type
222-
count: 2
223-
path: src/PhpSpreadsheet/Calculation/Calculation.php
224-
225-
-
226-
message: '#^Parameter \#1 \$branchPruningEnabled of class PhpOffice\\PhpSpreadsheet\\Calculation\\Engine\\BranchPruner constructor expects bool, mixed given\.$#'
227-
identifier: argument.type
228-
count: 1
229-
path: src/PhpSpreadsheet/Calculation/Calculation.php
230-
231-
-
232-
message: '#^Parameter \#1 \$columnAddress of static method PhpOffice\\PhpSpreadsheet\\Cell\\Coordinate\:\:columnIndexFromString\(\) expects string\|null, mixed given\.$#'
233-
identifier: argument.type
234-
count: 1
235-
path: src/PhpSpreadsheet/Calculation/Calculation.php
236-
237-
-
238-
message: '#^Parameter \#1 \$formula of method PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation\:\:_calculateFormulaValue\(\) expects string, mixed given\.$#'
239-
identifier: argument.type
240-
count: 1
241-
path: src/PhpSpreadsheet/Calculation/Calculation.php
242-
243-
-
244-
message: '#^Parameter \#1 \$matrix of static method PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation\:\:getMatrixDimensions\(\) expects array, mixed given\.$#'
245-
identifier: argument.type
246-
count: 1
247-
path: src/PhpSpreadsheet/Calculation/Calculation.php
248-
249-
-
250-
message: '#^Parameter \#1 \$operand of static method PhpOffice\\PhpSpreadsheet\\Calculation\\Engine\\FormattedNumber\:\:convertToNumberIfFormatted\(\) expects string, mixed given\.$#'
251-
identifier: argument.type
252-
count: 1
253-
path: src/PhpSpreadsheet/Calculation/Calculation.php
254-
255-
-
256-
message: '#^Parameter \#1 \$string of function strtoupper expects string, mixed given\.$#'
257-
identifier: argument.type
258-
count: 2
259-
path: src/PhpSpreadsheet/Calculation/Calculation.php
260-
261-
-
262-
message: '#^Parameter \#1 \$type of method PhpOffice\\PhpSpreadsheet\\Calculation\\Token\\Stack\:\:push\(\) expects string, mixed given\.$#'
263-
identifier: argument.type
264-
count: 1
265-
path: src/PhpSpreadsheet/Calculation/Calculation.php
266-
267-
-
268-
message: '#^Parameter \#1 \$worksheetName of method PhpOffice\\PhpSpreadsheet\\Spreadsheet\:\:getSheetByName\(\) expects string, mixed given\.$#'
269-
identifier: argument.type
270-
count: 1
271-
path: src/PhpSpreadsheet/Calculation/Calculation.php
272-
273-
-
274-
message: '#^Parameter \#2 \$subject of function preg_match expects string, mixed given\.$#'
275-
identifier: argument.type
276-
count: 3
277-
path: src/PhpSpreadsheet/Calculation/Calculation.php
278-
279-
-
280-
message: '#^Parameter \#2 \.\.\.\$arrays of function array_intersect_key expects array, mixed given\.$#'
281-
identifier: argument.type
282-
count: 2
283-
path: src/PhpSpreadsheet/Calculation/Calculation.php
284-
285-
-
286-
message: '#^Parameter \#3 \$reference of method PhpOffice\\PhpSpreadsheet\\Calculation\\Token\\Stack\:\:push\(\) expects string\|null, mixed given\.$#'
287-
identifier: argument.type
288-
count: 1
289-
path: src/PhpSpreadsheet/Calculation/Calculation.php
290-
291-
-
292-
message: '#^Parameter \#3 \$subject of function preg_replace_callback expects array\<float\|int\|string\>\|string, mixed given\.$#'
293-
identifier: argument.type
294-
count: 1
295-
path: src/PhpSpreadsheet/Calculation/Calculation.php
296-
297-
-
298-
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, mixed given\.$#'
299-
identifier: argument.type
300-
count: 1
301-
path: src/PhpSpreadsheet/Calculation/Calculation.php
302-
303-
-
304-
message: '#^Parameter &\$stack by\-ref type of method PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation\:\:executeNumericBinaryOperation\(\) expects PhpOffice\\PhpSpreadsheet\\Calculation\\Token\\Stack, mixed given\.$#'
305-
identifier: parameterByRef.type
306-
count: 2
307-
path: src/PhpSpreadsheet/Calculation/Calculation.php
308-
309-
-
310-
message: '#^Part \$token \(mixed\) of encapsed string cannot be cast to string\.$#'
311-
identifier: encapsedStringPart.nonString
312-
count: 2
313-
path: src/PhpSpreadsheet/Calculation/Calculation.php
314-
315-
-
316-
message: '#^Property PhpOffice\\PhpSpreadsheet\\Calculation\\Calculation\:\:\$branchPruningEnabled \(bool\) does not accept mixed\.$#'
317-
identifier: assign.propertyType
318-
count: 1
319-
path: src/PhpSpreadsheet/Calculation/Calculation.php
320-
3213
-
3224
message: '#^Cannot access offset int\|string\|null on mixed\.$#'
3235
identifier: offsetAccess.nonOffsetAccessible
@@ -1086,24 +768,12 @@ parameters:
1086768
count: 1
1087769
path: src/PhpSpreadsheet/Calculation/TextData/Concatenate.php
1088770

1089-
-
1090-
message: '#^Cannot access offset int\<0, max\> on mixed\.$#'
1091-
identifier: offsetAccess.nonOffsetAccessible
1092-
count: 11
1093-
path: src/PhpSpreadsheet/Calculation/TextData/Concatenate.php
1094-
1095771
-
1096772
message: '#^Cannot cast mixed to string\.$#'
1097773
identifier: cast.string
1098774
count: 1
1099775
path: src/PhpSpreadsheet/Calculation/TextData/Concatenate.php
1100776

1101-
-
1102-
message: '#^Method PhpOffice\\PhpSpreadsheet\\Calculation\\TextData\\Concatenate\:\:concatenate2Args\(\) should return array\|string but returns mixed\.$#'
1103-
identifier: return.type
1104-
count: 2
1105-
path: src/PhpSpreadsheet/Calculation/TextData/Concatenate.php
1106-
1107777
-
1108778
message: '#^Parameter \#1 \$ignoreEmpty of static method PhpOffice\\PhpSpreadsheet\\Calculation\\TextData\\Concatenate\:\:evaluateTextJoinArray\(\) expects bool, mixed given\.$#'
1109779
identifier: argument.type

src/PhpSpreadsheet/Calculation/BinaryComparison.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,31 @@ class BinaryComparison
1414
/**
1515
* Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters.
1616
*
17-
* @param null|string $str1 First string value for the comparison
18-
* @param null|string $str2 Second string value for the comparison
17+
* @param mixed $str1 First string value for the comparison, expect ?string
18+
* @param mixed $str2 Second string value for the comparison, expect ?string
1919
*/
20-
private static function strcmpLowercaseFirst(?string $str1, ?string $str2): int
20+
private static function strcmpLowercaseFirst(mixed $str1, mixed $str2): int
2121
{
22-
$inversedStr1 = StringHelper::strCaseReverse($str1 ?? '');
23-
$inversedStr2 = StringHelper::strCaseReverse($str2 ?? '');
22+
$str1 = StringHelper::convertToString($str1);
23+
$str2 = StringHelper::convertToString($str2);
24+
$inversedStr1 = StringHelper::strCaseReverse($str1);
25+
$inversedStr2 = StringHelper::strCaseReverse($str2);
2426

2527
return strcmp($inversedStr1, $inversedStr2);
2628
}
2729

2830
/**
2931
* PHP8.1 deprecates passing null to strcmp.
3032
*
31-
* @param null|string $str1 First string value for the comparison
32-
* @param null|string $str2 Second string value for the comparison
33+
* @param mixed $str1 First string value for the comparison, expect ?string
34+
* @param mixed $str2 Second string value for the comparison, expect ?string
3335
*/
34-
private static function strcmpAllowNull(?string $str1, ?string $str2): int
36+
private static function strcmpAllowNull(mixed $str1, mixed $str2): int
3537
{
36-
return strcmp($str1 ?? '', $str2 ?? '');
38+
$str1 = StringHelper::convertToString($str1);
39+
$str2 = StringHelper::convertToString($str2);
40+
41+
return strcmp($str1, $str2);
3742
}
3843

3944
public static function compare(mixed $operand1, mixed $operand2, string $operator): bool

0 commit comments

Comments
 (0)